| name | code-review |
| description | Structured diff and PR code review with a prioritized checklist. Use when reviewing staged changes, pull requests, or any code diff before merge. |
| requires_bins | ["git"] |
When to use
- Before merging a PR or feature branch
- Reviewing staged changes before committing
- Auditing a specific file or range of commits
- Any time you need a structured, consistent review output
Step 1 — Capture the diff
git diff
git diff --staged
git diff main...HEAD
git diff HEAD -- path/to/file.py
git diff abc123 def456
git diff --stat main...HEAD
Step 2 — Understand context
git log --oneline main..HEAD
git log --follow -p -- path/to/file.py
git show HEAD:path/to/file.py
Step 3 — Review checklist
Work through each category. Flag findings as P0/P1/P2 (below).
Correctness
Security
Performance
Tests
Style & readability
Breaking changes & API compat
Error handling
Step 4 — Output format
Produce a prioritized findings list. Read-only: propose changes, do not edit files directly.
## Review: <branch or description>
### Summary
<2-3 sentence overview of what the diff does and overall risk level>
### Findings
**P0 — Must fix before merge**
- [security-scan.py:42] SQL query built with f-string from user input → SQL injection.
Suggest: use parameterized query `cursor.execute(sql, (user_val,))`.
**P1 — Should fix**
- [api/orders.py:118] New `/admin/orders` endpoint missing auth check.
- [utils/parser.py:67] `yaml.load(data)` → use `yaml.safe_load(data)`.
**P2 — Nice to have / nit**
- [models/user.py:34] Variable `tmp` is unclear; rename to `normalized_email`.
- No test for the empty-input case in `parse_csv`.
### Verdict
[ ] Approve [ ] Request changes [ ] Needs discussion
Priority definitions
| Level | Meaning |
|---|
| P0 | Blocks merge: security vulnerability, data loss, crash in prod |
| P1 | Should fix: correctness bug, missing auth, missing tests for new behavior |
| P2 | Improve before or after merge: style, naming, coverage gaps |
Useful one-liners
git diff --name-only main...HEAD
git diff --numstat main...HEAD
git diff main...HEAD | grep -i "password\|secret\|token\|api_key"
git diff main...HEAD | grep "^+" | grep -i "todo\|fixme\|hack\|xxx"