AI code review tested: Claude found 12 of 12 planted bugs, with 0 false alarms
- The test: 8 small Python pull requests. Six hide one bug that passes the author's own tests (a lost cent, a trial that never ends, a path check you can walk around). Two are clean. 16 fresh Claude Code agents reviewed them, once with a plain prompt and once with a strict one.
- The result: 12 of 12 planted bugs found, each with the reason it breaks. 0 false alarms on the clean code. A plain "review this" added 4 and 5 suggestions to the two clean pull requests. The strict prompt said "No bugs found" both times.
- The advice: use an AI review as a second pass after the tests, and ask for a failing input. This test used small files and well-known bug types, so it does not show how it handles a big diff or your own business rules.
A post on X by DHH, with about 5,400 likes, asked the question many people have about AI code: "What if it only looks right but then breaks later?" His own answer was that agents now make fewer mistakes than the average programmer. I can't test that. I can test a smaller version of the worry: if code looks right and its tests pass, will an AI reviewer still spot what is wrong?
Other tests exist, and they paint a harsher picture. A planted-bug comparison of 10 review tools on DEV reported detection rates between about 39% and 70%. The SWR-Bench paper found that false positives were the main problem for LLM reviewers on real code. Those tests use whole code bases. I wanted a clean, small case where I know every answer, so I could see what one strong model does with a single file. So I hid known bugs and counted what came back.
How good is AI code review at finding bugs that tests miss?
In this test, very good, on small files. Here is the setup. I wrote the rules before the first review.
- The pull requests: 8 small Python modules of 15 to 30 lines, each with a short description and a unit test file that passes. They are numbered 1 to 8, and each is a separate review.
- The 6 bugs: I planted one in each of the first six, and checked every one with a script the reviewers never saw. Each bug passes its own tests.
- The 2 clean ones: a least-recently-used cache and a retry helper with backoff. I checked both by hand. They look a little risky on purpose.
- The 2 prompts: the plain one, "Please review the pull request in this folder", and a strict one (the full text is below).
- The reviewers: 16 fresh Claude Code subagents (the "opus" model setting), one per pull request and prompt. Each worked in its own copy of the folder and saw nothing of the others. Most only read the files. A few ran the tests or the function.
- The scoring: I read every reply. A hit means it named the planted bug and said why it breaks. A false alarm means it called something a bug that is not a defect. Style comments and test ideas did not count either way.
Which bugs did the AI reviewers catch?
All six, in both prompts. That is 12 of 12. Every reviewer gave a reason, and most gave an input that fails.
| Pull request | The planted bug | Why the tests missed it | Plain | Strict |
|---|---|---|---|---|
| 1. Pagination | The page count rounds down, so a partly filled last page can never be shown | Tests use 20 items with 10 per page | found | found |
| 2. Discount in cents | Float maths then int() loses a cent: 170 at 30% off gives 118, not 119 | Tests use 10%, 25% and 50% | found | found |
| 3. Post tags | A list as a default argument is shared by every call | The default is used once per test run | found | found |
| 4. Free trial | timedelta.seconds never passes 14 days, so no trial ever expires | No test checks an old trial | found | found |
| 5. File download | A startswith check runs before the path is cleaned, so ../ gets out | The test only tries an absolute path | found | found |
| 6. User search | The sort whitelist checks only the first word, so SQL can follow it | The test injects through the search text, which is safe | found | found |
| 7. LRU cache (clean) | none | n/a | approved, 4 nits | No bugs found |
| 8. Retry (clean) | none | n/a | approved, 5 suggestions | No bugs found |
The discount bug is the best example. Both reviewers ran the function and gave inputs that break it. The plain reviewer found 100 at 80% off giving 19 instead of 20. The strict one found 1,000 at 7% off giving 929 instead of 930. That is a bug you would only meet in production, with the right price and the right percentage. The tests looked fine.
The search bug is the most serious one. The code checks the sort column against a list, but only looks at the first word. A reviewer wrote the exploit out in full: a sort value that starts with name and then adds a sub-query, which lets someone read other columns one character at a time. Both prompts found it, and both said to compare the whole value with the list.
Did the AI reviewers raise any false alarms?
No bug claims on the clean code. Four reviews of clean pull requests gave 0 false alarms. The difference between the prompts is in the noise:
- Plain prompt: both clean pull requests came back "approve", with 4 nits on the cache and 5 suggestions on the retry helper. Examples: add a lock in case threads share it, add jitter to the retry delay, retry only network errors. These are good ideas. They are not bugs.
- Strict prompt: "No bugs found", both times, with a short explanation of what it checked.
The strict prompt did cost something. On the search pull request it also reported that % and _ in the search text work as wildcards. That is true, but whether it is a bug depends on what you want. A second issue like that is the kind of extra you may or may not want.
What happened that I did not plan?
I named all eight files code.py. That is also the name of a module in Python's standard library. Seven of the eight plain reviewers noticed and told me to rename it, since it can break the import in some setups. None of the strict reviewers mentioned it, because the prompt said no style comments and it is not a bug in the code's logic. So the plain prompt caught a mistake in my own test setup, and the strict prompt filtered it out. Both behaviours are what the prompts asked for.
Three plain reviewers also added points beyond the planted bug that were right: the trial check and the days-left count disagree at exactly 14 days, the upload "own files" title has no owner check, and an empty sort string would crash with an index error.
What AI code review prompt did I use?
The strict prompt, in full. You can paste it as it is:
Review it like a careful senior engineer. Report only real bugs: code that
gives wrong results, loses data or opens a security hole. For each bug give
the line and an input that fails. If you find none, say "No bugs found".
Do not write style comments.
The plain prompt had only "Please review the pull request in the folder". Both prompts also told the agent not to edit files and to keep the reply under 200 words.
Speed and cost were small. A review took about 9 seconds with the strict prompt and 11.5 seconds with the plain one, on average. Each review used about 56,900 tokens (plain) or 56,500 (strict), on average. Most of that is Claude Code's own start-up context, not the 30 lines of code, so I would not read it as the price of a review.
What this test does not show
- The files are tiny, and that is why my numbers are higher than the others above. 15 to 30 lines each, one idea each. A real pull request spans many files and needs context the reviewer does not have.
- The bugs are famous. Mutable defaults, float money, path traversal and SQL injection fill textbooks. A model has seen them many times. A bug in your own business rules, like "refunds after 30 days are not allowed", cannot be found by reading code alone.
- One bug per pull request, and I knew where. Real reviews do not come with a count. The test says nothing about how many real bugs are missed in a code base that has 20.
- Only 4 reviews of clean code. 0 false alarms in 4 is a good sign, not a rate.
- One model family, one run per cell. A second run could differ. I did not repeat any review.
- An AI helped me write this. AI agents helped me write the pull requests, the hidden checks and the scoring, which may make the bugs easier for an AI reviewer to see. I checked each bug with a script and read every reply by hand.
- It does not test DHH's claim. His point was about agents writing code compared with people. This test is about review, one step after the code is written.
What should I do about it?
- Add an AI review after the tests pass. It cost about 10 seconds a file here and found what 4 to 6 passing tests could not.
- Ask for a failing input. Reviewers who had to give one found the real cases, and you can paste the input straight into a test.
- Use the strict prompt for a short list, the plain one for ideas. Run both if you can.
- Turn each finding into a test. Every reviewer said which test was missing. The bug stays fixed only when a test covers it.
- Do not read "No bugs found" as proof. It means one reader saw nothing. For money, login and files, add a human review.
A related result from an earlier test: four AI agents built business apps that passed 792 checks, and a second read still found a security leak. For how a short sentence changes what an agent does, see the test of unrequested changes.
FAQ
Can AI do a code review?
Yes, for small pieces of code. In this test, 16 fresh Claude Code reviews found 12 of 12 planted bugs in 6 pull requests, each with a reason it breaks. It was not tested on large diffs or on rules that only your business knows.
Is AI code review accurate?
On 30-line files with textbook bugs it was: 12 of 12 found and 0 false alarms in 4 reviews of clean code. That is a small test. A real code base has more files, more context and bugs that are harder to see, so treat the result as a minimum check.
What is a good AI code review prompt?
Ask for real bugs only, with the line and an input that fails, and let it say "No bugs found". In this test that prompt gave no noise on clean code, while a plain "review this" added 4 to 5 suggestions each time.
Can an AI code reviewer replace a human reviewer?
Not on this evidence. It found every known bug type in small files. It cannot know your product rules, and "No bugs found" only means one reader saw nothing. Use it as a fast second pass before a person reads the change.
How long does an AI code review take?
About 9 seconds with the strict prompt and 11.5 seconds with the plain one for a 30-line file, with Claude Code subagents. Large pull requests will take longer.
Sources
- DHH on X, 30 November 2026: post on agents, mistakes and code that "only looks right" (about 5,400 likes).
- Other tests: SWR-Bench (LLM code review on real changes) and a planted-bug comparison of 10 review tools on DEV. I did not check their numbers.
- Claude Code docs: Subagents (each runs in its own context window).
- Python docs: datetime.timedelta (the
secondsattribute holds only the part below one day) and default argument values (a default list is created once). - OWASP: Path traversal and SQL injection.
- Python docs: the code module, the standard-library name my test files accidentally reused.