On this page#
What changes when an agent does this#
A devin review moves the bottleneck from producing comments to proving that a proposed change preserves the repository’s invariants. The agent can inspect more code and suggest patches quickly, but the engineer now has to validate scope, evidence, and rollback safety. Review throughput rises; responsibility does not move.
Code review is the systematic examination of source code by someone other than its author. With an agent, “someone” becomes a machine-driven process that can traverse files, compare patterns, run checks, and propose edits. That changes the shape of the work:
| Before the agent | With the agent | |---|---| | Finding suspicious code is slow | Rejecting irrelevant findings becomes slow | | Review comments are the output | Verified patches become the output | | Coverage depends on reviewer attention | Coverage depends on prompt scope and repository access | | The reviewer may miss distant effects | The agent may invent relationships that look plausible | | Approval follows human inspection | Approval must still follow human inspection |
The wrong goal is “have Devin review the pull request.” That delegates an activity without defining acceptance. The useful goal is narrower: identify invariant violations, produce evidence for each finding, repair only confirmed defects, and leave a reversible change set.
Treat the agent as an untrusted reviewer with unusual stamina. It can read broadly, but it cannot own the merge decision.
Photo by Christina Morillo on Pexels.
The prompt chain#
Do not ask for review, repair, tests, and approval in one prompt. Split the work into discovery, verification, repair, and final audit so that each stage has a bounded output. This prevents an early assumption from silently becoming a patch, a passing test, and then a false claim of correctness.
A large language model generates outputs from learned statistical patterns; it does not possess an independent guarantee that its explanation matches repository reality. Prompt chaining matters because every stage forces the next claim to cite fresh evidence instead of inheriting confidence.
Stage 1: establish scope and invariants#
Start by making the agent map the change before judging it. The answer you want is a review plan tied to explicit invariants, not a stream of style comments. If the agent cannot state what must remain true, it is not ready to assess whether the patch is safe.
Review this change without editing files.
First:
1. Summarize the intended behavior.
2. List the files and interfaces affected directly.
3. Identify likely transitive effects.
4. Extract repository invariants from tests, types, schemas,
validation, and nearby call sites.
5. Mark every assumption that lacks repository evidence.
Return a review plan only. Do not propose fixes yet.This prompt separates facts from assumptions. It also makes omissions visible before repair begins.
Stage 2: produce findings with evidence#
Require each finding to survive a small burden of proof. A useful finding identifies the violated invariant, the exact path through the code, and a realistic trigger. Anything without all three is a hypothesis, not a defect, and should not enter the repair queue.
Execute the review plan.
For each finding, provide:
- severity and affected invariant;
- exact file and symbol;
- triggering input or state;
- control-flow or data-flow explanation;
- existing test or repository evidence;
- confidence: confirmed or hypothesis.
Exclude formatting preferences and unrelated refactors.
Do not edit files.This is consistent with agent workflows described in Claude Code’s official documentation: tool-enabled coding agents can inspect and act across a codebase, so scope must be constrained explicitly. Tool access is capability, not correctness.
Stage 3: challenge the findings#
Now make the agent try to disprove itself. This step is essential because plausible findings often collapse when checked against validation, callers, generated code, feature flags, or an intentionally changed contract.
Challenge every proposed finding.
Try to falsify it using repository evidence:
- upstream validation;
- downstream handling;
- types and schemas;
- tests;
- configuration and feature flags;
- documented intentional behavior.
Return:
1. confirmed defects;
2. rejected findings with the disconfirming evidence;
3. unresolved items requiring human judgment.
Do not edit files.Skipping this stage is the most common workflow error. A long finding list feels productive, but unchallenged findings merely transfer verification work to the human.
Stage 4: repair only confirmed defects#
Repairs should be minimal, local, and independently reversible. Ban opportunistic cleanup because it expands the semantic surface the human must inspect and makes a clean rollback harder.
Repair only the confirmed defects.
Constraints:
- preserve public behavior except where the defect requires change;
- make the smallest coherent patch;
- add or update a test that fails before the fix;
- do not rename, reformat, upgrade, or refactor unrelated code;
- record each changed file and why it was necessary.
Stop if a repair requires a product or architecture decision.For a reusable version of this chain, the PairFoundry Review and Repair pack is the direct next step. Engineers who want the underlying prompting model first can use the free foundations track.
The gate#
The gate is a mandatory human inspection between agent output and merge: review the diff, replay the defect claim, verify the test’s failure-before/fix-after logic, and confirm that the patch preserves named invariants. A green check is supporting evidence. It is never permission to merge an unread change.
At the gate, the human must answer five questions:
- Is every changed line necessary for a confirmed finding?
- Can I explain the defect without repeating the agent’s wording?
- Does the test exercise the actual failure mechanism?
- Did the patch alter an API, schema, authorization boundary, or persisted data?
- Can this change be reverted without retaining dependent edits?
Reject the patch if any answer is unclear. “The suite passes” does not resolve a missing assertion, an incomplete fixture, or behavior outside test coverage. Code review remains a human accountability boundary even when an agent performs the first inspection.
For team use, put the agent’s findings and patch in the pull request, but keep approval with a named engineer. The author should label unresolved assumptions rather than letting them disappear inside an apparently finished diff. Other workflow patterns belong in the PairFoundry workflow library, while the pack overview helps separate review work from other agent tasks.
Photo by Jakub Zerdzicki on Pexels.
What it gets wrong#
The agent’s most dangerous failures are not obvious syntax errors. They are coherent explanations attached to incomplete repository evidence. Detect them by checking whether each conclusion is grounded in reachable code, current contracts, and a test that distinguishes the alleged defect from intentional behavior.
Watch for these failure modes:
- Phantom bug: It ignores validation or a caller guarantee. Trace inputs from the real entry point.
- Local fix, global break: It repairs one function while violating another consumer’s contract. Search call sites and serialized forms.
- Test-shaped correctness: It changes implementation and test together until both agree. Confirm the test represents the invariant, not the patch.
- Scope drift: It mixes cleanup with repair. Reject unrelated renames, formatting, and abstractions.
- False completeness: It reports no issues after inspecting only the visible diff. Check transitive interfaces and configuration.
- Authority laundering: A confident explanation substitutes for evidence. Demand paths, symbols, and triggering states.
The mechanism behind these errors matters: an LLM can produce a fluent causal story even when repository context is missing. Confidence is therefore not a useful acceptance signal. Evidence density is.
Some work should not enter this workflow at all. Do not let the agent independently finalize security-sensitive authorization changes, irreversible migrations, ambiguous product behavior, or patches whose correctness depends on inaccessible production state. Those require an explicit human decision before code generation.
Rollback#
Rollback should restore the pre-review state without reconstructing intent from a tangled diff. Keep the agent’s repair isolated, record its base state, avoid unrelated edits, and verify the restored tree with the same focused checks used at the gate. Reversibility must be designed before the patch, not improvised after failure.
Use this sequence:
- Separate the repair from pre-existing work.
- Record the findings mapped to individual changes.
- Keep each patch small enough to revert coherently.
- If the repair fails, revert the entire repair unit—not selected suspicious lines.
- Re-run the focused regression test and relevant broader checks.
- Reopen the original finding as unresolved; do not silently mark it fixed.
If the change includes data, schema, or deployment effects, source rollback may be insufficient. Stop before merge unless the operational rollback path is explicit and compatible with both old and new code. An agent-generated inverse patch is not a rollback plan.
Photo by Daniil Komov on Pexels.
Related reading#
- Claude Code Rust — the workflow, the gate, and the rollback
- GitHub Copilot API keys: making the output reviewable, not just correct
FAQ#
When should I not use this workflow?#
Do not use it as an autonomous approval path for irreversible migrations, authorization boundaries, ambiguous requirements, or failures that depend on production-only state. You can still use the agent to gather evidence, but generation must stop before repair when the missing decision belongs to a product owner, security reviewer, or operator.
How is this different from following the official agent documentation?#
Official documentation explains capabilities and tool operation; this workflow defines a repository-specific control system around them. The missing pieces are staged falsification, an explicit human gate, and rollback discipline. Claude Code’s documentation is useful for operating an agent, but operation alone does not define your acceptance criteria.
What breaks when a team adopts devin review?#
Teams get into trouble when agent comments look authoritative, duplicate human review, or hide unresolved assumptions. Assign one engineer to own the gate, require evidence-formatted findings, and keep agent repairs separate from author changes. Otherwise, speed at the first pass becomes confusion at approval.
How do I roll back after an agent repair has already merged?#
Revert the complete repair unit, run the focused regression and relevant broader checks, then reopen the original defect. Do not preserve fragments merely because they look harmless. If database or deployment state changed, follow the predeclared operational rollback; reverting source code alone may leave the system incompatible.
Can a passing test suite replace the human gate?#
No. Tests show that selected assertions passed under selected conditions. They do not prove that the agent identified the right invariant, avoided contract drift, or covered inaccessible states. The human gate exists to inspect those exact gaps before an agent-generated patch becomes repository history.