AI engineering
Reviewing AI-Authored Code
The hardest thing about reviewing generated code is that it looks reviewed already. Fluency is not a proxy for correctness, but the brain treats it as one.
AI-authored code shifts review effort away from style and syntax and towards intent, edge cases, silent assumptions and dependency provenance, because generated code is fluent in ways that suppress the usual signals of doubt.
Generated code fails in a different distribution
Human code fails in patterns reviewers have internalised over years. Someone is tired and mishandles a nil case. Someone does not know the codebase and reimplements an existing helper. Someone is rushing and skips the error path. Reviewers have priors about where to look, and those priors are tuned to human error.
Generated code has a different failure distribution and the priors do not transfer. It is syntactically clean, idiomatic, consistently formatted and well named, so all the cheap surface signals that usually prompt a second look are absent. The errors that remain are semantic: a plausible but wrong assumption about what a function returns, an edge case handled in a way that reads sensible and is not, an API used with the signature it had two versions ago.
It is also uniformly confident. A human writing something they are unsure about tends to leave a trace — a hedged comment, an awkward construction, a question in the pull request description. Generated code carries no such signal, because the model does not know which parts of its own output are shaky. The reviewer loses the map of where the author was uncertain, which in human review is one of the most efficient guides to where to spend attention.
And it is fluent, which matters more than it should. Reading something well written activates a sense of comprehension that is not the same as having verified it. This is a documented feature of how people read, not a failing specific to engineers, and the only defence is a process that does not rely on the reviewer noticing that they are skimming.
- Reviewer priors are tuned to human error patterns and do not transfer
- Surface signals — formatting, naming, structure — are clean by default
- No trace of author uncertainty, so the usual map of where to look is missing
- Fluency produces a feeling of comprehension that is not verification
What to check first
Start with intent, before reading a line of the implementation. What was this change supposed to do? If the pull request description does not say, that is the first thing to fix, because reviewing generated code without a stated intent means checking that the code does what the code does — which it always will.
Then check the edges. Empty collections, single-element collections, zero and negative numbers, null and absent values, timezone and locale boundaries, concurrent access, the second call rather than the first. Generated implementations tend to be correct on the central case, which is what makes them convincing, and the interesting divergence is at the boundaries.
Then check the assumptions the code makes about the rest of the system. Does it assume this list is already sorted? That this map is populated? That this call is idempotent? That this identifier is unique across tenants? These are the failures that pass review most easily, because verifying them requires knowledge held outside the diff, which is exactly the knowledge a model generating from local context did not have.
Then check the dependencies. Every import should be a package that exists, is already in the project, is the version the code assumes and is one you are prepared to depend on. Generated code can reference plausible package names and plausible-but-outdated API signatures with complete confidence. This is a mechanical check and it belongs in tooling — a build that fails on an unknown or newly added dependency catches it more reliably than a human reading an import block.
Then check for duplication. A model working from a local context window will happily reimplement a utility that already exists three directories away. Nothing about the resulting code looks wrong; there is simply now a second implementation of the same thing, which will drift.
- Intent first — without a stated goal you are only checking self-consistency
- Boundaries: empty, single, zero, negative, null, concurrent, second call
- Cross-system assumptions are the failures that pass review most easily
- Automate dependency and version checks; humans read import blocks badly
- Look for reimplementation of helpers that already exist elsewhere
What matters less now
Style, formatting and naming consume a large share of review comments in most teams, and generated code is generally competent at all three. Continuing to spend review attention there is a poor allocation, and it is worse than neutral: a review full of style comments feels thorough while leaving the semantic risk untouched.
Push all of it into tooling. Formatters, linters and type checkers should run before a human sees the change, and any recurring style comment should be converted into a rule or dropped. This is good practice regardless of who wrote the code; it is close to mandatory when the author is a model, because the human attention saved is exactly the attention the semantic checks need.
Boilerplate correctness also matters less. Generated CRUD handlers, mappers and test scaffolding are usually structurally right, and reading every line of a large mechanical diff is a poor use of a reviewer. Skim the mechanical parts and concentrate on the parts where a decision was made — the conditionals, the error handling, the data transformations, the places where the code chose one behaviour over another.
The corollary is that the reviewer needs to be able to find those parts, which is a question about the size and shape of the change rather than about reviewer diligence. A five-hundred-line diff where forty lines matter is a review that will miss things, no matter who is doing it.
- Style, formatting and naming are largely handled — automate the rest
- A review full of style comments feels thorough and catches nothing important
- Skim mechanical boilerplate; concentrate on where a decision was made
- Finding the decisions depends on change size, not reviewer effort
Tests deserve their own scrutiny
The most dangerous single artefact in an AI-assisted change is a generated test suite that was written from the generated implementation. It will pass. It will have good coverage numbers. And it encodes the implementation's assumptions as expected behaviour, so a wrong implementation arrives with its own certificate of correctness attached.
The defence is to derive tests from the requirement rather than the code. Where the tests were generated, review them against the specification and not against the implementation: does this assert what the feature is supposed to do, or does it assert what this code happens to do? Those two look identical in a diff and are completely different in value.
Watch for tests that assert the shape of a result without asserting its correctness — checking that a list has three elements without checking which three, checking that a function returns without checking what. These pass reliably, raise coverage, and would not catch the bug they exist to prevent.
Coverage percentage is a particularly weak signal in this context. Generated tests can exercise a large fraction of the lines while asserting very little about behaviour. Treat a coverage number as a floor rather than as evidence, and spend the review effort on whether the assertions encode the requirement.
It is also worth asking, for any non-trivial change, what would have to break for a bug to escape both the implementation and its tests. If the same generation process produced both, the answer is often "one assumption", which is a much thinner margin than an implementation and tests written by two different humans.
- Tests generated from a generated implementation certify its assumptions
- Review tests against the requirement, never against the code they cover
- Watch for shape assertions that never check correctness
- Coverage rises easily without behavioural assertions — treat it as a floor
- One process producing both code and tests means one assumption can defeat both
Making it work as a team practice
Say when a change is AI-assisted. Not as a confession or a flag for extra suspicion, but because it tells the reviewer which failure distribution to expect, and because a team that cannot see how its code is being produced cannot reason about its own quality trend. Marvex tracks Claude Code authorship and GitHub Copilot usage alongside delivery data for the organisational version of this question; the pull request level benefits from a simple team norm.
Keep the author accountable for the change. Submitting generated code means vouching for it: having read it, understood it, and being able to explain any part of it under question. If the author cannot explain a section, the reviewer should not be the first person to try. This one norm resolves most of the cultural difficulty around AI-assisted contribution, because it puts responsibility exactly where it was before.
Keep changes small, more strictly than before. Assistance makes it easy to produce a great deal of code quickly, and the constraint that used to limit change size — how long it takes to write — has weakened while the constraint that matters, how much a human can meaningfully review, has not moved at all. If pull request size is trending up as assistance spreads, that is worth acting on directly.
Watch rework as the health signal. If the loop between review comments and revisions is growing, review is catching things, which is good, but it is catching them late and expensively. That pattern usually means the checks should move earlier: into tests derived from the requirement, into stricter types, into the prompt and the context the author gives the assistant before any code exists.
- Declare AI assistance so the reviewer knows which failures to expect
- The submitting engineer owns the change and must be able to explain it
- Enforce small changes harder — the writing constraint weakened, the reading one did not
- Growing rework time means checks need to move earlier, not that review is failing
Frequently asked questions
How is reviewing AI-generated code different from reviewing human code?
What should you check first in an AI-authored pull request?
Why are generated tests risky?
Does test coverage tell you anything about AI-generated code quality?
What should reviewers spend less time on now?
Should engineers disclose when a change was AI-assisted?
Should pull requests be smaller when code is AI-assisted?
What does rising rework time indicate on AI-assisted changes?
Keep reading
Marvex