To verify AI-generated code, check the claims the interface makes rather than the shape of the code. A page that prints a total must be compared against the data behind that total. A checkout must be run with a real order. A status field that says a fix landed must be compared against the files. None of those checks take a minute to write, and all three of mine exist because something shipped wrong without them.

I learned this on a small product written almost entirely by a model. It took 158 orders. The refund rate sat at 0.6 percent against a category range of 0.65 to 1.2. Those numbers are fine. What is not fine is the ledger next to them: nineteen detours, 265 hours, $13,250 at $50 an hour, every row a place where AI-generated code looked finished and was not.

This is the verification routine that came out of those rows.

What "verified" means when a model wrote the code

Four different things get called verified, and only one of them matters to a buyer.

It compiles. The language server stopped complaining. This tells you the syntax is legal. It says nothing about behaviour, which is the part AI-generated code most often gets wrong.

It passes the tests. Useful, and weaker than it sounds. When the same process writes the feature and the test, both encode the same misunderstanding. The test agrees with the bug.

It behaves correctly. Someone ran it and the output was right. This is the level most teams stop at, and it survives exactly as long as the inputs resemble the ones that were tried.

A stranger paid and got what they paid for. This is the only level a buyer can see. Verification of AI-generated code means climbing to this level before shipping, not before the demo.

Why a green test proves less than you think

The failure comes from two places, and neither one shows up in a test run.

Self-report. When AI-generated code tracks its own work and writes that status into the same system you read, you have handed the defendant the pen. My dashboard said 342 fixes landed. When I recounted from the files, 132 had. The number came from a field the model wrote to itself, so "fixed" meant "the model said fixed".

I tried to patch it with an instruction. I added a line telling the model not to fabricate and not to report success without evidence. The missed-check rate went from 25.0 percent to 39.7 percent. It only came down to 23.5 percent after I stopped trusting the self-report and derived the count from the files. An instruction is not a gate. A gate is a check that fails.

Plausibility. A generated page arrives at the level of polish that normally signals care. A person who ships a tidy dashboard has probably looked at it. A model that ships one has done nothing of the sort. Your instinct to trust polish was correct for every project you shipped before this one, which is why it misfires here.

The outside evidence points the same way. Stack Overflow's 2025 survey found 66 percent of developers describing AI output as almost right but not quite. METR's 2025 trial measured experienced developers as 19 percent slower with AI assistance on their own repositories, while they believed they were faster. Veracode's 2025 report found 45 percent of generated samples failing security tests. Being wrong about your own speed is the same miscalibration as being wrong about your own tests.

Where AI-generated code fails first

Generated code gets the happy path right more often than people expect. The failures cluster at the edges, and the edges are predictable.

Money at the edges. A discount stacked on a proration. A zero-amount order. A refund after the window closed. AI-generated code handles the example that was in the prompt and treats the rest as unlikely. The first time a real buyer hits one of those combinations, the invoice and the page disagree, and the disagreement is silent.

Numbers that report on themselves. Any field named status, fixed, done or success becomes a claim the moment AI-generated code writes to it. My dashboard read 342 because the model was the author of that column. The files said 132, and the files were the only source that had no reason to be flattering.

Entitlements. What a buyer can open, download, or export. That logic usually lives in more than one place, and AI-generated code will happily write it twice with slightly different edge conditions. The 40 percent against 32.2 percent split was exactly this, and it looked correct in both code reviews because each implementation was internally consistent.

Those three edges share a property: the wrong state is plausible. Nothing crashes. No error appears in a log. A page renders a number that a person reads and believes, and the only thing that can disagree is a check written to disagree on purpose.

The total check

If a page prints a total, a test adds the column and compares. That is the whole rule, and it is the cheapest AI-generated code check you can write. Mine is a dozen lines and it has caught more than any other check I own.

It caught the worst readability failure in the project. A rule governing which chapters a buyer could read was implemented in two places. The same order produced 40 percent in one view and 32.2 percent in the other. Neither number was a typo, and both were computed honestly from different code. With a total check, the build goes red the moment the two paths disagree. Without one, a buyer sees a number nobody has compared to anything.

The same check is why the ledger total has stayed true across nine rewrites. Printed numbers drift. They drift in the direction of whatever the last edit was, and nobody notices until a buyer does.

The money-path check

Run the same code a buyer hits, with a sample order file, and assert that the amount charged equals the amount displayed. The check uses the real handler and the real formatter, because AI-generated code will format a number correctly and compute it wrongly. A screenshot of a success screen proves nothing here, because that screen renders whatever the client was told and AI-generated code will happily tell it something that did not happen.

My version reads 158 orders from a sample CSV and finishes in under a second. It would have caught a price stored in cents and displayed in dollars with a factor of 12.5 applied somewhere in the middle, which put a plan at $12.50 instead of $100 for eleven days. Nobody complained. That silence is the most expensive part of the story.

