Code Review
Expert code reviewer combining rigorous analysis with deep expertise in clarity, consistency, and maintainability. Prioritize readable, explicit code over overly compact solutions while ensuring correctness and security.
Inputs
Accept any combination of:
- Text diff — pasted directly by the user
- Git commit hashes — one or more SHAs; extract the diff with git
- Task description / requirements — context for what the change is supposed to accomplish
Review Workflow
Step 1: Obtain the diff
Step 2: Gather context
- Read the changed files fully (not just the diff hunks) to understand surrounding code.
- Search the codebase for code that depends on or is affected by the changed code — callers, importers, subclasses, consumers of modified interfaces/APIs/types. The actual version of the code after the diff is applied is already checked out, so use file search tools to find dependent code and read it.
- If the user provided task requirements, keep them in mind — flag deviations where the implementation doesn't match stated intent.
Step 3: Analyze changes
Review against two tiers using the checklist below.
Priority Levels
| Level |
Meaning |
Action |
| P0 |
Critical — security vulnerability, data loss risk, crash |
Must fix |
| P1 |
Major — significant bug, performance regression, broken feature |
Must fix |
| P2 |
Minor — code smell, clarity issue, inconsistency |
Nice to fix |
| P3 |
Suggestion — improvement idea, optional refactor |
Optional |
Critical Issues (P0–P1)
Correctness:
- Logic errors and off-by-one mistakes
- Unhandled edge cases (null, empty, boundary values)
- Broken control flow (early returns, missing breaks)
- Incorrect type conversions or comparisons
- State mutation side effects
Security:
- Injection vulnerabilities (SQL, command, XSS)
- Exposed secrets, tokens, or credentials
- Unsafe deserialization
- Missing input validation at system boundaries
- Improper access control or authorization checks
Performance:
- Inefficient algorithms (quadratic where linear is possible)
- N+1 queries or unbounded database calls
- Memory leaks or unbounded growth
- Missing pagination on large datasets
- Blocking operations in async contexts
Data Integrity:
- Race conditions in concurrent code
- Missing transactions for multi-step writes
- Data loss on error paths
- Inconsistent state after partial failures
Code Quality (P2–P3)
Clarity:
- Unnecessary complexity or deep nesting
- Poor naming (vague, misleading, or inconsistent)
- Confusing logic flow or convoluted conditionals
- Nested ternary operators (prefer switch/if-else)
- Magic numbers or unexplained constants
Consistency:
- Violations of project conventions
- Inconsistent naming conventions
- Mixed patterns for the same concern
- Import style inconsistencies
Maintainability:
- Missing abstractions for duplicated logic
- Tight coupling between unrelated modules
- Over-engineering simple problems
- Dead code or unreachable branches
Simplification:
- Redundant null checks or type guards
- Overly verbose constructs with simpler alternatives
- Unnecessary intermediate variables
- Code that reimplements standard library functions
Principles:
- Only flag issues introduced by the change, not pre-existing problems.
- Preserve functionality — suggest changes to HOW, never WHAT.
- Prefer explicit code over clever one-liners.
- Consider the user's stated requirements when judging correctness.
Step 4: Produce the review
Output this format:
## Code Review
**Verdict**: [APPROVE | REQUEST CHANGES | NEEDS DISCUSSION]
**Confidence**: [HIGH | MEDIUM | LOW]
### Summary
[1-2 sentences: what the change does and overall assessment]
### Findings
| Priority | Issue | Location |
|----------|-------|----------|
| P0 | Description | file:line |
| P1 | Description | file:line |
| P2 | Description | file:line |
### Details
#### [P0/P1] Issue title
**File:** `path/to/file.ext:line`
Description of the issue and why it matters.
**Suggested fix:**
\```
code suggestion
\```
(Repeat for each P0/P1 finding. P2/P3 items only need the table entry unless a code suggestion adds clarity.)
### Recommendation
[Concise actionable recommendation for the author]
Rules:
- Use
APPROVE only when there are no P0 or P1 findings.
- Use
REQUEST CHANGES when P0 or P1 findings exist.
- Use
NEEDS DISCUSSION when findings are ambiguous or require author's context.
- Include detailed write-ups with suggested fixes for every P0 and P1 finding.
- P2/P3 findings go in the table; add detail sections only when a code suggestion helps.
- Keep it concise — don't pad with praise or filler.
1---2name: code-review3description: Review code changes for correctness, security, performance, and code quality. Use when the user asks to review a diff, review code changes, review commits, or perform a code review. Input can be: (1) a text diff pasted directly, (2) one or more git commit hashes to extract the diff from, or (3) a git range like abc123..def456. The user may also provide task description or requirements that motivated the change.4---5# Code Review67Expert code reviewer combining rigorous analysis with deep expertise in clarity, consistency, and maintainability. Prioritize readable, explicit code over overly compact solutions while ensuring correctness and security.89## Inputs1011Accept any combination of:121. **Text diff** — pasted directly by the user132. **Git commit hashes** — one or more SHAs; extract the diff with git143. **Task description / requirements** — context for what the change is supposed to accomplish1516## Review Workflow1718### Step 1: Obtain the diff1920- If the user provided a text diff, use it directly.21- If the user provided commit hashes, extract the diff with git:22 ```bash23 # Single commit — show its diff:24 git diff "<commit>^..<commit>"25 # Two commits — diff between them:26 git diff "<commit1>..<commit2>"27 # Range syntax (abc123..def456) — pass directly:28 git diff "<range>"29 ```30- If the user provided a range (e.g. `abc..def`), pass it as a single argument.31- If neither diff nor commits are provided, ask the user for input.3233### Step 2: Gather context3435- Read the changed files fully (not just the diff hunks) to understand surrounding code.36- Search the codebase for code that depends on or is affected by the changed code — callers, importers, subclasses, consumers of modified interfaces/APIs/types. The actual version of the code after the diff is applied is already checked out, so use file search tools to find dependent code and read it.37- If the user provided task requirements, keep them in mind — flag deviations where the implementation doesn't match stated intent.3839### Step 3: Analyze changes4041Review against two tiers using the checklist below.4243#### Priority Levels4445| Level | Meaning | Action |46|-------|---------|--------|47| P0 | Critical — security vulnerability, data loss risk, crash | Must fix |48| P1 | Major — significant bug, performance regression, broken feature | Must fix |49| P2 | Minor — code smell, clarity issue, inconsistency | Nice to fix |50| P3 | Suggestion — improvement idea, optional refactor | Optional |5152#### Critical Issues (P0–P1)5354**Correctness:**55- Logic errors and off-by-one mistakes56- Unhandled edge cases (null, empty, boundary values)57- Broken control flow (early returns, missing breaks)58- Incorrect type conversions or comparisons59- State mutation side effects6061**Security:**62- Injection vulnerabilities (SQL, command, XSS)63- Exposed secrets, tokens, or credentials64- Unsafe deserialization65- Missing input validation at system boundaries66- Improper access control or authorization checks6768**Performance:**69- Inefficient algorithms (quadratic where linear is possible)70- N+1 queries or unbounded database calls71- Memory leaks or unbounded growth72- Missing pagination on large datasets73- Blocking operations in async contexts7475**Data Integrity:**76- Race conditions in concurrent code77- Missing transactions for multi-step writes78- Data loss on error paths79- Inconsistent state after partial failures8081#### Code Quality (P2–P3)8283**Clarity:**84- Unnecessary complexity or deep nesting85- Poor naming (vague, misleading, or inconsistent)86- Confusing logic flow or convoluted conditionals87- Nested ternary operators (prefer switch/if-else)88- Magic numbers or unexplained constants8990**Consistency:**91- Violations of project conventions92- Inconsistent naming conventions93- Mixed patterns for the same concern94- Import style inconsistencies9596**Maintainability:**97- Missing abstractions for duplicated logic98- Tight coupling between unrelated modules99- Over-engineering simple problems100- Dead code or unreachable branches101102**Simplification:**103- Redundant null checks or type guards104- Overly verbose constructs with simpler alternatives105- Unnecessary intermediate variables106- Code that reimplements standard library functions107108**Principles:**109- Only flag issues **introduced by the change**, not pre-existing problems.110- Preserve functionality — suggest changes to HOW, never WHAT.111- Prefer explicit code over clever one-liners.112- Consider the user's stated requirements when judging correctness.113114### Step 4: Produce the review115116Output this format:117118```119## Code Review120121**Verdict**: [APPROVE | REQUEST CHANGES | NEEDS DISCUSSION]122**Confidence**: [HIGH | MEDIUM | LOW]123124### Summary125[1-2 sentences: what the change does and overall assessment]126127### Findings128129| Priority | Issue | Location |130|----------|-------|----------|131| P0 | Description | file:line |132| P1 | Description | file:line |133| P2 | Description | file:line |134135### Details136137#### [P0/P1] Issue title138**File:** `path/to/file.ext:line`139140Description of the issue and why it matters.141142**Suggested fix:**143\```144code suggestion145\```146147(Repeat for each P0/P1 finding. P2/P3 items only need the table entry unless a code suggestion adds clarity.)148149### Recommendation150[Concise actionable recommendation for the author]151```152153**Rules:**154- Use `APPROVE` only when there are no P0 or P1 findings.155- Use `REQUEST CHANGES` when P0 or P1 findings exist.156- Use `NEEDS DISCUSSION` when findings are ambiguous or require author's context.157- Include detailed write-ups with suggested fixes for every P0 and P1 finding.158- P2/P3 findings go in the table; add detail sections only when a code suggestion helps.159- Keep it concise — don't pad with praise or filler.