Ask an AI to "review this code" and it mostly fixes your naming and style. Ask it to break your code instead, and it starts finding the bugs that slipped past human reviewers.
The labs making headlines for AI bug hunting aren't using a magic model. They point the model at code with one job: find the input that makes it fail. You can do the same thing in any chat tool with one prompt. Below is the prompt, why it works, and a short example where it catches a bug a normal review walks right past.
Why a normal review prompt misses logic bugs
When you paste code and write "review this," the model compares what it sees to what good code usually looks like. That's pattern matching, and it's good at it. You get comments about unclear variable names, missing comments, a function that could be shorter. Useful, but in my experience much of it is the kind of thing an automatic style checker would flag anyway.
What you rarely get is a logic bug. Code can look perfect and still be wrong, because the wrongness lives in an assumption nobody questioned. A normal review asks "does this look right?" Nobody in that conversation is asking "when does this break?"
The bugs that survive human review are rarely exotic. They tend to fall into three groups:
- Edge cases: what happens at the very start or end of a range, like the first item, the last item, or an empty list. Think of calendar code that works all month and breaks on the 31st.
- Off by one errors: counting one too many or one too few, the classic fence problem where ten one meter sections of fence need eleven posts, not ten.
- Rare combinations: a bug that only appears after a specific sequence of events nobody thought to test.
One real example shows how ordinary these are. In a postmortem from April 2026, Anthropic described a Claude Code change meant to clear older reasoning from sessions that had been idle for over an hour. A bug made it clear that reasoning on every turn for the rest of the session instead of once, so Claude seemed forgetful and repetitive (summary by Simon Willison). It only showed up for people who left a session idle and came back, which is exactly the kind of case nobody thinks to test.
The bug isn't clever. It's an assumption that held in every case someone happened to try.
The adversarial prompt
The fix is to change the model's job. Instead of a reviewer confirming your code works, make it a tester trying to prove it doesn't. Paste this, then paste your code below it.
Act as an adversarial tester. Your goal is to break the code below, not to
confirm it works. Ignore style, naming and formatting completely.
For every function:
1. List the assumptions it makes about its inputs and about when it is called.
2. For each assumption, describe a concrete input or sequence of calls that
violates it.
3. Check edge values: empty input, zero, one item, negative numbers, very
large numbers, and counts that don't divide evenly.
4. Check state: anything that persists between calls, runs in a different
order than expected, or depends on timing.
5. Look for anything the code treats as "always" or "never" happening.
For each problem you find, give: the exact line, the input that triggers it,
what the code does, and what it should do. If you can't find a real failing
input, say so instead of inventing one.
CODE:
[paste your code here]In my experience, the framing does the heavy lifting. "Review this" sets the target as matching expected behavior. "Break this" sets the target as finding a specific failing input, which pushes the model to trace what the code does with unusual values instead of judging how it looks. Asking for the exact triggering input matters too: a vague worry is easy to dismiss, a concrete "call it with 25 items" is easy to check.
The last line of the prompt is there on purpose. My rule of thumb: a model asked to find problems will find some, real or not, unless you give it permission to come back empty.
Running it on code that already looks fine
Here's a short script that shows a list of items ten per page. It reads cleanly and works with every number you'd probably test first.
def get_page(items, page, per_page=10):
"""Return one page of results. Pages start at 1."""
start = (page - 1) * per_page
end = start + per_page
return items[start:end]
def total_pages(items, per_page=10):
return len(items) // per_page
def show_all(items, per_page=10):
for page in range(1, total_pages(items, per_page) + 1):
for item in get_page(items, page, per_page):
print(item)Run it with 10, 20 or 100 items and everything prints. Run it with 25 and only 20 show up. The // in total_pages divides and throws away the remainder, so 25 items count as 2 pages and the last 5 quietly vanish. No error, no warning.
The responses below are illustrative, condensed to show the shape of answer each prompt tends to produce. Your exact wording will differ.
GENERIC PROMPT: "Review this code."
The code is clean and readable. Suggestions:
1. Add a docstring to total_pages and show_all.
2. Consider type hints for clarity.
3. show_all could return a list instead of printing.
ADVERSARIAL PROMPT:
Assumption: the number of items divides evenly by per_page.
Line: return len(items) // per_page
Input: 25 items, per_page=10
Result: total_pages returns 2, so items 21 to 25 are never shown.
Fix: round up, for example (len(items) + per_page - 1) // per_page.
Assumption: page is always 1 or higher.
Line: start = (page - 1) * per_page
Input: page=-1, with 25 items
Result: start is -20, so it returns items[-20:-10]: ten real items
from the wrong part of the list, with no error.
Input: page=0
Result: returns an empty list silently instead of signaling a bad page.
Fix: raise an error when page is below 1.The generic answer isn't wrong. It just answers a different question. The adversarial answer names the line, the assumption behind it, and the exact input that breaks it, which is the one thing you needed to know.
The page=-1 case is the nasty one. An empty page at least looks broken. Ten plausible items from the wrong page look like a working feature, and that kind of bug can sit in production for months.
A review prompt that asks the model whether your code works will mostly tell you it does, while one that asks it to break your code goes looking for the input that proves otherwise. Paste the last script you shipped into the adversarial prompt today, try every failing input it names, and see what it finds that your last review didn't.