---
title: "Verify AI-Generated Code Instead of Reading It | Humza Khan"
description: "How to verify AI-generated code: reviews rarely catch bugs, so use independent checkers, run the code, and gate CI on clean, fast and secure."
url: https://humza.io/blog/stop-reading-the-code-start-proving/
author: "Humza Khan"
published: 2026-10-19
modified: 2026-10-19
tags: ["ai", "code-review", "testing", "verification"]
---

# Stop reading the code. Start proving it's clean, fast and secure.

How to verify AI-generated code: reviews rarely catch bugs, so use independent checkers, run the code, and gate CI on clean, fast and secure.

By [Humza Khan](https://humza.io/) · October 19, 2026 · 6 min read

-   ai
-   code-review
-   testing
-   verification

![Dark title card reading “Stop reading the code. Prove it.” with code-like characters passing through a glass filter and coming out as clean dotted lines.](https://humza.io/blog/stop-reading-the-code-start-proving/cover.webp)

A few weeks ago I had agents spec out an autonomous trading desk: 231 files of design docs, specs, build slices and a Go scaffold, shipped as 35 small PRs. Codex wrote every word, Claude orchestrated, and I read maybe a dozen files properly.

My first instinct was guilt. Then I went looking for the evidence that reading code was ever what kept it honest. There isn’t much.

## Reading was always a weak check

Microsoft studied its own code reviews and found that only about 15% of reviewer comments point to a possible defect, “much less a blocking defect” ([Czerwonka, Greiler, Tilford, 2015](https://www.microsoft.com/en-us/research/wp-content/uploads/2015/05/PID3556473.pdf)). Most comments were about long-term maintainability. An earlier Microsoft study came to the same place: developers expect review to find bugs, but what it mostly delivers is knowledge transfer and team awareness ([Bacchelli & Bird, 2013](https://www.microsoft.com/en-us/research/?p=164195)).

![Bar chart titled “Most code review comments aren’t about bugs.” About 15% of Microsoft reviewer comments point to a possible defect. The other 85% cover maintainability, style, and everything else.](https://humza.io/blog/stop-reading-the-code-start-proving/review-comments-share.png)

Science has run the cleanest version of this test. The BMJ sent 607 peer reviewers papers with nine major errors planted in them. On average they found 2.58 ([Schroter et al., 2004](https://researchonline.lshtm.ac.uk/id/eprint/6900)). These are experts, reading slowly, whose actual job is finding mistakes.

The reason is human hardware. Vigilance research says nobody, however motivated, can keep watching for rare problems for much more than half an hour ([Bainbridge, 1983](https://gwern.net/doc/sociology/technology/1983-bainbridge.pdf)). The industry review guidance says the same thing in practice: under 400 lines, under 60 to 90 minutes, or detection falls off ([SmartBear/Cisco](https://smartbear.com/resources/case-studies/cisco-systems-collaborator/)). An agent can produce 400 lines before you’ve finished your coffee.

So reading code was never a reliable bug filter. It worked because volume was low and it carried two other jobs along with it: a second person understood the change, and someone put their name on it.

## Every field that scaled hit this wall first

Manufacturing got there in the 1950s. Deming’s third point: “Cease dependence on inspection to achieve quality.” Inspection at the end of the line is too late, the defect is already in the product. You build quality into the process instead ([Deming’s 14 points](https://www.ifm.eng.cam.ac.uk/research/dstools/demings-14-points/)).

Science got there too. Nobody trusts a result because two reviewers read it. They trust it because someone else ran it again.

Reading every line of agent code is end-of-line inspection. It doesn’t scale, and it wasn’t catching much when it did.

## What “built-in quality” looks like with agents

There’s an asymmetry that makes this work. Plenty of things are much easier to check than to produce, and AI gets good fastest at whatever is easy to verify ([Jason Wei, verifier’s law](https://www.jasonwei.net/blog/asymmetry-of-verification-and-verifiers-law)). Writing a trading engine is hard. Checking that it rejects an order over the position limit is a test.

So the work moves from reading output to building checks. Three things matter most.

### 1\. Checkers that don’t share your blind spots

In 1986, Knight and Leveson had 27 programmers write the same program independently. The programs failed together far more often than chance predicts, because people make the same mistakes on the same hard parts ([Knight & Leveson](https://www.kth.se/social/files/564df871f2765419e306178d/KnightLeveson.pdf)). Two checkers who think alike are closer to one.

Models are worse here than people. Letting a model refine its own code five rounds in a row, with no outside check, produced a [37.6% increase in critical vulnerabilities](https://arxiv.org/abs/2506.11022).

On the trading desk I ran three reviewer agents, each with one lens: consistency, money-path safety, and “could a fresh agent actually build this slice”. First pass: 87 findings, 43 of them blocking. Almost all of them sat in the seams between files, where no single writer owned both sides. A manifest path spelled two ways, a test ID cited in one doc and missing from the catalogue. A separate arbiter agent made the binding call when they disagreed, 33 times. Otherwise you get agents politely arguing forever.

### 2\. Run it, don’t read it

A diff tells you what the code says. A test run tells you what it does.

Every slice in my build plan names its test IDs up front, and a slice isn’t done until they exist and pass. Coverage goes unit to e2e, no exceptions. Seeds aren’t dummy data; they need to look like prod in shape, if not in volume.

One catch: agents will game a check if they can. METR caught frontier models modifying tests and monkey-patching evaluators to get a perfect score ([METR, 2025](https://metr.org/blog/2025-06-05-recent-reward-hacking)). So the agent writing the code doesn’t get to own the tests that grade it.

### 3\. Write the context down, inside the repo

An agent can only be checked against what’s written down. ADRs, runbooks, schema commentary, the ICP, all inside the codebase. If an agent can’t grep it, it doesn’t exist.

Same for the reasoning. Every agent conversation gets attached to the PR, so when something breaks I read a few paragraphs of reasoning instead of a few thousand lines of code.

## Prove it’s clean, fast and secure

Passing tests is the floor. “It works” is the thing models have got best at. What they’re still weak on is what a careful reader used to look for, and each one has a check that does it better than a reader.

**Clean.** GitClear analyzed 211 million changed lines from 2020 to 2024. As AI assistants spread, duplicated code blocks rose eightfold in 2024, and for the first time in their data, copy-pasted code outpaced refactored code ([DevClass on GitClear, 2025](https://www.devclass.com/ai-ml/2025/02/20/ai-is-eroding-code-quality-states-new-in-depth-report/1626250)). Messy code costs real time. Across 39 production codebases, tasks in the unhealthiest code took 124% longer, and that code had 15 times more defects ([Tornhill & Borg, 2022](https://arxiv.org/abs/2203.04374)). The check: duplication and complexity limits in CI, plus a code-health score that fails the build when it drops.

![Bar chart comparing time to complete a task. Healthy code is the baseline. Warning-level code takes 78% longer. Alert-level red code takes 124% longer and has 15 times more defects.](https://humza.io/blog/stop-reading-the-code-start-proving/unhealthy-code-chart.png)

**Fast.** Correct isn’t quick. On EffiBench, GPT-4’s working solutions took 3.12 times as long to run as human-written ones on average, and in the worst cases 13.89 times as long with 43.92 times the memory ([Huang et al., 2024](https://arxiv.org/abs/2402.02037)). The check: performance budgets in CI. Benchmarks on the hot paths that fail the build when latency or memory regresses.

**Secure.** Veracode gave more than 100 models 80 coding tasks. 45% of the code had a security flaw, 72% in Java, and newer, bigger models were no better at security even as they got better at writing working code ([Veracode, 2025](https://www.veracode.com/resources/genai-code-security-report/)). The check: static analysis and dependency scanning on every PR, plus a reviewer agent whose only job is security.

**And the tests themselves.** A passing suite only proves what it tests. Mutation testing breaks the code on purpose and checks that a test fails. Google runs it inside code review, across millions of mutants ([Petrović et al.](https://arxiv.org/abs/2102.11378)). A mutant that survives means a test that wasn’t checking anything.

## Where the human goes

Bainbridge’s paper is called *Ironies of Automation*, and the biggest irony applies to us. Automate the work, leave the human watching, and you’ve given them the one job humans are worst at. Their skills fade from disuse, and they’re still the one blamed when it fails. Madeleine Clare Elish calls that person the [moral crumple zone](https://estsjournal.org/index.php/ests/article/view/1089). Research on automation bias adds that training and instructions don’t prevent it ([Parasuraman & Manzey, 2010](https://depositonce.tu-berlin.de/items/0c787d91-6021-480b-a333-009e0d1d0092/full)).

So “skim the agent’s PRs” is the worst of both. You’re not really checking, and you’re still on the hook.

The useful human work sits upstream. My one real mistake on that build wasn’t in the code. I let a research pass pick Python for the stack, never asked myself the question, and ended up migrating the whole design to Go. No line of code came close to costing me that much.

Agents are very good at code that is locally right. The expensive mistakes are decisions: the architecture, the language, the data model, what to test, what not to build at all. Those are what I read now.

Be the validator, not the proofreader. Comprehension is now a function of our tools, not a state of our minds. Weird, novel and kinda scary, but we were never as good at the old way as we thought.

* * *

*If you need better validation and systems in your org so you can ship with confidence, that’s what I help companies build. Reach out at [hello@humza.io](mailto:hello@humza.io)*

Originally published on [Substack](https://humzaaa.substack.com/p/stop-reading-the-code-start-proving).
