
Reviewing AI-Generated Code
Agent failures can look like working code, so instincts calibrated on human mistakes can miss them. Review depth by blast radius and verifiability, plus four agent-specific checks.
TL;DR: AI-generated code fails differently from human code — its failures can look like working code, so a reviewer's instincts calibrated on human mistakes can miss them. The fix is a changed posture: assume plausibility proves nothing, set review depth by blast radius and verifiability, run the checks that catch agent-specific failures, and defend structurally against approval fatigue. Merging code you cannot explain is not review.
AI code fails differently
Human bugs have a texture reviewers learn early. They cluster around carelessness and misunderstanding — the off-by-one, the forgotten null, the requirement misread — and they often look wrong on the page. Using polish as a fast first signal rests on a working assumption: sloppy code and buggy code go together.
Agent output breaks that assumption. Generated code is often well-formatted, idiomatically named, and confidently structured, whether it is correct or not. Some of its failures come from plausibility rather than carelessness, and they hide in specific, recurring places.
The recognizable patterns: interfaces that almost exist — a method name one word off from the real one, an option the library never had, an import from a package that was never published. Edge cases handled confidently and wrongly — boundary values, empty collections, concurrent access — inside a happy path that is entirely correct. Duplicated logic that quietly reimplements a utility the codebase already has, when the agent never saw the original. And abstraction nobody asked for: a configuration layer, a generic wrapper, an extension point invented for a future that is not in the task.
None of these announce themselves the way a human's rushed commit does. The reviewer's prior has to change accordingly: style-level polish is no longer a reliable signal of substance-level correctness. That single recalibration — plausibility proves nothing — is most of the posture.
It is worth being precise about what this does not mean. It does not mean agent code is worse than human code. It means the reviewer's error model must match the author. Reviewing a junior engineer, you watch for gaps in understanding; reviewing a senior, you watch for shortcuts under deadline; reviewing an agent, you watch for confident plausibility in exactly the places listed above. A reviewer running the wrong error model does a diligent review of the failures that are not there.
Calibrating review depth to risk
Not all agent output deserves the same scrutiny, and pretending it does risks turning the scrutiny into theater. A rename sweep and an authentication change are different review problems; the calibration runs on two questions.
First, blast radius: if this change is wrong, how far does the damage travel? A leaf component fails locally and visibly. A shared utility, a data migration, an authorization path fails broadly and sometimes silently.
Second, verifiability: how cheaply can correctness be checked from outside? A change with tight test coverage and observable behavior verifies itself cheaply. A change whose correctness depends on reasoning — concurrency, caching, security boundaries — is expensive to verify no matter how readable the diff is.
| Verifiability | Small blast radius | Large blast radius |
|---|---|---|
| Cheap to verify | Skim the diff, trust the checks | Read every line |
| Expensive to verify | Read every line | Re-derive before reading |
Skim means confirming the change matches its intent and the checks are genuinely relevant, not ceremonial. Read means working through every line as if a capable stranger wrote it — because one did. Re-derive is the discipline reserved for the expensive-and-broad cell: work out independently what the code must do — the invariants, the failure handling, the edge behavior — before reading the agent's version, then compare. Reading first anchors you to the agent's framing, and plausible code is precisely the kind that makes an anchored reviewer nod along.
The calibration is also allowed to move mid-review. Certain findings escalate depth on the spot: a new dependency you did not expect, a touched file outside the task's stated scope, error handling that swallows rather than surfaces, any change to authentication, authorization, or money paths. Hitting one of these in a skim converts the skim to a read; hitting one in a read is a reasonable trigger to stop and re-derive the affected part. Depth set at the start is a plan, not a contract.
The dimensions that catch agent failures
Four checks, each aimed at a failure general review tends to miss.
Does it use what already exists? Agents can reinvent what they were not shown — a date formatter, a retry wrapper, a validation helper the codebase already owns. Duplication is a correctness risk wearing a style costume: two implementations of one rule can drift apart. For any nontrivial logic in the diff, the question is whether it already exists in the repository, and the reviewer may be better positioned to answer than the agent was.
Do the edge cases hold? Take the inputs the diff must survive — empty, boundary, malformed, concurrent — and trace them through the new code deliberately. This is where confident-but-wrong code can hide, and where a skim glides past. Checking the happy path alone is not what review is for.
Is the diff minimal for the intent? Every line beyond the stated task is a review flag, not a bonus. Drive-by refactors, "improved" adjacent functions, renamed variables in untouched logic — each expands the surface you are vouching for and buries the change that matters. When agent output shows scope creep, the correct response is to reject or split it, not to absorb it into a bigger approval.
Does the explanation match the code? Agents narrate their work fluently, and the narration is generated by the same process that generated the code — it is a claim, not a report. Verify the diff does what the summary says. A summary that reads "falls back to the cached value when the request fails" over code that catches the error and returns undefined is the kind of divergence to look for:
// Narration: "falls back to the cached value when the request fails"
try {
return await fetchSettings(userId);
} catch {
return undefined; // the cache is never consulted
}Reviewers who read only summaries are reviewing the agent's confidence, not its work.
Review at volume without rubber-stamping
Bad generation is not the only failure mode of the agent era; approval fatigue is another. Delegation multiplies the diffs arriving for review, each one plausible, each one described convincingly, many of them fine. Somewhere down the queue, "looks right, checks are green" quietly replaces reading, and the defense the whole workflow depends on is gone — while its ceremony remains.
The sustainable defenses are structural, not motivational.
Delegate smaller. Review capacity, not generation capacity, is the binding constraint — so task size should be set by what you can genuinely review, not by what the agent can produce in one run. A day's delegation that produces more diff than you can read is over-delegation by definition.
Treat unreviewable diffs as malformed. A pull request too large to actually review does not get a deeper sigh and a skim; it gets split. Declining to review an oversized diff is not process friction — accepting it unread is the process failure.
Budget review like the scarce resource it is. A rough per-diff attention budget — set by the depth the risk table assigns, not by how busy the day is — keeps the tenth review of the day from silently getting a fraction of the first one's care. When the budget consistently does not fit the incoming volume, the correction is upstream: smaller tasks, fewer parallel delegations, tighter specs — not thinner reviews.
Keep green checks in their place. Passing tests verify what someone thought to encode, at whatever depth they encoded it. For agent output, tests are one input to review, not a substitute for it — particularly when the agent wrote the tests too, a case with its own failure modes and its own treatment in another article on this topic.
The line that survives all of it comes from this topic's first principle: the engineer who merges owns the code. If you cannot explain a change to another engineer — what it does, why it is safe, what it would break — you have not reviewed it, whatever the checklist says.