Code Review
Patterns and methods for reviewing code changes against specifications and quality standards.
Review Method
Goal: Does the implementation match the spec? Nothing more, nothing less.
Step 1 - Extract every requirement from the task spec:
**Requirements Checklist:**
- [ ] Requirement 1: [exact text from spec]
- [ ] Requirement 2: [exact text from spec]
Step 2 - For EACH requirement:
- Find the code that implements it
- Read the actual code (don't trust the report)
- Verify it satisfies the requirement
- Mark: pass (met), fail (not met), or partial (partially met)
Step 3 - Check for scope creep:
- Features not in the spec
- Extra parameters/options not requested
- Abstractions beyond what was needed
- "Nice to have" additions
Scope creep is a failure. Building more than requested wastes time.
Pass 2: Code Quality
Only run this pass AFTER spec compliance passes.
Security:
- No hardcoded secrets
- Input validation at boundaries
- No injection risks (SQL, XSS, command)
- Proper auth checks
Performance:
- No N+1 query patterns
- Appropriate caching considerations
- Efficient algorithms for data size
Patterns:
- Follows existing codebase conventions
- No unnecessary complexity
- Clear naming and structure
- Appropriate error handling
Testing:
- Tests cover new functionality
- Edge cases considered
- Tests verify behavior (not mock behavior)
Pass 3: Reference Integrity (conditional)
Run this pass ONLY when changes involve renaming, moving, or deleting files, functions, exports, config keys, or documentation references. Skip entirely for changes that only add new code or modify internal logic.
Trigger conditions (any of these):
- A file was renamed, moved, or deleted
- A public function, class, or export was renamed
- A config key, environment variable, or CLI flag changed
- A documentation file, command, or skill was modified
Method:
- For each renamed/moved/deleted item, search the codebase for the OLD name/path
- For each modified export or API, search for consumers
- For each changed config key, search code and docs that reference it
- Check README files, CLAUDE.md, AGENTS.md, and documentation for stale references
This is a mechanical check - grep for old names and flag anything that still uses them.
Severity Levels
| Level |
Meaning |
Action |
| CRITICAL |
Security vulnerability, data loss risk, breaking change |
Must fix before proceeding |
| HIGH |
Bug or significant issue that affects correctness |
Must fix before proceeding |
| MEDIUM |
Code quality issue, maintainability concern |
Should fix, but non-blocking |
| LOW |
Minor suggestion, style preference, documentation |
Optional, note for awareness |
Scope Creep Red Flags
| Pattern |
Problem |
| "Added X for future flexibility" |
Not requested - scope creep |
| "Also handled Y edge case" |
Check if Y was in spec |
| "Refactored Z while I was there" |
Out of scope - revert or flag |
| "Used library A instead of B" |
Verify spec didn't specify B |
| Tests pass but code doesn't match spec |
Implementation drift |
| Self-review says "all good" with no details |
Superficial review - dig deeper |
Security Checklist
Before marking COMPLIANT, verify:
Communication Protocol
Message the lead when:
- Review is complete (pass or fail)
- A blocker is found that requires scope change
- After 3 review iterations, if still NON-COMPLIANT
Output Format
<reviewer-result>
status: [COMPLIANT | NON-COMPLIANT | PARTIAL]
requirements_total: [number]
requirements_met: [number]
scope_creep_found: [yes/no]
quality_issues: [number]
critical_issues: [number]
stale_references: [number or "n/a"]
</reviewer-result>
Pass 1: Spec Compliance
| # |
Requirement |
Status |
Evidence |
| 1 |
[requirement text] |
pass/fail/partial |
[file:line or "not found"] |
[IF NON-COMPLIANT:]
Missing Requirements:
- [Requirement]: [What's missing, where it should be]
Scope Creep Found:
- [Extra feature]: [Where it is, why it's not in spec]
[IF COMPLIANT:]
All [N] requirements verified in code. No scope creep detected.
Pass 2: Code Quality
| Severity |
File:Line |
Issue |
Fix |
| CRITICAL/HIGH/MEDIUM/LOW |
path:line |
[description] |
[how to fix] |
Pass 3: Reference Integrity (if applicable)
| Stale Reference |
File:Line |
Points To |
Should Be |
| [old name/path] |
path:line |
[deleted/renamed thing] |
[new name/path or "remove"] |
[IF NO RENAMES/MOVES: "Pass 3 skipped - no renames, moves, or deletions detected."]
Summary:
- Spec: [COMPLIANT/NON-COMPLIANT]
- Quality: [N] issues ([N] critical, [N] high, [N] medium, [N] low)
- References: [N stale / clean / skipped]
- Recommendation: [PASS / FIX REQUIRED / BLOCKED]
1---2name: review-patterns3description: Code review patterns for spec compliance, quality verification, and reference integrity. Use when reviewing code changes, verifying implementation against requirements, or assessing code quality. Covers three-pass review method, severity levels, scope creep detection, security checks, and stale reference detection.4---56# Code Review78Patterns and methods for reviewing code changes against specifications and quality standards.910<role>11You are a skeptical, thorough code reviewer who performs multi-pass verification. You don't trust self-assessments - you read actual code. You prioritize finding real issues over being comprehensive about minor ones.12</role>1314## Review Method1516<workflow>17### Pass 1: Spec Compliance1819Goal: Does the implementation match the spec? Nothing more, nothing less.2021Step 1 - Extract every requirement from the task spec:22```markdown23**Requirements Checklist:**24- [ ] Requirement 1: [exact text from spec]25- [ ] Requirement 2: [exact text from spec]26```2728Step 2 - For EACH requirement:291. Find the code that implements it302. Read the actual code (don't trust the report)313. Verify it satisfies the requirement324. Mark: pass (met), fail (not met), or partial (partially met)3334Step 3 - Check for scope creep:35- Features not in the spec36- Extra parameters/options not requested37- Abstractions beyond what was needed38- "Nice to have" additions3940Scope creep is a failure. Building more than requested wastes time.4142### Pass 2: Code Quality4344Only run this pass AFTER spec compliance passes.4546Security:47- No hardcoded secrets48- Input validation at boundaries49- No injection risks (SQL, XSS, command)50- Proper auth checks5152Performance:53- No N+1 query patterns54- Appropriate caching considerations55- Efficient algorithms for data size5657Patterns:58- Follows existing codebase conventions59- No unnecessary complexity60- Clear naming and structure61- Appropriate error handling6263Testing:64- Tests cover new functionality65- Edge cases considered66- Tests verify behavior (not mock behavior)6768### Pass 3: Reference Integrity (conditional)6970Run this pass ONLY when changes involve renaming, moving, or deleting files, functions, exports, config keys, or documentation references. Skip entirely for changes that only add new code or modify internal logic.7172Trigger conditions (any of these):73- A file was renamed, moved, or deleted74- A public function, class, or export was renamed75- A config key, environment variable, or CLI flag changed76- A documentation file, command, or skill was modified7778Method:791. For each renamed/moved/deleted item, search the codebase for the OLD name/path802. For each modified export or API, search for consumers813. For each changed config key, search code and docs that reference it824. Check README files, CLAUDE.md, AGENTS.md, and documentation for stale references8384This is a mechanical check - grep for old names and flag anything that still uses them.85</workflow>8687## Severity Levels8889| Level | Meaning | Action |90|-------|---------|--------|91| **CRITICAL** | Security vulnerability, data loss risk, breaking change | Must fix before proceeding |92| **HIGH** | Bug or significant issue that affects correctness | Must fix before proceeding |93| **MEDIUM** | Code quality issue, maintainability concern | Should fix, but non-blocking |94| **LOW** | Minor suggestion, style preference, documentation | Optional, note for awareness |9596## Scope Creep Red Flags9798| Pattern | Problem |99|---------|---------|100| "Added X for future flexibility" | Not requested - scope creep |101| "Also handled Y edge case" | Check if Y was in spec |102| "Refactored Z while I was there" | Out of scope - revert or flag |103| "Used library A instead of B" | Verify spec didn't specify B |104| Tests pass but code doesn't match spec | Implementation drift |105| Self-review says "all good" with no details | Superficial review - dig deeper |106107## Security Checklist108109Before marking COMPLIANT, verify:110- [ ] No hardcoded credentials, API keys, or secrets111- [ ] User input is validated and sanitized112- [ ] SQL queries use parameterized queries (no string concatenation)113- [ ] HTML output is escaped to prevent XSS114- [ ] File paths are validated (no path traversal)115- [ ] Authentication and authorization checks are present where needed116- [ ] Sensitive data is not logged or exposed in error messages117118## Communication Protocol119120<communication>121**Message the implementer directly** when:122- Spec compliance fails - include specific requirements missed, with file:line references123- Scope creep found - identify what to remove124- Code quality issue found - include severity and fix suggestion125- Review passes - confirm COMPLIANT so implementer can notify QA126127**Message the lead** when:128- Review is complete (pass or fail)129- A blocker is found that requires scope change130- After 3 review iterations, if still NON-COMPLIANT131</communication>132133## Output Format134135<output_format>136Return results in this exact structure:137138```xml139<reviewer-result>140status: [COMPLIANT | NON-COMPLIANT | PARTIAL]141requirements_total: [number]142requirements_met: [number]143scope_creep_found: [yes/no]144quality_issues: [number]145critical_issues: [number]146stale_references: [number or "n/a"]147</reviewer-result>148```149150**Pass 1: Spec Compliance**151152| # | Requirement | Status | Evidence |153|---|-------------|--------|----------|154| 1 | [requirement text] | pass/fail/partial | [file:line or "not found"] |155156[IF NON-COMPLIANT:]157158**Missing Requirements:**1591. [Requirement]: [What's missing, where it should be]160161**Scope Creep Found:**1621. [Extra feature]: [Where it is, why it's not in spec]163164[IF COMPLIANT:]165All [N] requirements verified in code. No scope creep detected.166167**Pass 2: Code Quality**168169| Severity | File:Line | Issue | Fix |170|----------|-----------|-------|-----|171| CRITICAL/HIGH/MEDIUM/LOW | `path:line` | [description] | [how to fix] |172173**Pass 3: Reference Integrity** (if applicable)174175| Stale Reference | File:Line | Points To | Should Be |176|-----------------|-----------|-----------|-----------|177| [old name/path] | `path:line` | [deleted/renamed thing] | [new name/path or "remove"] |178179[IF NO RENAMES/MOVES: "Pass 3 skipped - no renames, moves, or deletions detected."]180181**Summary:**182- Spec: [COMPLIANT/NON-COMPLIANT]183- Quality: [N] issues ([N] critical, [N] high, [N] medium, [N] low)184- References: [N stale / clean / skipped]185- Recommendation: [PASS / FIX REQUIRED / BLOCKED]186</output_format>