PR Review
Bug-first PR review: report only findings with evidence, reachable impact, and a
concrete fix. Prefer silence over false positives.
Step 1 — Acquire Context (run independent reads in parallel)
# If PR number given:
gh pr view <number> --json title,body,files,baseRefName,headRefName,commits
gh pr diff <number>
# If reviewing current branch, determine base first:
git status -sb
git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null || true
git merge-base HEAD origin/<base-branch>
git diff "$(git merge-base HEAD origin/<base-branch>)"..HEAD
git log "$(git merge-base HEAD origin/<base-branch>)"..HEAD --oneline
Use the PR's baseRefName when available. Do not assume main if the PR or
repository reports a different base branch.
Also read applicable guidance:
- root
CLAUDE.md / REVIEW.md
- any
CLAUDE.md / REVIEW.md in directories containing modified files
- skip rules for generated files, vendored code, snapshots, fixtures, or file patterns
Build a guidance map: which rules apply to which changed paths.
Done only when you have: base branch, head branch, file list, full diff, commit
list, PR description, guidance map, and skipped paths. If any item is
unavailable, state why before review.
Step 2 — Profile the Diff
Check what the diff touches to decide which specialist passes to run:
HAS_REACT — diff contains .tsx, .jsx, use*.ts, components/, or similar
HAS_ARCH — diff touches services/, schemas/, api/, routes/, migrations/, prisma/
HAS_UI — diff contains CSS, Tailwind classes, styled-components, or design tokens
HAS_CONFIG — diff touches build, deploy, dependency, env, CI, auth, or database config
Step 3 — Run Specialist Passes
For non-trivial diffs, run specialist passes in parallel when agents are
available. Otherwise run the same passes sequentially yourself. Each pass must
read enough surrounding code to confirm data flow and call sites.
Always run:
- Bug + regression — logic errors, broken edge cases, build failures, wrong results
- Security + trust boundaries — exploit paths, auth bypasses, injection, races, secret exposure
- Guideline compliance — exact violations of the guidance map; cite the rule and respect skip rules
If HAS_ARCH:
- Architecture — coupling, boundary violations, schema design, migration/backward compatibility
If HAS_REACT:
- React runtime — hook dependencies, stale closures, key stability, hydration, waterfalls, memoization correctness
If HAS_UI:
- Accessibility + interface — WCAG issues, labels, keyboard navigation, focus states, contrast, interactive states
If HAS_CONFIG:
- Release safety — deploy/build breaks, unsafe defaults, missing migrations, dependency/runtime mismatch
Step 4 — Validate Candidate Findings
Before reporting a candidate, confirm all gates:
- The issue was introduced by this PR, or is pre-existing but directly relevant
to the changed code path.
- The affected path is reachable with realistic inputs or states.
- The problem is not handled elsewhere by a guard, fallback, type guarantee,
transaction, try/catch, sanitizer, or caller contract.
- The impact is concrete: accuracy, security, reliability, performance, or
maintainability harm the author would likely fix.
- The finding is guidance-scoped: it does not violate skip rules and cites any
exact project rule it enforces.
If validation fails, drop the finding silently.
Step 5 — Reconcile Findings
- Deduplicate findings that describe the same underlying issue.
- Keep the most specific description and highest justified severity.
- Score severity:
- P0 — production-stopping issue: exploitable security hole, data loss, broken core flow, deploy/build break
- P1 — should fix before merge: clear correctness, reliability, or security bug
- P2 — fix soon: performance or maintainability issue a senior engineer would care about
- P3 — low risk: clear guidance violation or minor bug worth fixing, but non-blocking
- Pre-existing — existing bug directly relevant to the changed path but not introduced here
- Resolve contradictions by source evidence first: diff, tests, docs, runtime behavior. Ask the user only when product intent is required.
Output Format
## PR Review — <title>
Issues: N P0 · N P1 · N P2 · N P3 · N pre-existing
### P0
- `path/to/file.ts:42` — [Issue description] → [Specific fix]
### P1
- `path/to/file.ts:88` — [Issue description] → [Specific fix]
### P2
...
### Pre-existing
...
### Risk Summary
[No blocking issues found / Found issues worth addressing before merge / Found production-risk issue]
Omit sections that have no findings. Do not approve, block, or post comments.
Hard Constraints
- Do not comment on GitHub/GitLab or call commenting tools unless the user explicitly asks
- Do not flag style, formatting, or missing tests unless guidance says so or the issue creates concrete risk
- Do not invent rules; enforce only evidenced bugs and applicable project guidance
- Do not flag theoretical security risks without a plausible path to harm
- Do not flag skipped paths or generated files unless guidance explicitly includes them
- Prefer no findings over weak findings
1---2name: pr-review3description: Bug-first, evidence-only PR review with guidance-scoped specialist passes for security, correctness, architecture, React patterns, and accessibility. Use when the user says "review this PR", "review my changes", "review the diff", or mentions a PR number. Prefers silence over speculative findings.4---56# PR Review78Bug-first PR review: report only findings with evidence, reachable impact, and a9concrete fix. Prefer silence over false positives.1011## Step 1 — Acquire Context (run independent reads in parallel)1213```bash14# If PR number given:15gh pr view <number> --json title,body,files,baseRefName,headRefName,commits16gh pr diff <number>1718# If reviewing current branch, determine base first:19git status -sb20git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null || true21git merge-base HEAD origin/<base-branch>22git diff "$(git merge-base HEAD origin/<base-branch>)"..HEAD23git log "$(git merge-base HEAD origin/<base-branch>)"..HEAD --oneline24```2526Use the PR's `baseRefName` when available. Do not assume `main` if the PR or27repository reports a different base branch.2829Also read applicable guidance:3031- root `CLAUDE.md` / `REVIEW.md`32- any `CLAUDE.md` / `REVIEW.md` in directories containing modified files33- skip rules for generated files, vendored code, snapshots, fixtures, or file patterns3435Build a guidance map: which rules apply to which changed paths.3637Done only when you have: base branch, head branch, file list, full diff, commit38list, PR description, guidance map, and skipped paths. If any item is39unavailable, state why before review.4041## Step 2 — Profile the Diff4243Check what the diff touches to decide which specialist passes to run:4445- `HAS_REACT` — diff contains `.tsx`, `.jsx`, `use*.ts`, `components/`, or similar46- `HAS_ARCH` — diff touches `services/`, `schemas/`, `api/`, `routes/`, `migrations/`, `prisma/`47- `HAS_UI` — diff contains CSS, Tailwind classes, styled-components, or design tokens48- `HAS_CONFIG` — diff touches build, deploy, dependency, env, CI, auth, or database config4950## Step 3 — Run Specialist Passes5152For non-trivial diffs, run specialist passes in parallel when agents are53available. Otherwise run the same passes sequentially yourself. Each pass must54read enough surrounding code to confirm data flow and call sites.5556**Always run:**57- **Bug + regression** — logic errors, broken edge cases, build failures, wrong results58- **Security + trust boundaries** — exploit paths, auth bypasses, injection, races, secret exposure59- **Guideline compliance** — exact violations of the guidance map; cite the rule and respect skip rules6061**If HAS_ARCH:**62- **Architecture** — coupling, boundary violations, schema design, migration/backward compatibility6364**If HAS_REACT:**65- **React runtime** — hook dependencies, stale closures, key stability, hydration, waterfalls, memoization correctness6667**If HAS_UI:**68- **Accessibility + interface** — WCAG issues, labels, keyboard navigation, focus states, contrast, interactive states6970**If HAS_CONFIG:**71- **Release safety** — deploy/build breaks, unsafe defaults, missing migrations, dependency/runtime mismatch7273## Step 4 — Validate Candidate Findings7475Before reporting a candidate, confirm all gates:7677- The issue was introduced by this PR, or is pre-existing but directly relevant78 to the changed code path.79- The affected path is reachable with realistic inputs or states.80- The problem is not handled elsewhere by a guard, fallback, type guarantee,81 transaction, try/catch, sanitizer, or caller contract.82- The impact is concrete: accuracy, security, reliability, performance, or83 maintainability harm the author would likely fix.84- The finding is guidance-scoped: it does not violate skip rules and cites any85 exact project rule it enforces.8687If validation fails, drop the finding silently.8889## Step 5 — Reconcile Findings90911. Deduplicate findings that describe the same underlying issue.922. Keep the most specific description and highest justified severity.933. Score severity:94 - **P0** — production-stopping issue: exploitable security hole, data loss, broken core flow, deploy/build break95 - **P1** — should fix before merge: clear correctness, reliability, or security bug96 - **P2** — fix soon: performance or maintainability issue a senior engineer would care about97 - **P3** — low risk: clear guidance violation or minor bug worth fixing, but non-blocking98 - **Pre-existing** — existing bug directly relevant to the changed path but not introduced here994. Resolve contradictions by source evidence first: diff, tests, docs, runtime behavior. Ask the user only when product intent is required.100101## Output Format102103```104## PR Review — <title>105Issues: N P0 · N P1 · N P2 · N P3 · N pre-existing106107### P0108- `path/to/file.ts:42` — [Issue description] → [Specific fix]109110### P1111- `path/to/file.ts:88` — [Issue description] → [Specific fix]112113### P2114...115116### Pre-existing117...118119### Risk Summary120[No blocking issues found / Found issues worth addressing before merge / Found production-risk issue]121```122123Omit sections that have no findings. Do not approve, block, or post comments.124125## Hard Constraints126127- Do not comment on GitHub/GitLab or call commenting tools unless the user explicitly asks128- Do not flag style, formatting, or missing tests unless guidance says so or the issue creates concrete risk129- Do not invent rules; enforce only evidenced bugs and applicable project guidance130- Do not flag theoretical security risks without a plausible path to harm131- Do not flag skipped paths or generated files unless guidance explicitly includes them132- Prefer no findings over weak findings