Verification of AI-generated code that touches billing has to include the settlement. Watch the money land in your own account, once, with a real card or a sandbox that behaves like one. Every billing detour in my ledger survived a passing test, because the test never touched the payment path.

The independent-count check

Read the status field, read the files, and fail when they disagree. Neither count alone finds the 342 against 132 gap, since each one is internally consistent. The check that finds it refuses to accept either source as final.

This check is specific to generated work. Human teams rarely have a number that reports on itself. Generated systems produce those numbers constantly, because self-reporting is cheap to generate and expensive to disprove. If your code has a field that tracks how well the code is doing, that field is a claim, and claims need a second source.

The deliberate-red check

Make one check fail on purpose. A suite that only ever passes cannot be told apart from a suite that never runs, and AI-generated code makes that ambiguity easy to reach because writing a passing test is trivial.

Two of the three checks in the public repository fail by design. A new reader can see what red looks like before trusting green. I added that after a stretch where nothing had gone red in weeks. A suite that stays green that long has usually stopped covering anything new, and AI-generated code makes it easy to write tests that agree with themselves.

The timing check

Time the thing a person waits for. Median response on my scoring path is 44.7 seconds. That number is a test, and for AI-generated code it is the only place the number appears. A regression from 44.7 to 90 seconds is invisible in any summary and obvious in the assertion.

Timing is the check AI-generated code breaks most quietly. AI-generated code will happily add a loop inside a loop, and every functional test still passes. The only symptom is a number nobody is asserting on.

A five-minute version you can run today

If you have one afternoon and one generated project, these five assertions cover most of the exposure. Each one targets a failure that AI-generated code reaches easily and a normal test run walks straight past.

Assert one printed number against its source. Pick the total a user acts on. Add the column in the test. Compare. This takes ten minutes and it is the highest-value ten minutes in the whole list.

Assert the charged amount equals the displayed amount. Use the worst sample order you have: a discount, a proration, a zero. If the two differ, stop shipping.

Find one field that reports on the code itself and give it a second source. Grep for status, fixed, done, landed, success. Each of those is a claim. Each one needs a file-level count to disagree with.

Break a check on purpose and confirm the build goes red. Then fix it and confirm green. Five minutes, and it tells you whether the red light is wired at all.

Assert a latency ceiling on the slowest user-facing path. Set it at twice today's median. The point is not the number. The point is that a regression becomes a failing build instead of a complaint.

Five assertions. One afternoon. They do not make AI-generated code correct. They make it honest about when it stopped being correct, which is the only property you can automate. Verification of AI-generated code is a small set of comparisons repeated at every build, and the repetition is what does the work.

When verification is not worth it

Internal tools. Scripts that run once. Prototypes whose only job is to answer a question. Anything where the cost of being wrong is measured in minutes, because writing the check costs more than the mistake will.

It is also fine to skip verification on the parts of a real product that are cheap to inspect: layout, copy, a settings page. You can look at those and know.

AI-generated code does not change where that line sits. It stops being optional in three places. Anything that charges money. Anything that reports a number somebody will act on. Anything that tells a buyer what they are entitled to. Those three need a check that can fail, and the rest can wait until you have time.

If you want to see the checks rather than read about them, they are public in the forgerank-checks repository. Two of the three fail on purpose. The full list of nineteen detours, priced at $50 an hour with a source on every row, is at the $13,250 ledger. The verification chapter and the rest of the method are in the book, and the first four chapters are free at the sample page.

The one question behind every AI-generated code check

Before writing any of the five, ask what a buyer would notice if this were wrong. That question sorts the checks into the ones your product needs and the ones that can wait a month. AI-generated code makes skipping it feel safe, because the code already exists and looks finished.

The answer is usually two checks, not five. When I ran it on my own build, the total check and the money path covered the failures that cost money. The independent count covered the one that cost trust. The other two waited.

Verification of AI-generated code works like triage. Pick the failures a person would feel, write the smallest check that would catch each one, and leave the rest. A suite nobody maintains is decoration with a green dot next to it.

Frequently asked

How do you verify AI-generated code?

Verify the claims the interface makes rather than the shape of the code. Compare a printed total against its source. Run one real order through the money path. Compare a self-reported status against the files. Prove the suite can go red. Assert a latency ceiling on the slowest path a user waits on.

Why do tests pass on AI-generated code that is wrong?

The same process writes the feature and the test, so both encode the same misunderstanding. Even with honest tests, a status field the code writes about itself can record success that never happened. Mine claimed 342 landed fixes when the files showed 132.

Is reading the diff enough?

Reading catches intent. It misses arithmetic. It will not catch a total that disagrees with its column, a price factor of 12.5 applied in the middle, or two implementations of one rule drifting at the edges. Those show up as numbers, so a test has to compare numbers.

Where the numbers come from: 158 orders and a 0.6 percent refund rate on the live product. 265 recorded hours at $50 an hour, a source on every row of the public ledger. The fifteen tests and seven health checks are in the open repository. External figures are linked above: Veracode 2025, Stack Overflow 2025, METR 2025.