Iterative Code Review
Overview
Industry-standard code review powered by a reviewer subagent dispatched from the superpowers:requesting-code-review prompt template. Reviews against Google Engineering Practices, Clean Code (Robert C. Martin), SOLID principles, Martin Fowler's code smells, and testing standards from Google SWE Book, Kent Beck, and Microsoft. Iterates until clean.
Security Audit Gate
If the security audit already ran (look for AUDIT_COMPLETE in the invocation context), proceed normally.
Scope Detection
digraph scope {
"Start" [shape=doublecircle];
"Uncommitted changes?" [shape=diamond];
"Review diff" [shape=box];
"Recent branch commits?" [shape=diamond];
"Review branch" [shape=box];
"User specified?" [shape=diamond];
"Review specified" [shape=box];
"Ask user" [shape=box];
"Start" -> "Uncommitted changes?";
"Uncommitted changes?" -> "Review diff" [label="yes"];
"Uncommitted changes?" -> "Recent branch commits?" [label="no"];
"Recent branch commits?" -> "Review branch" [label="yes"];
"Recent branch commits?" -> "User specified?" [label="no"];
"User specified?" -> "Review specified" [label="yes"];
"User specified?" -> "Ask user" [label="no"];
}
git diff + git diff --staged for uncommitted changes
git log for branch commits vs base
- User-specified scope
- If ambiguous: ask the user — never guess
Review Process
digraph review {
"Determine scope" [shape=box];
"Dispatch reviewer subagent" [shape=box];
"Issues found?" [shape=diamond];
"Fix all findings" [shape=box];
"Re-dispatch on changes only" [shape=box];
"Clean pass - score" [shape=doublecircle];
"Determine scope" -> "Dispatch reviewer subagent";
"Dispatch reviewer subagent" -> "Issues found?";
"Issues found?" -> "Fix all findings" [label="yes"];
"Issues found?" -> "Clean pass - score" [label="no"];
"Fix all findings" -> "Re-dispatch on changes only";
"Re-dispatch on changes only" -> "Issues found?";
}
How to Dispatch
Superpowers has no named reviewer agent — superpowers:code-reviewer was removed in
superpowers v5.1.0 and replaced by a prompt template. Dispatching it fails with an
unknown agent type.
1. Load the template. Invoke superpowers:requesting-code-review, then Read
<that skill's announced base directory>/code-reviewer.md. Invoking the skill does not
load the template — its SKILL.md only links to it. Skipping the Read leaves you
improvising a reviewer prompt from memory.
Ignore that skill's "Note Minor issues for later" guidance — the no-deferral rule in
Iteration Rules below overrides it.
2. Resolve the checklist paths to literal absolute strings, against the base directory
announced when this skill (necturalabs:iterative-code-review) loaded — NOT the
superpowers skill's, which was announced more recently and does not contain them:
<necturalabs:iterative-code-review base>/references/review-checklist.md
<necturalabs:iterative-code-review base>/references/testing-rules.md
<necturalabs:iterative-code-review base>/references/comment-checklist.md
<necturalabs:iterative-code-review base>/references/naming-and-layout.md
A subagent receives literal text. It cannot resolve a placeholder, and it cannot resolve a
path relative to a skill it never loaded.
3. Dispatch a general-purpose subagent with the template placeholders filled. Every
row below goes into the prompt as literal text — the subagent resolves nothing:
| Template placeholder |
Fill with |
[DESCRIPTION] |
What was implemented |
[PLAN_OR_REQUIREMENTS] |
What it should do, plus "review against the checklists at" the four absolute paths from step 2 — this is what makes the reviewer apply OUR standards instead of the template's defaults — plus the verification demand below |
[BASE_SHA] |
Scope start commit, per Scope Detection above |
[HEAD_SHA] |
git rev-parse HEAD |
Committed scope fills all four rows and leaves the template's git-range block intact.
Uncommitted scope does not. The template renders git diff [BASE_SHA]..[HEAD_SHA]
unconditionally, and for uncommitted work both SHAs are HEAD — the reviewer diffs
HEAD..HEAD, sees nothing, and returns a clean pass. Replace that git-range block
outright: state that the changes are uncommitted, and give the reviewer bare git diff
and git diff --staged. Do not fill the SHA rows and then tell the reviewer to ignore
them — that leaves two contradicting instructions in one prompt.
Verification demand — append to [PLAN_OR_REQUIREMENTS]. Every failure mode here is
silent: an empty diff, an unread template, or a dead checklist path each yield a confident,
clean, well-formatted review. So require the reviewer to report, in its output, the diff
stat it actually saw and confirmation that it read all four checklist files. It cannot go
in the template's Output Format section, which is fixed.
A clean pass over an empty diff is a failed dispatch, not a clean review. Do not accept
it and do not re-send the same prompt — an identically-derived prompt reproduces the
identical empty diff forever. Re-derive the scope per Scope Detection above, fix what was
wrong (usually an uncommitted scope filled as a SHA range), and dispatch the corrected
prompt. That retry does not consume an iteration, but only a corrected prompt may be
retried, and only once: if the diff is still empty, stop and tell the user there is nothing
to review.
Review Checklist (Summary)
Full detailed checklist: references/review-checklist.md
| Category |
Source |
Key Checks |
| Design & Architecture |
Google, SOLID |
SRP, OCP, LSP, ISP, DIP, Law of Demeter |
| Complexity |
McCabe, SonarQube |
Cyclomatic <10, Cognitive <15, Nesting <3, Params <4 |
| Code Smells |
Fowler, Refactoring.Guru |
Bloaters, OO abusers, change preventers, dispensables, couplers |
| Naming |
Clean Code, Google, per-language guides |
Descriptive, unambiguous, consistent vocabulary; casing per the language — see references/naming-and-layout.md |
| Functions |
Clean Code |
Small, one thing, no side effects, no flag args |
| Error Handling |
Clean Code, OWASP |
No swallowed exceptions, specific catches, proper cleanup |
| Testing |
Google SWE, Kent Beck, Microsoft |
See references/testing-rules.md |
| Comments |
Ousterhout, Clean Code, per-language guides |
See references/comment-checklist.md |
| Performance |
Google, SonarQube |
Resource cleanup, N+1, proper data structures |
| Concurrency |
Java Concurrency Checklist |
Protected shared state, no deadlocks, proper sync |
| DRY/KISS/YAGNI |
Industry Standard |
No duplication, no over-engineering, no speculation |
| Style & Layout |
Google/Airbnb Guides, per-language guides |
Follow project conventions, no mixed style+logic PRs; indentation, line endings and encoding — see references/naming-and-layout.md |
| API Design |
Google API Guide |
Backward compat, proper HTTP, consistent errors |
Testing Rules (Summary)
Full detailed rules: references/testing-rules.md
Critical rules the agent MUST follow when writing or reviewing tests:
- Test YOUR code's logic, not external libraries/services — mock externals at boundaries
- Reuse existing codebase helpers — never fabricate parallel implementations
- Every test must be able to fail — no tautological assertions
- No logic in tests — use literal expected values, no loops/conditionals
- Test behavior through public APIs — never break encapsulation
- One behavior per test — if name has "and", split it
- Arrange-Act-Assert — clear separation, one Act per test
- Don't mock what you don't own — wrap externals, mock the wrapper
- Don't over-mock — if more mocks than test logic, refactor production code
- Every production bug gets a regression test — a new test, never an edit to an existing one
- Never assert on human-readable copy — assert ids, roles, codes, and state, not rendered sentences
- Every new test must be observed failing for its stated reason before it counts as passing
- Never encode a known bug as expected behavior — fix the defect instead
- Never weaken a test to get green — flag relaxed assertions, widened tolerances, new skip/xfail markers, and deletions that do not name one of the four legitimate cases
Reporting
Keep ALL output short and concise. Never overwhelm the user.
Per-Finding Format (one line each)
[SEVERITY] Category: description — file:line
Severities
- CRITICAL — Bugs, data loss, crashes. Must fix.
- HIGH — Design flaws, missing tests. Should fix.
- MEDIUM — Quality issues. Fix preferred.
- LOW — Style, optional improvements.
- INFO — Educational notes, no action needed.
Iteration Rules
- Each iteration reviews ONLY changes since last review
- New issues from fixes = new findings
- Recurring finding after fix = escalate severity one level
- Max 5 iterations — summarize remaining if not clean
- Track: "Review iteration 2/5"
- Never skip, delay, defer, or postpone ANY finding — every finding must be fully resolved within the review scope. No TODOs, no "address in a follow-up", no "out of scope" dismissals, no "note for later". The only exception is an explicit user instruction to skip a specific finding.
- Double-check every finding against codebase context and online references
Final Summary (after clean pass)
## Code Review: Score X/100
**Positives**
- [concise bullet]
- [concise bullet]
**Negatives**
- [concise bullet]
**Informational**
- [optional notes]
Score guide: 90-100 excellent, 70-89 good, 50-69 needs work, <50 significant issues.
Anti-Laziness Rules
- Never substitute a manual scan for this skill — reading the diff yourself and saying "looks clean" is not a code review. Invoke this skill.
- Never say "looks good" without checking every file
- Never skip a category from the checklist
- Never mark a finding as LOW to avoid fixing it — severity must reflect actual impact
- If unsure about a finding, ASK the user — don't guess or skip
- Verify findings in the actual code — don't report phantom issues
- Never rationalize deferral — "we can fix this later", "out of scope", "low priority for now" are all unacceptable. Fix it or get explicit user approval to skip
1---2name: iterative-code-review3description: MUST invoke after implementing features, fixing bugs, refactoring, or making any code changes — before committing, merging, or claiming work is done. Also use when the user asks for code review. Requires superpowers plugin. Iterates until a clean pass with zero findings.4---56# Iterative Code Review78## Overview910Industry-standard code review powered by a reviewer subagent dispatched from the `superpowers:requesting-code-review` prompt template. Reviews against Google Engineering Practices, Clean Code (Robert C. Martin), SOLID principles, Martin Fowler's code smells, and testing standards from Google SWE Book, Kent Beck, and Microsoft. Iterates until clean.1112<HARD-GATE>13This skill REQUIRES `superpowers` to be installed. If not available, tell the user:14"Install superpowers first: `/plugin marketplace add obra/superpowers` then `/plugin install superpowers@superpowers-dev`"15Do NOT proceed without it.16</HARD-GATE>1718## Security Audit Gate1920<HARD-GATE>21**BEFORE reviewing, check if changes are security-related** (auth, crypto, input validation, API endpoints, sessions, secrets, dependencies — see `iterative-security-audit` for the full list). If yes AND the security audit has not already run in this invocation chain, **STOP** — invoke the security audit first. It chains into code review with `AUDIT_COMPLETE` in context.2223If the security audit already ran (look for `AUDIT_COMPLETE` in the invocation context), proceed normally.24</HARD-GATE>2526## Scope Detection2728```dot29digraph scope {30 "Start" [shape=doublecircle];31 "Uncommitted changes?" [shape=diamond];32 "Review diff" [shape=box];33 "Recent branch commits?" [shape=diamond];34 "Review branch" [shape=box];35 "User specified?" [shape=diamond];36 "Review specified" [shape=box];37 "Ask user" [shape=box];3839 "Start" -> "Uncommitted changes?";40 "Uncommitted changes?" -> "Review diff" [label="yes"];41 "Uncommitted changes?" -> "Recent branch commits?" [label="no"];42 "Recent branch commits?" -> "Review branch" [label="yes"];43 "Recent branch commits?" -> "User specified?" [label="no"];44 "User specified?" -> "Review specified" [label="yes"];45 "User specified?" -> "Ask user" [label="no"];46}47```48491. `git diff` + `git diff --staged` for uncommitted changes502. `git log` for branch commits vs base513. User-specified scope524. If ambiguous: **ask the user** — never guess5354## Review Process5556```dot57digraph review {58 "Determine scope" [shape=box];59 "Dispatch reviewer subagent" [shape=box];60 "Issues found?" [shape=diamond];61 "Fix all findings" [shape=box];62 "Re-dispatch on changes only" [shape=box];63 "Clean pass - score" [shape=doublecircle];6465 "Determine scope" -> "Dispatch reviewer subagent";66 "Dispatch reviewer subagent" -> "Issues found?";67 "Issues found?" -> "Fix all findings" [label="yes"];68 "Issues found?" -> "Clean pass - score" [label="no"];69 "Fix all findings" -> "Re-dispatch on changes only";70 "Re-dispatch on changes only" -> "Issues found?";71}72```7374### How to Dispatch7576Superpowers has no named reviewer agent — `superpowers:code-reviewer` was removed in77superpowers v5.1.0 and replaced by a prompt template. Dispatching it fails with an78unknown agent type.7980**1. Load the template.** Invoke `superpowers:requesting-code-review`, then **Read**81`<that skill's announced base directory>/code-reviewer.md`. Invoking the skill does not82load the template — its `SKILL.md` only links to it. Skipping the Read leaves you83improvising a reviewer prompt from memory.8485Ignore that skill's "Note Minor issues for later" guidance — the no-deferral rule in86Iteration Rules below overrides it.8788**2. Resolve the checklist paths to literal absolute strings**, against the base directory89announced when **this** skill (`necturalabs:iterative-code-review`) loaded — NOT the90superpowers skill's, which was announced more recently and does not contain them:9192- `<necturalabs:iterative-code-review base>/references/review-checklist.md`93- `<necturalabs:iterative-code-review base>/references/testing-rules.md`94- `<necturalabs:iterative-code-review base>/references/comment-checklist.md`95- `<necturalabs:iterative-code-review base>/references/naming-and-layout.md`9697A subagent receives literal text. It cannot resolve a placeholder, and it cannot resolve a98path relative to a skill it never loaded.99100**3. Dispatch a `general-purpose` subagent** with the template placeholders filled. Every101row below goes into the prompt as literal text — the subagent resolves nothing:102103| Template placeholder | Fill with |104|---|---|105| `[DESCRIPTION]` | What was implemented |106| `[PLAN_OR_REQUIREMENTS]` | What it should do, **plus** "review against the checklists at" the four absolute paths from step 2 — this is what makes the reviewer apply OUR standards instead of the template's defaults — **plus** the verification demand below |107| `[BASE_SHA]` | Scope start commit, per Scope Detection above |108| `[HEAD_SHA]` | `git rev-parse HEAD` |109110**Committed scope** fills all four rows and leaves the template's git-range block intact.111112**Uncommitted scope** does not. The template renders `git diff [BASE_SHA]..[HEAD_SHA]`113unconditionally, and for uncommitted work both SHAs are `HEAD` — the reviewer diffs114`HEAD..HEAD`, sees nothing, and returns a clean pass. **Replace that git-range block115outright**: state that the changes are uncommitted, and give the reviewer bare `git diff`116and `git diff --staged`. Do not fill the SHA rows and then tell the reviewer to ignore117them — that leaves two contradicting instructions in one prompt.118119**Verification demand — append to `[PLAN_OR_REQUIREMENTS]`.** Every failure mode here is120silent: an empty diff, an unread template, or a dead checklist path each yield a confident,121clean, well-formatted review. So require the reviewer to report, in its output, the diff122stat it actually saw and confirmation that it read all four checklist files. It cannot go123in the template's Output Format section, which is fixed.124125**A clean pass over an empty diff is a failed dispatch, not a clean review.** Do not accept126it and do not re-send the same prompt — an identically-derived prompt reproduces the127identical empty diff forever. Re-derive the scope per Scope Detection above, fix what was128wrong (usually an uncommitted scope filled as a SHA range), and dispatch the corrected129prompt. That retry does not consume an iteration, but only a *corrected* prompt may be130retried, and only once: if the diff is still empty, stop and tell the user there is nothing131to review.132133## Review Checklist (Summary)134135Full detailed checklist: `references/review-checklist.md`136137| Category | Source | Key Checks |138|----------|--------|------------|139| Design & Architecture | Google, SOLID | SRP, OCP, LSP, ISP, DIP, Law of Demeter |140| Complexity | McCabe, SonarQube | Cyclomatic <10, Cognitive <15, Nesting <3, Params <4 |141| Code Smells | Fowler, Refactoring.Guru | Bloaters, OO abusers, change preventers, dispensables, couplers |142| Naming | Clean Code, Google, per-language guides | Descriptive, unambiguous, consistent vocabulary; casing per the language — see `references/naming-and-layout.md` |143| Functions | Clean Code | Small, one thing, no side effects, no flag args |144| Error Handling | Clean Code, OWASP | No swallowed exceptions, specific catches, proper cleanup |145| Testing | Google SWE, Kent Beck, Microsoft | See `references/testing-rules.md` |146| Comments | Ousterhout, Clean Code, per-language guides | See `references/comment-checklist.md` |147| Performance | Google, SonarQube | Resource cleanup, N+1, proper data structures |148| Concurrency | Java Concurrency Checklist | Protected shared state, no deadlocks, proper sync |149| DRY/KISS/YAGNI | Industry Standard | No duplication, no over-engineering, no speculation |150| Style & Layout | Google/Airbnb Guides, per-language guides | Follow project conventions, no mixed style+logic PRs; indentation, line endings and encoding — see `references/naming-and-layout.md` |151| API Design | Google API Guide | Backward compat, proper HTTP, consistent errors |152153## Testing Rules (Summary)154155Full detailed rules: `references/testing-rules.md`156157**Critical rules the agent MUST follow when writing or reviewing tests:**1581591. **Test YOUR code's logic, not external libraries/services** — mock externals at boundaries1602. **Reuse existing codebase helpers** — never fabricate parallel implementations1613. **Every test must be able to fail** — no tautological assertions1624. **No logic in tests** — use literal expected values, no loops/conditionals1635. **Test behavior through public APIs** — never break encapsulation1646. **One behavior per test** — if name has "and", split it1657. **Arrange-Act-Assert** — clear separation, one Act per test1668. **Don't mock what you don't own** — wrap externals, mock the wrapper1679. **Don't over-mock** — if more mocks than test logic, refactor production code16810. **Every production bug gets a regression test** — a new test, never an edit to an existing one16911. **Never assert on human-readable copy** — assert ids, roles, codes, and state, not rendered sentences17012. **Every new test must be observed failing** for its stated reason before it counts as passing17113. **Never encode a known bug as expected behavior** — fix the defect instead17214. **Never weaken a test to get green** — flag relaxed assertions, widened tolerances, new skip/xfail markers, and deletions that do not name one of the four legitimate cases173174## Reporting175176Keep ALL output short and concise. Never overwhelm the user.177178### Per-Finding Format (one line each)179```180[SEVERITY] Category: description — file:line181```182183### Severities184- **CRITICAL** — Bugs, data loss, crashes. Must fix.185- **HIGH** — Design flaws, missing tests. Should fix.186- **MEDIUM** — Quality issues. Fix preferred.187- **LOW** — Style, optional improvements.188- **INFO** — Educational notes, no action needed.189190## Iteration Rules191192- Each iteration reviews ONLY changes since last review193- New issues from fixes = new findings194- Recurring finding after fix = escalate severity one level195- **Max 5 iterations** — summarize remaining if not clean196- Track: "Review iteration 2/5"197- **Never skip, delay, defer, or postpone ANY finding** — every finding must be fully resolved within the review scope. No TODOs, no "address in a follow-up", no "out of scope" dismissals, no "note for later". The only exception is an explicit user instruction to skip a specific finding.198- **Double-check every finding** against codebase context and online references199200## Final Summary (after clean pass)201202```203## Code Review: Score X/100204205**Positives**206- [concise bullet]207- [concise bullet]208209**Negatives**210- [concise bullet]211212**Informational**213- [optional notes]214```215216Score guide: 90-100 excellent, 70-89 good, 50-69 needs work, <50 significant issues.217218## Anti-Laziness Rules219220- **Never substitute a manual scan for this skill** — reading the diff yourself and saying "looks clean" is not a code review. Invoke this skill.221- **Never say "looks good" without checking every file**222- **Never skip a category** from the checklist223- **Never mark a finding as LOW to avoid fixing it** — severity must reflect actual impact224- **If unsure about a finding, ASK the user** — don't guess or skip225- **Verify findings in the actual code** — don't report phantom issues226- **Never rationalize deferral** — "we can fix this later", "out of scope", "low priority for now" are all unacceptable. Fix it or get explicit user approval to skip