Code Review Loop
Review a code change for correctness, safety, maintainability, and test coverage.
What this Loop Engineering template does
Produce a severity-ranked review of a code change with file and line references, changing no code unless asked.
Read the diff and its description. Stay read-only by default and rank issues by severity.
When to use it
When not to use it
Validation checks
Boundaries & stop rule
Copy the loop prompt
/goal Produce a severity-ranked review of a code change with file and line references, changing no code unless asked.Task type: Code ReviewTarget tool: Claude CodeWork toward this goal until all validation checks pass or the stop rule is reached.Design hypothesis:This code review loop can produce a safer result if the scope stays narrow, validation is explicit, and a checker can reject shortcut work.Smallest useful run:Run one bounded pass on the newest relevant signal before expanding scope or adding a schedule.Loop cycle:1. Discovery — Read the latest signal for this template before acting: CI output, issue detail, review comment, dataset report, or content brief.2. Handoff — Hand the work to one agent in an isolated branch, worktree, or clearly scoped session. Keep final approval with a human.3. Verification — Use an independent review pass to confirm the result, inspect the diff or artifact, and reject shortcut work.4. Persistence — Save a short run note with the signal reviewed, actions taken, validation result, and next recommended step.5. Scheduling — Run manually until the loop is reliable; only then consider a scheduled or event-triggered run.Context:Read the diff and its description. Stay read-only by default and rank issues by severity.Validation:Review report includes severity levelsEvery blocking issue has file and line referencesNo code is changed unless explicitly requestedValidation evidence:Record the original signal, checks run, final result, changed files or artifacts, and any checker rejection.Independent checker:Use an independent review pass to confirm the result, inspect the diff or artifact, and reject shortcut work.Boundaries:Read-only by defaultDo not auto-apply fixesDo not approve your own changesStop rule:Stop when the review covers correctness, safety, maintainability, and tests.Maximum iterations: 3Budget:Example only: stop before exceeding the agreed per-run token budget.Human approval:Required before merge, deploy, delete, purchase, or external communication.Fallback:If the change is too large to review safely, ask for it to be split and review the highest-risk part first.Loop Validation Log:- Hypothesis: This code review loop can produce a safer result if the scope stays narrow, validation is explicit, and a checker can reject shortcut work.- Smallest useful run: Run one bounded pass on the newest relevant signal before expanding scope or adding a schedule.- Expected evidence: Record the original signal, checks run, final result, changed files or artifacts, and any checker rejection.- Actual evidence: [fill in after the run]- Passed? [yes / no / partial]- Feedback: After the run, note what the loop learned, what failed, and what should change before the next pass.- Next step: [stop / adjust the loop / run the next pass]Do not delete tests, bypass checks, or modify unrelated files just to satisfy the validation condition. If blocked, stop and summarize the blocker, attempted fixes, and recommended next action.
Failure modes to watch
Review receipt
This is a bounded review exercise for the template, not a claim about a production deployment.
Scenario
A change adds a retry helper that catches every error and repeats a network mutation up to ten times.
Baseline evidence
The review uses the actual diff, caller list, existing retry policy, idempotency behavior, and tests; it stays read-only and distinguishes observed defects from questions.
Validation result
The report identifies an unbounded side-effect risk, missing terminal-error classification, and absent backoff test with severity, file location, consequence, and a concrete verification request.
Shortcut rejected
A generic suggestion to add more tests is rejected because it neither proves the unsafe path nor gives the author a reproducible condition to address.
Human gate
The code owner decides whether the operation is safely repeatable and must approve a revised retry contract; the reviewer does not edit or approve its own proposed fix.
Loop Engineering FAQ
No, not by default. It is read-only and reports issues. Apply fixes in a separate maker loop so review and implementation stay independent.