Skip to main content

The AI Code Review Inversion: What to Focus on When the Author Is a Machine

· 9 min read
Tian Pan
Software Engineer

Your code review is optimizing for the wrong thing. When AI agents contribute the majority of your commits, reviewing for local correctness — does this function do what it says? — is like grading a math test by checking the handwriting. The machine already passed your linter, ran your test suite, and formatted the output to spec. The bugs it ships are not the bugs line-by-line review catches.

A large-scale study of GitHub pull requests found that AI-co-authored PRs contain 1.7x more issues than human-only PRs — including 75% more logic and correctness issues, 2.74x more security vulnerabilities, and 3x more readability problems. Not because the code looks wrong. Because it does the wrong thing, in the wrong place, with the wrong assumptions about the rest of the system. Those are precisely the failure modes that traditional code review, optimized for catching typos and style violations, is not designed to find.

The review discipline needs to invert. Instead of asking "is this code correct?" the primary question becomes "did the machine understand what we actually wanted?"

The Paradox of AI-Authored Code Quality

Here's the frustrating reality: AI-generated code is locally coherent and globally brittle. It follows idioms. It passes tests. It handles the happy path cleanly. Then it ships a security vulnerability, calls an API with the wrong pagination semantics, or quietly ignores an error that turns a partial failure into silent data corruption.

Around 48% of AI-generated code contains security flaws despite passing automated checks. In one widely-cited study, approximately 60% of logic faults in AI-generated code pass the test suite entirely — they're not caught until production. These numbers don't come from AI writing bad syntax. They come from AI not knowing what it doesn't know about your system.

The root cause is the context window. An agent can see the function you asked it to write, the file it lives in, and a handful of related files. It cannot see the authentication contract three services upstream, the retry budget negotiated with a downstream dependency, or the invariant that a particular field must never be null after your 2023 migration. It writes code that is correct given what it can see. The parts it cannot see are where it fails.

This isn't a fixable limitation of today's models — it's a structural property of how agents reason about large codebases. Your review process needs to account for it directly.

Shift One: Review Intent, Not Implementation

When a human writes code, you can ask them what they were trying to accomplish. The code is an artifact of that intent. When an agent writes code, the code is the only artifact — unless you preserved the conversation.

Intent alignment is now the first gate of a useful review. Before reading a single line, answer these questions:

  • What was the ticket or spec the agent was given?
  • What did the agent say it was going to do before it did it?
  • Does the PR description (if any) match what the diff actually contains?

Misalignment here is far more expensive to fix than any implementation detail. An agent that misinterpreted "archive the record" as "delete the record" will write clean, well-tested code that does the wrong thing. You will not catch it by checking variable names.

Teams that have adapted to high AI contribution rates treat the agent's conversation history as a first-class artifact — some requiring it to be attached to PRs the way you would attach a design doc. The canonical record of why a change was made lives in the conversation, not the commit message.

If you're reviewing a PR without knowing what the agent was asked, you're reviewing blind.

Shift Two: Gate on Global Consistency

After intent alignment, the second gate is global consistency: does this change contradict something the agent couldn't see?

This is where context window limitations surface most concretely. Agents are trained on public conventions for APIs, frameworks, and patterns. They are not trained on your specific codebase's conventions, your internal contract with a particular service, or the reason you chose a non-obvious implementation two years ago. They fill that gap with reasonable defaults — and reasonable defaults are frequently wrong for your context.

The boundaries are where this shows up: authentication flows, service contracts, caching semantics, error handling strategies, feature flags, pagination behavior. These are cross-cutting concerns that touch multiple files and services. An agent with a limited view writes code that makes sense in isolation but violates the contract at the seam.

A practical review heuristic: spend proportionally more time on the places where the new code touches existing systems than on the places where it does something new. A new function is mostly fine. The place where that function calls an existing service, reads from a shared cache, or writes to a table with an existing schema — that's where you look.

Some teams document these cross-cutting contracts explicitly in AGENTS.md or equivalent files that get injected into agent context. This helps, but it requires discipline to keep current, and it can't substitute for a reviewer who knows the system.

Shift Three: Audit What the Tests Are Actually Testing

AI agents write tests. They also write tests that verify their own assumptions rather than your spec.

Loading…
References:Let's stay in touch and Follow me for more thoughts and updates