---
aim: pr_review
kind: intent
nature: subject
---

# Pull Request Review Skill

## Summary

An agent skill for reviewing pull requests against shared team standards. Checks CI and scope first, audits the diff with concrete file-and-line evidence, pauses for a human maintainer on sensitive areas, and posts a structured review summary without silently merging.

## Requirements

- **TESTS-FIRST** — Never review a broken build; stop and report failing checks before auditing the diff.
- **EVIDENCE-ONLY** — Every finding cites a file path, line range, and concrete risk — never vague style nitpicks.
- **HUMAN-ON-RISK** — Changes touching authentication, billing, or database migrations require maintainer clearance before the review posts.
- **NO-SILENT-MERGE** — The skill posts a structured review summary and never approves or merges on a maintainer's behalf.

## Persona: ReviewAgent

### Label

Review Agent

### Role

- Executes the pull request review skill, inspects the diff against shared team standards, and drafts evidence-backed findings.

### Access

- Runs the review workflow — [invokes](aim:pr_review#Process:RunCodeReview)
- Checks CI status and diff scope — [invokes](aim:pr_review#Operation:CheckBuildAndScope)
- Audits changes against team standards — [invokes](aim:pr_review#Operation:AuditDiff)
- Posts the final review summary — [invokes](aim:pr_review#Operation:PostReviewSummary)
- Produces the structured review — [produces](aim:pr_review#Result:ReviewSummary)

## Persona: Maintainer

### Role

- Human owner responsible for clearing high-risk changes and deciding whether a pull request merges.

### Access

- Clears high-risk changes after human inspection — [invokes](aim:pr_review#Operation:ClearRiskGate)

## Knowledge: TeamStandards

### Label

Shared Team Review Standards

### Summary

Authoritative security, correctness, and backwards-compatibility checklist shared across all engineering skills so policies live in one place instead of being copy-pasted into every prompt.

## Record: PullRequest

### Summary

The pull request currently under review by the skill.

### Schema

```schema
id: string required unique key
repo: string required
author: string required
checksGreen: boolean required
touchesSensitiveArea: boolean required
status: enum(Queued, Reviewing, AwaitingMaintainer, Posted, Blocked) required default(Queued)
```

### Immutable

- `id`
- `repo`
- `author`

## Record: Finding

### Summary

One concrete issue discovered during the diff audit, backed by file location and risk explanation.

### Schema

```schema
id: string required unique key
prId: ref(pr_review#PullRequest.id) required
filePath: string required
lineRange: string required
severity: enum(blocker, warning, note) required
risk: string required
```

## State: ReviewLifecycle

### Summary

Tracks a pull request from review request through auditing, optional maintainer sign-off, and final summary or early block.

### Of

- `pr_review#Record:PullRequest.status`

### States

- Queued — initial
- Reviewing
- AwaitingMaintainer
- Posted — final
- Blocked — final

### Moves

- Queued → Reviewing — [pr_review#Operation:CheckBuildAndScope]
- Queued → Blocked — [pr_review#Operation:CheckBuildAndScope]
- Reviewing → AwaitingMaintainer — [pr_review#Operation:AuditDiff]
- AwaitingMaintainer → Reviewing — [pr_review#Operation:ClearRiskGate]
- Reviewing → Posted — [pr_review#Operation:PostReviewSummary]

## Operation: CheckBuildAndScope

### Label

Check Build & Scope

### Summary

Verifies that automated checks pass and the diff is in scope before spending tokens auditing code.

### Input

```schema
prId: ref(pr_review#PullRequest.id) required
```

### Ensures

- Updates the pull request status based on CI health — [reads](aim:pr_review#Record:PullRequest), [mutates](aim:pr_review#Record:PullRequest), [satisfies](aim:pr_review#Requirements[TESTS-FIRST])

### Decides

- **Ready** — automated checks are green and the diff is ready for audit
- **Blocked** — automated checks failed; report the failure and stop

### Criteria

```criteria
Ready when checksGreen = true
otherwise Blocked
```

## Operation: AuditDiff

### Label

Audit Diff Against Standards

### Summary

Inspects changed files against shared team standards, records evidence-backed findings, and checks whether sensitive areas require human sign-off.

### Input

```schema
prId: ref(pr_review#PullRequest.id) required
```

### Ensures

- Applies shared team policies without copy-pasted prompt rules — [consults](aim:pr_review#Knowledge:TeamStandards)
- Records only file-and-line cited findings — [reads](aim:pr_review#Record:PullRequest), [mutates](aim:pr_review#Record:Finding), [mutates](aim:pr_review#Record:PullRequest), [satisfies](aim:pr_review#Requirements[EVIDENCE-ONLY])

### Decides

- **Standard** — no sensitive paths touched; gate clears immediately — [emits](aim:pr_review#Event:RiskGateCleared)
- **HighRisk** — touches auth, billing, or migrations; escalates to maintainer — [emits](aim:pr_review#Event:MaintainerSignOffRequested), [satisfies](aim:pr_review#Requirements[HUMAN-ON-RISK])

### Criteria

```criteria
HighRisk when touchesSensitiveArea = true
otherwise Standard
```

## Operation: ClearRiskGate

### Label

Maintainer Risk Sign-Off

### Summary

A human maintainer reviews high-risk findings and clears the pull request so the agent can publish the review summary.

### Input

```schema
prId: ref(pr_review#PullRequest.id) required
```

### Ensures

- Records human clearance on sensitive changes — [reads](aim:pr_review#Record:PullRequest), [reads](aim:pr_review#Record:Finding), [mutates](aim:pr_review#Record:PullRequest), [emits](aim:pr_review#Event:RiskGateCleared), [satisfies](aim:pr_review#Requirements[HUMAN-ON-RISK])

## Operation: PostReviewSummary

### Label

Post Review Summary

### Summary

Publishes the structured review comment with cited findings and verdict without merging or approving on a human's behalf.

### Input

```schema
prId: ref(pr_review#PullRequest.id) required
```

### Expects

- The formatted review summary is ready — [needs](aim:pr_review#Result:ReviewSummary)

### Ensures

- Publishes the review and closes the run without silent merge — [reads](aim:pr_review#Record:PullRequest), [reads](aim:pr_review#Record:Finding), [mutates](aim:pr_review#Record:PullRequest), [emits](aim:pr_review#Event:ReviewPosted), [satisfies](aim:pr_review#Requirements[NO-SILENT-MERGE])

## Result: ReviewSummary

### Label

Structured Review Summary

### Summary

A concise pull request comment grouping blockers, warnings, and notes with exact file paths, line ranges, and concrete risks.

### Format

- markdown — verdict, test status, and cited findings grouped by severity

### Ensures

- Cites every recorded finding with file and line evidence — [reads](aim:pr_review#Record:Finding), [satisfies](aim:pr_review#Requirements[EVIDENCE-ONLY])
- States recommendation only, never merges automatically — [satisfies](aim:pr_review#Requirements[NO-SILENT-MERGE])

## Process: RunCodeReview

### Label

Run Pull Request Review

### Summary

End-to-end execution of the pull request review skill: gate on green CI, audit against shared standards, wait for risk-gate clearance, and post the summary.

### Steps

1. Check CI status and diff scope — [invokes](aim:pr_review#Operation:CheckBuildAndScope) — continues: Ready
2. Audit the diff against shared team standards — [invokes](aim:pr_review#Operation:AuditDiff) — continues: Standard, HighRisk
3. Wait for risk-gate clearance (automatic on standard PRs, maintainer sign-off on high-risk paths) — [subscribes](aim:pr_review#Event:RiskGateCleared)
4. Post the structured review summary — [invokes](aim:pr_review#Operation:PostReviewSummary)

## Event: MaintainerSignOffRequested

### Summary

A high-risk pull request was escalated to a human maintainer for inspection.

## Event: RiskGateCleared

### Summary

Risk checks passed automatically or a maintainer signed off on high-risk paths.

## Event: ReviewPosted

### Summary

The structured pull request review summary was posted.

## Trigger: PullRequestOpened

### Label

Pull Request Opened or Updated

### Summary

Activates the review skill whenever a pull request is opened or receives new commits.

### Kind

- webhook

### Fires

- [triggers](aim:pr_review#Process:RunCodeReview)
