---
name: pr-review
description: Reviews a pull request, a branch or uncommitted changes, putting correctness bugs first and design second, with severity-ranked findings that cite file and line. Use when the user asks to review a PR, a branch or a diff.
---

# PR Review

Review a change the way a careful teammate would: find what will break, then what will hurt later. Do not comment on style unless the user asks.

## 1. Pin down the target

Decide what is being reviewed and get the exact diff.

```bash
git status --short                      # uncommitted work
git diff                                # unstaged
git diff --staged                       # staged
git diff origin/main...HEAD             # a branch vs its merge base
gh pr diff 123                          # a PR, if the gh CLI is available
git log --oneline origin/main..HEAD     # the commits involved
```

If the target is ambiguous (several branches, a dirty tree plus a PR), ask one short question before reading anything.

## 2. Understand the intent

- Read the PR description, linked issue and commit messages. State the intent in one sentence to yourself.
- If the intent is unclear, say so in the report; a change you cannot explain cannot be judged correct.

## 3. Read the surrounding code, not just the diff

A diff shows what changed, not what it breaks. For every changed function:

- Open the whole file around the hunk, and the callers (`grep -rn "functionName"`).
- Check the contracts: argument types, nullability, error returns, ordering assumptions, units.
- Look for sibling code that should have changed too (other call sites, config, docs, migrations, tests, types).
- Check tests: do they exercise the new behavior, or only the happy path?

## 4. Hunt bugs first

Walk the diff once purely for correctness:

- Off-by-one, wrong comparison, inverted condition, missing `await`, unhandled promise or error.
- Null/undefined/empty-collection inputs, zero, negative, very large values.
- Concurrency: shared state, races, double submit, retries that are not idempotent.
- Resource handling: unclosed handles, transactions not rolled back on error, leaked listeners.
- Data: migrations that lock tables or lose data, changed defaults, timezone and encoding assumptions.
- Backward compatibility: changed API shape, renamed env vars, removed fields still used elsewhere.

Only report a bug if you can describe a concrete input or sequence of events that makes it fail. If you cannot, mark it as a question, not a finding.

## 5. Then design

Second pass, fewer comments, higher bar:

- Does the change belong in this layer or module?
- New coupling, duplicated logic that already exists elsewhere, a public API that will be hard to change.
- Missing tests for risky logic.
- Something simpler that does the same job.

## 6. Output format

Report findings sorted by severity. Use this shape:

```
Summary: <one or two sentences: what the change does and your overall verdict>

[blocker] path/to/file.ts:42 - <short title>
  Scenario: <concrete input/sequence that fails>
  Effect: <what the user or system sees>
  Suggestion: <smallest fix>

[major] ...
[minor] ...
[question] ...

Not checked: <things you could not verify, e.g. did not run the code>
```

Severity scale:

- blocker: data loss, security hole, crash on a common path, wrong results.
- major: bug on an uncommon path, missing error handling, missing test for risky logic.
- minor: small robustness or clarity issue worth fixing but not blocking.
- question: you need the author to explain intent.

If there are no findings, say so plainly and list what you checked. Do not invent problems to look thorough.

## Pitfalls

- Do not review only the lines that are highlighted; bugs live in what the change interacts with.
- Do not flag formatting, naming taste or import order unless asked or the repo has a stated rule.
- Do not claim a bug without a failure scenario.
- Do not run or modify the code in ways that change the user's working tree unless asked. Running tests is fine.
- Do not approve or merge on the user's behalf; give a verdict and let them act.
- Keep the list short: five real findings beat thirty trivial ones.

Source: [AnyModel skills catalog](https://anymodel.org/en/skills) · License: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
