| name | pr-review |
| description | Perform thorough, structured code review on a PR. Detects stack/conventions from the codebase, checks linked issues for acceptance criteria, then reviews the diff with severity-graded findings. |
| compatibility | {"tools":["bash","read","edit"]} |
Code Review Skill
Structured code review. Adapts to whatever stack is in the repo. Reviews only changes in the PR diff — never touches unrelated code.
0. Identify the PR
git branch --show-current
gh pr view --json number,title,url,body,baseRefName,headRefName,state
If no PR found, tell user and stop.
Store: PR_NUMBER, BASE_BRANCH, HEAD_BRANCH.
1. Detect Stack & Conventions
Before reviewing, read the codebase to understand what patterns to enforce.
cat CLAUDE.md 2>/dev/null || cat .claude/CLAUDE.md 2>/dev/null
ls package-lock.json yarn.lock pnpm-lock.yaml bun.lockb 2>/dev/null | head -1
cat package.json 2>/dev/null | head -60
ls tsconfig.json pyproject.toml go.mod Cargo.toml mix.exs 2>/dev/null
grep -r "jest\|vitest\|pytest\|rspec\|go test" package.json pyproject.toml go.mod 2>/dev/null | head -5
From this, derive:
- Language + runtime
- Framework (Next.js, Express, Django, Rails, Go stdlib, etc.)
- Package manager
- TypeScript strictness (if applicable)
- Test framework
- Any project-specific conventions from CLAUDE.md
2. Check Linked Issues
gh pr view $PR_NUMBER --json body --jq '.body'
Scan body for closing keywords: closes, fixes, resolves (case-insensitive), followed by #N or a full GitHub issue URL.
For each linked issue:
gh issue view $ISSUE_NUMBER --json title,body,labels,milestone
Extract:
- Goal / problem statement
- Acceptance criteria (look for checklist items, "should", "must", "expected behaviour" sections)
- Out of scope notes
Build an Issue Checklist — a list of requirements the PR must satisfy. You will verify these during review.
3. Get the Diff
git diff origin/$BASE_BRANCH...HEAD
git diff --name-status origin/$BASE_BRANCH...HEAD
Classify changed files by type (page, route handler, component, hook, model, migration, test, config, etc.).
For large PRs (>20 files), group by feature area and review group by group.
4. Review Each File
Read every changed file twice — once for intent, once for issues.
cat src/<path/to/file>
Never skim. Never review only the diff lines — understand surrounding context.
Severity Classification
- 🔴 Critical — bug, security hole, broken auth, data loss, crash, build failure
- 🟡 Warning — anti-pattern, likely future bug, performance problem, missing error handling
- 🟢 Suggestion — readability, naming, style, conventions
5. Review Checklist
Apply these checks universally. Skip sections not applicable to the stack.
Issue / Acceptance Criteria Coverage
Flag any acceptance criteria not met as 🔴 Critical.
Logic & Correctness
Security
Error Handling
Types & Contracts (TypeScript / typed languages)
State & Data Flow
Performance
Code Quality
Conventions (from CLAUDE.md and detected stack)
Apply any project-specific rules detected in §1. Flag violations as 🟡 Warning.
6. Anti-Pattern Radar
Watch for signs of vibe coding / over-engineering regardless of stack:
| Pattern | What to look for |
|---|
| Unnecessary fallbacks | Default values that mask real errors |
| Over-complicated data processing | Multi-step transforms that could be a single expression |
| Non-SOLID code | God functions, mixed concerns, feature envy |
| Defensive over-engineering | Try/catch around code that can't throw |
| Stale TODO/FIXME | Comments referencing issues that should be resolved |
| Premature abstraction | Generic helper written for one use case |
| Shadowed variables | const x in inner scope hiding outer x |
7. Output Format
Prioritise by severity, not by file order.
## Code Review: [PR title] (#N)
### Issue Coverage
> Linked issues: #X — [title]
| Criterion | Status |
|---|---|
| [AC item 1] | ✅ / ⚠️ / ❌ |
| [AC item 2] | ✅ / ⚠️ / ❌ |
### Summary
One paragraph: overall quality, biggest concerns, what's done well.
### 🔴 Critical Issues
1. **[Short title]** (`src/path/to/file.ts`, line N)
Problem. Why it matters. Concrete fix.
// Before
...
// After
...
### 🟡 Warnings
...same format...
### 🟢 Suggestions
...same format...
### ✅ What's working well
Callouts of good patterns to reinforce.
Rules:
- Lead with the most severe issue, not the first file
- Every finding gets a concrete fix — not just a description
- For large fixes, offer: "Want me to apply this?"
- Cap at ~10 items per category for large PRs
- If a 🔴 maps to an unmet acceptance criterion, say so explicitly
8. After the Review
- Issue coverage verdict: all criteria met / partially met / missing items
- Offer to apply fixes for 🔴 and 🟡 items: "Want me to apply any of these?"
- Offer a deeper dive if a category had 3+ issues in same area
- Check related files if tight coupling spotted
- Run type check after any TypeScript changes:
pnpm tsc --noEmit (or equivalent)
- Run lint after changes:
pnpm lint (or equivalent)
Apply fixes one at a time, confirm each before moving to the next.