Why Asking AI to Fix Its Own Code Fails

Key takeaways
- An AI coding tool reviewing its own output is working from the same assumptions that produced the problem, so the review inherits the blind spot.
- The model cannot see the three things that decide whether an app is safe to launch: your running system, your production configuration, and what happens when a real customer does something unexpected.
- "I checked and the tests pass" is usually true and almost always meaningless, because generated tests frequently assert on mocked values and never execute the code they name.
- The checks that matter are empirical, not textual: pay with a real card, sign in as a second customer, pull the plug mid-request.
Asking the AI that built your app to review it does not work because the model is answering a question about text while you are asking a question about a running system. It cannot reach your database, cannot spend money on a real card, cannot see your deployment configuration, and has no memory of the decisions it made in an earlier session. What comes back is a fluent, confident reading of the code in front of it, which is precisely the artefact that already contains the fault.
This is not a complaint about AI coding tools. We use them daily, on our own products and our clients'. It is an argument about what a review is, and about the specific conditions a model cannot reproduce no matter how good it gets.
The review inherits the blind spot that caused the bug
Code is wrong for one of two reasons. Either it does not do what its author intended, or it does exactly what its author intended and the intention was wrong. AI tools are now very good at the first kind. Syntax errors, type mismatches, obvious logic slips: a model will find those in its own output readily.
The failures that stop a launch are almost always the second kind. A payment handler that grants access when the browser reports success is not a mistake in execution; it is a correct implementation of a flawed assumption about who can be trusted. A database table without a row-level policy is not a bug in the policy; it is the absence of a requirement nobody stated. When you ask the model to check its work, it re-reads the code against the same assumption set that generated it, and the code passes, because internally it is consistent.
Veracode's 2025 GenAI Code Security Report is the clearest public evidence that this is structural rather than incidental. Testing more than 100 models across 80 curated coding tasks, it found security vulnerabilities introduced in roughly 45% of cases, and, critically, that the rate did not fall as models improved at producing syntactically correct, working code. The two capabilities are not the same capability. It is worth reading that 45% precisely: it is the share of tested task outputs that failed, not a measurement of all AI code in production. The useful conclusion is about direction, not magnitude. Getting better at writing code has not made these tools better at noticing unsafe code.
Three things the model cannot see
Your running system. The model sees a repository. It does not see which environment variables are actually set in production, whether the database policies in your migration files were ever applied to the live database, that your payment keys are still the test ones, or that a service in the chain quietly stopped working three weeks ago. A very large share of real production failures live in the gap between what the code says and what the deployed system is doing.
Real money. The only way to know whether a subscription flow works is to run it: sign up, get charged, let it renew, cancel, try to pay twice, pay with a card that declines. That requires a card, a payment account and time passing. A model can read a payment integration and tell you it looks correct. It cannot tell you that the account is wired to someone else's business, which we have found in a real client app, because nothing in the code is wrong — the identifier is simply the wrong identifier.
An adversarial second user. Most of what makes an app unsafe only appears when a second person exists. Can customer B read customer A's records by changing a number in a URL? Does a shared link stay valid after access is revoked? You cannot discover this by reasoning about code; you discover it by holding two accounts open and trying.
Why "the tests pass" is not evidence
The most dangerous sentence in a generated codebase is a green test run. We have audited an app with twenty passing tests where not one of them ever executed the code it claimed to cover: every dependency was mocked, the assertions were made against the mocks, and the real functions were never called. The suite was an elaborate way of confirming that the test framework works.
A model asked to verify the app reads the test names, sees them pass, and reports that the application is tested. It has no way to know that the coverage is theatrical, because establishing that requires running the suite against deliberately broken code and observing that it still passes. That is an experiment, not a reading.
If you want to check this yourself in five minutes: take the three tests covering your most important behaviour, break the code underneath them on purpose, and run them again. Anything still green is decoration.
What actually catches these problems
Three things, none of which a model can do on your behalf:
- Use the app as a hostile customer. Two accounts open at once. A real card. Deliberate declines. Cancel and then try to get back in. Edit the numbers in URLs.
- Compare the code to the deployed reality. Read what is actually configured in production against what the repository assumes, table by table and key by key.
- Verify the verifiers. Break things on purpose and confirm that your tests and your monitoring notice.
A model is genuinely useful inside each of those steps. It is good at drafting the fix once you know what is wrong, good at explaining an unfamiliar error, good at writing the test you have decided you need. It is simply not the thing that decides whether your app is safe, any more than a spell-checker decides whether an argument is sound.
What to do with this
If you built something with Lovable, Replit, Bolt, Cursor or ChatGPT and your honest answer to "is this safe to launch" is that the AI said it was fine, you do not yet have an answer. Work through the twelve checks before launching an AI-built app, or send it to us: Boltout's AI App Rescue audit is free, comes back in writing inside 48 hours, and ranks every finding by what it would do to a customer. If the question you are really asking is whether the app is worth repairing at all, rebuild it or repair it is the one to read.
Sources
- Veracode 2025 GenAI Code Security Report — security vulnerabilities introduced in roughly 45% of tested tasks across more than 100 models, with no improvement as code correctness improved
- CVE-2025-48757, US National Vulnerability Database — insufficient row level security in AI-generated applications, published May 2025
- Stripe, webhook delivery and duplicate events
Frequently asked questions
No. Automated review is good value for a specific class of problem: known vulnerable patterns, dependency versions with published advisories, dangerous functions, obvious injection risks. Run it. What it cannot do is confirm that your business rules are enforced, that your payment flows behave correctly in every path, or that your deployed configuration matches your code, and those are the things that stop a launch.
Better, and still not sufficient. A second model does not share the first one's session, so it brings fresh assumptions and will sometimes catch a flawed one. But it still cannot reach your running system, cannot spend real money, and cannot act as a second customer. It changes the quality of the reading; it does not turn a reading into a test.
More than you would expect. Open two accounts in two browsers and try to see one from the other. Pay with a real card, then cancel, then try to use the paid features. Sign out and check your saved data is still there when you sign back in. Each of those is a plain-English experiment with a yes or no answer, and each one covers a failure we find regularly.
No. They are the fastest way to get from an idea to something real that we have seen, and that genuinely matters. The mistake is treating the output as a finished product rather than as a working draft that has never been tested by anyone but its author. Keep building with them, and have the parts that touch money, customer data and identity verified by someone who can run the system.
Written by
Chief Operating Officer · Boltout
Moid Khan is Chief Operating Officer at Boltout, where he oversees delivery and operations across the studio's ventures and client engagements. He writes about building software products with AI, web, mobile, and cloud technology, drawing on work with startup and enterprise teams across the US and globally.
Ready to build something?
We help businesses ship better software, from AI integrations to full-stack web and mobile. Let's talk about what you need.
Get in touchKeep exploring
Services aligned with “Vibe Coding”: View capability overview