code-review
Generated at build time from
skills/code-review/SKILL.md. Do not edit this page directly.
A review is not a checklist. It is a comparison between the behavior the change is supposed to preserve and the behavior the code actually creates.
Δ → Graph → Review<M, I, E>│ │ │ │ ││ │ │ │ └─ evidence in code / runtime path (§7)│ │ │ └──── impact if the mismatch is real (§6)│ │ └─────── meaningful mismatch / risk (§5)│ ││ └─ nodes = changed responsibilities/state,│ edges = calls, data flow, state transitions,│ dependencies, and trust boundaries│└─ the change: diff, PR, commit, patch, or implemented feature§1 Intent what the change is supposed to accomplish§2 Delta what actually changed and what it can affect§3 Actual reconstruct changed behavior/state/dependency graph§4 Compare expected contract vs actual implementation§5 Risk correctness and maintainability risks that matter§6 Impact concrete failure or long-term consequence§7 Evidence prove every finding from code or targeted verification§8 Tests assess whether changed behavior is actually protected§9 Output findings first; no nits by defaultRead the intent. Read the diff. Reconstruct the changed graph. Report only issues that can be tied to a concrete behavior, invariant, boundary, dependency, compatibility, security, or maintainability consequence.
If you cannot explain what can go wrong, do not report it as a finding.
1. Establish intent before judging code
Section titled “1. Establish intent before judging code”Understand what the change is trying to do.
Use the smallest relevant context available:
task / issue / user request.agents/product.md.agents/engineering.mdrelevant ADRsexisting testschange descriptionDo not assume the diff itself fully describes intent.
Extract:
- Expected behavior — what should become true.
- Preserved behavior — what must not regress.
- System constraints — boundaries, ownership, invariants, compatibility, or operational properties the change must respect.
- Review scope — changed files plus the surrounding code required to understand their impact.
If no explicit design contract exists, infer intent from the task, tests, public contracts, and surrounding implementation. Mark uncertain interpretations as uncertain rather than inventing requirements.
Do not reopen product decisions during code review unless the implementation cannot satisfy the stated requirement.
2. Review the delta, not the repository by ritual
Section titled “2. Review the delta, not the repository by ritual”Default to diff-based review when a change set exists.
Start with:
changed filesadded / removed behaviorchanged public contractschanged state/datachanged dependencieschanged trust or authorization boundarieschanged failure handlingchanged testsThen follow only the edges needed to understand those changes.
changed node ↓ callers / calleesstate owner ↓ writers / readerscontract ↓ producers / consumersInspect surrounding code when the local diff is insufficient.
Do not turn a PR review into a baseline audit of unrelated legacy code.
If you discover a pre-existing issue that is not caused or materially worsened by the change, do not report it as a blocking finding. Mention it separately only when it is necessary to understand the changed behavior.
For a requested baseline audit with no diff, establish explicit subsystem scope first and review that graph instead.
3. Reconstruct the actual graph
Section titled “3. Reconstruct the actual graph”Read the code as behavior, not as isolated lines.
Reconstruct only what changed:
Input / trigger ↓validation / authorization ↓responsibility owner ↓state read ↓decision / transition ↓state write / external effect ↓observable resultTrack when relevant:
data flowstate transitionssource of truthtransaction boundariesconcurrent writersdependency directionresource lifecycletrust boundarieserror propagationretry / duplicate behaviorcompatibility pathThe code is the source of truth for the actual graph.
Comments, task descriptions, tests, and design docs describe intent; they do not override what the implementation actually does.
For UI changes, use the same idea at the interface boundary:
user move ↓state transition ↓rendered state ↓next available moveDo not duplicate a full design-graph review unless the task specifically asks for interface design review.
4. Compare actual implementation against the contract
Section titled “4. Compare actual implementation against the contract”Compare:
expected behavior vsactual behavior
expected ownership vsactual ownership
expected invariant vsactual transition
expected boundary vsactual dependency
expected failure semantics vsactual failure semanticsTypical mismatch shapes:
required path is missingunexpected path is reachablestate can enter an invalid combinationcheck and write are separated across a race windowauthorization exists on one path but not anothererror is swallowed or translated incorrectlyretry can duplicate a non-idempotent effecttransaction boundary does not cover the invariantnew dependency reverses an intended boundarycached/derived state can become authoritative accidentallymigration breaks old readers or writerscleanup no longer follows resource lifetimeA different implementation is not a problem merely because it differs from the design sketch. Report it only when it breaks a required property or creates a concrete code-health regression.
5. Find risks that matter
Section titled “5. Find risks that matter”Review in this order:
Correctness
Section titled “Correctness”Can the changed code produce the wrong observable result?
Look especially at:
wrong conditionmissing state transitionstale valueoff-by-one / boundary caseincorrect fallbacklost or duplicated operationpartial updatewrong error mappinginvalid orderingState and concurrency
Section titled “State and concurrency”Only when state or multiple execution paths are involved:
race conditionlost updatecheck-then-act gapnon-atomic invariantduplicate deliverynon-idempotent retrydeadlock / lock orderingstale derived stateBoundaries and contracts
Section titled “Boundaries and contracts”When the change crosses a meaningful boundary:
input validationauthorizationAPI/event/schema compatibilitydependency directiontransaction ownershipsource-of-truth ownershipexternal integration semanticsSecurity
Section titled “Security”Security review is risk-triggered, not a generic checklist.
Trace changed trust boundaries when the diff touches:
authenticationauthorizationuser-controlled inputfile/path accesssecretstenant/user isolationnetwork/external integrationssensitive datacryptographyLook for concrete control bypass or data-flow problems.
For deep security analysis, hand off to a dedicated security-review capability when available. Code Review should identify the changed security risk; it should not recreate an entire threat-model framework.
Performance and reliability
Section titled “Performance and reliability”Review only when the changed path can materially affect them.
Examples:
new unbounded loop/queryN+1 or repeated remote callblocking work added to hot pathunbounded memory/resource growthretry stormmissing timeout at a new remote boundaryloss of durability or recovery behaviorDo not speculate about scale that the system does not have.
Maintainability
Section titled “Maintainability”Only report maintainability findings that have a concrete cost.
Examples:
same responsibility now has two ownersbusiness rule duplicated across pathsnew abstraction hides rather than simplifies behaviordependency direction creates coupling that will make changes unsafedead branch or legacy path remains active after replacementcode complexity prevents a reviewer from establishing correctnessDo not report taste.
DRY, SOLID, KISS, YAGNI, design patterns, or clean-code rules are not findings by themselves. Use them only when they explain a concrete problem in this code.
6. Assign severity from impact, not preference
Section titled “6. Assign severity from impact, not preference”Use three severities:
Critical
Section titled “Critical”The change can cause a severe production or security outcome such as:
data loss/corruptionauthorization bypasssecret or sensitive-data exposuremajor outageirreversible destructive behaviorsystem-wide invariant violationUse Critical sparingly.
A concrete issue that can cause:
wrong user-visible behaviorbroken invariantrace / consistency bugimportant regressioncontract incompatibilityresource leak with material impactmeaningful security weaknesshigh-probability future defect caused by the new structureThis normally blocks acceptance.
A real but limited issue whose impact is local and non-catastrophic:
small correctness edge caselocalized maintainability regressionmissing narrow defensive handlingtest gap for changed behavior with low blast radiusDo not emit Nit findings by default.
Formatting, import order, naming preferences, mechanical style, and issues fully handled by formatter/linter/typechecker should not consume review output unless they cause a real semantic problem.
7. Require evidence for every finding
Section titled “7. Require evidence for every finding”A finding must contain four things:
Location ↓Actual behavior ↓Failure scenario / consequence ↓Why the proposed direction fixes the causeMinimum standard:
[Severity] file:line — concise title
Actual:<what this code does>
Impact:<concrete scenario that fails>
Fix:<smallest direction that removes the cause>When useful, add a compact path:
Request → Handler → checkConflict → Service → insertEvidence can come from:
code pathstate transitioncontract mismatchexisting test behaviortargeted testtype/build resultreproductionDo not claim runtime failure merely because code “looks suspicious.”
When a suspected issue is cheap to verify, run the smallest targeted check that can confirm or falsify it.
If verification falsifies the suspicion, remove the finding.
Do not turn review into a full QA pass. Verification exists to support or falsify findings.
8. Review tests as evidence, not coverage theater
Section titled “8. Review tests as evidence, not coverage theater”Ask:
What changed?What can now fail?Does a test protect that behavior or invariant?Good tests should prove the changed contract at the lowest useful level.
Look for:
missing regression for the bug being fixedtest that cannot fail when implementation is wrongmocking that bypasses the changed behaviorassertions on implementation detail instead of contractmissing concurrency/integration coverage where the bug exists only thereupdated snapshots that merely bless unintended behaviorDo not demand tests for trivial mechanical changes.
Do not maximize test count or coverage percentage.
A test gap is a finding only when it leaves meaningful changed behavior unprotected or makes the implementation impossible to verify safely.
9. Prefer simplification over speculative redesign
Section titled “9. Prefer simplification over speculative redesign”Ask whether the change solves the intended problem with less machinery.
Look for unnecessary:
abstractionlayerconfigurationgeneric frameworknew dependencyduplicate modelparallel implementation pathfuture-proofingBut do not request a rewrite merely because another design is cleaner in theory.
Prefer the existing codebase pattern when it satisfies the requirement.
A review should improve code health without requiring perfection.
If the change is correct, understandable, tested enough for its risk, and does not degrade system health, do not block it for optional polish.
10. Output findings, not a review essay
Section titled “10. Output findings, not a review essay”Lead with findings ordered by severity.
Example:
Critical- [file:line] ...
Major- [file:line] ...
Minor- [file:line] ...For each finding, include the smallest evidence needed to understand and act on it.
After findings, optionally include:
Verified- targeted checks actually run
Residual risk- only material areas that could not be verifiedIf no actionable finding exists, say so directly:
No actionable findings.Then mention only meaningful verification limitations, if any.
Do not manufacture feedback so the review looks thorough.
Do not write .agents/code-review.md. Review output belongs to the PR/task/review context, while permanent architectural decisions belong in .agents/engineering.md or ADRs.
Review-only vs remediation
Section titled “Review-only vs remediation”Default behavior for an explicit review request:
inspect→ report findings→ do not modify codeIf the parent task explicitly asks to review and fix, or the review is an internal stage of an implementation task:
inspect→ finding→ fix root cause→ targeted verification→ re-review affected graphDo not silently broaden the implementation beyond findings.
Proportionality
Section titled “Proportionality”Depth follows risk, not diff size.
tiny mechanical change→ confirm intent + inspect diff + automated checks if relevant
normal behavior change→ reconstruct changed graph + compare contract + inspect tests
state / boundary / concurrency / migration / auth change→ deeper affected-subgraph review + targeted verification
large cross-system change→ review by subgraph/domain; use graph-protocol if delegation helpsA five-line transaction change can deserve more scrutiny than a thousand-line mechanical rename.
Relationship to other skills
Section titled “Relationship to other skills”design-thinking
Section titled “design-thinking”design-thinking:intent → expected implementation graph → code
code-review:code/diff → actual graph → compare against intentDo not redo implementation design unless a finding demonstrates that the current design cannot satisfy the contract.
engineering-design
Section titled “engineering-design”Use .agents/engineering.md and ADRs as intended system constraints when they exist.
Code Review verifies whether implementation preserves those responsibilities, ownership rules, boundaries, contracts, and guarantees.
It does not create a new architecture unless remediation requires revisiting a broken design.
design-graph
Section titled “design-graph”Use when a UI change cannot be reviewed correctly without reconstructing the interaction/surface graph.
Do not invoke it for non-interface code.
graph-protocol
Section titled “graph-protocol”Use only when a large review is naturally decomposable into independent domains or subgraphs.
The main reviewer remains responsible for integrating cross-boundary findings and removing duplicates.
The Pipeline
Section titled “The Pipeline”CHANGE → "What is this supposed to accomplish?" → establish intent and relevant contracts
→ "What actually changed?" → scope the delta and affected edges
→ "What behavior/state/dependency graph does the code now create?" → reconstruct the actual graph
→ "Where does actual differ from required?" → identify concrete mismatches
→ "What can go wrong because of that mismatch?" → establish impact and severity
→ "Can I prove this from code or a targeted check?" → require evidence; falsify weak suspicions
→ "Are changed behaviors protected by meaningful tests?" → assess verification gaps
→ "Is any new complexity actually required?" → reject unnecessary machinery, not stylistic differences
→ FINDINGS → actionable, evidence-backed, severity-orderedIf you cannot trace a finding from changed code to a concrete consequence, it is not a finding.