Plant a bug before you trust an AI code reviewer

AI code review has moved from experiment to default in a remarkably short time. Many teams now have a model reading every pull request before a human does, leaving comments, suggesting fixes and, increasingly, approving small changes on its own.

When I ask engineering leaders how they chose their tool, the answers sound reasonable: it leaves useful comments, developers accept a good share of them, it catches things people used to miss. When I ask how often it misses a real defect, the room usually goes quiet.

That silence is the problem. A code reviewer is a test of your code. Like any test, its value lies in what it fails to let through, and most teams have no measurement of that at all. It is the same trap I described in testing, where AI testing dashboards stay green while the checks behind them quietly stop checking.

Activity is not detection

The metrics vendors show, and the ones teams track internally, are almost all activity metrics. How many comments per pull request. What share of suggestions developers accepted. How much review time was saved.

Those numbers are not useless, but they answer the wrong question. Consider an illustrative reviewer that leaves forty comments on a pull request: naming, formatting, a missing docstring, a suggestion to extract a helper. Developers accept most of them, because they are cheap to accept. On the same pull request, it waves through an inverted condition in a billing path. Every dashboard says that reviewer had a good day.

Activity metrics also reward the wrong behavior over time. A reviewer that comments more looks more valuable, even if those comments crowd out the one that mattered. A reviewer that stays quiet on a clean change looks lazy, even when quiet is the correct answer.

If you want to know whether your AI reviewer catches defects, you have to give it defects you already know about.

Build a planted-defect set

The idea is borrowed from mutation testing, which has been used for decades to check whether a test suite would notice a deliberately introduced bug. Here the target is the reviewer rather than the test suite.

Start with a small set of real pull requests from your own codebase, changes that were reviewed and merged without incident. For each one, make a copy with a single planted defect of a kind that matters to you. Good candidates include:

  • A removed null or bounds check
  • An inverted or off-by-one condition
  • A permission or authorization check that has been deleted
  • An error that is caught and silently swallowed
  • A change to a test that makes it assert less than before, the reviewer’s version of the false-heal problem, where a repaired test passes but no longer checks the behavior it was written for.

Keep the plants realistic. A defect that sticks out like a syntax error teaches you nothing; one that looks like a plausible slip by a tired engineer is exactly what a reviewer is for. Two or three dozen planted pull requests across your most important code paths is enough to start.

Record, for each planted pull request, what the defect is and where it lives. That record is your answer key.

Run the drill and score it honestly

Feed the planted pull requests through the reviewer exactly as it runs in production: same configuration, same prompt, same context. Then score each one against the answer key.

Be strict about what counts as a catch. A comment somewhere in the file is not a catch. The reviewer has to point at the defect, or close enough that a developer reading the comment would find and fix it. A vague “consider adding more validation” on the right function is a judgment call; decide your rule in advance and apply it consistently.

Keep two numbers. The first is the catch rate: of the planted defects, how many did the reviewer flag? The second is the noise around those catches: how many other comments did it leave on the same pull requests? A reviewer that catches a planted defect buried among thirty style comments may as well have missed it, because nobody will read that far.

Then look at the misses one by one. Patterns matter more than the headline number. In my peer-reviewed work on self-healing web locators, I framed AI repair as assisted triage rather than an automatic fix, and the same framing applies here: the misses tell you where a person still has to look. If the reviewer reliably catches null-check removals but never notices a deleted authorization check, that is a specific, fixable gap, and an important one.

Treat a drop as a regression

The planted-defect set is not a one-time evaluation. It is a regression suite for your reviewer.

AI reviewers change underneath you. The vendor updates the model; your team tweaks the prompt or the rules; someone adds more context to the input to reduce noise. Any of these can quietly change what the reviewer catches. Re-run the drill on every such change, and on a schedule even when nothing obvious has changed.

If the catch rate drops, treat it the way you would treat a failing test in CI: investigate before you ship. In practice that might mean rolling back a prompt change, adding a rule, or narrowing what the reviewer is allowed to approve without a human.

The same drill is the fairest way to compare tools. If you are evaluating two vendors, run both on the same planted set. You will learn more in an afternoon than from any demo, much as an exit test tells you more about an AI agent than its feature list does.

Decide what the reviewer is allowed to approve

Finally, use the results to set boundaries. A reviewer that catches most planted defects in configuration and documentation changes but misses half of them in authorization code should not be allowed to approve authorization changes on its own, however helpful its comments are elsewhere.

That is not an argument against AI code review. In my experience these tools catch real problems and save real time. It is an argument for knowing, with evidence, where they can be trusted and where a person still has to look.

We would never let a new test suite into CI without checking that it fails when it should. An AI reviewer deserves the same treatment. Plant a bug, see whether it notices, and keep checking.

By jawad