To verify a bug that an AI tool has flagged, reproduce it in a clean environment first, then capture it in a failing automated test, then tighten that test until it fails for exactly the reason the AI claimed and passes once the code is fixed. Only then does the report count as confirmed. The AI's suggestion is a hypothesis, not evidence: a bug is real when you can make it happen again on demand and a test proves it. Everything below works for any AI assistant, code review bot, static analyzer, or fuzzer that produces bug reports.
What You'll Need
- The AI's original report, copied in full, including the exact code snippet, file path, line number, and any error message it quoted.
- A local copy of the project you can break freely, on a branch you are happy to throw away.
- The same dependency and runtime versions the project normally runs with, so you are testing the real thing rather than a slightly different environment.
- A test framework the project already uses, or one you can add without changing production code (pytest, Jest, JUnit, Go's testing package, xUnit, and similar).
- Access to logs, a debugger, or a stack trace, so you can see why the failure happens rather than only that it happens.
Step-by-Step
- Read the report as a claim, not a fact. Rewrite the AI's finding as a single testable sentence: "When the input has X, the function returns Y but should return Z." If you cannot state it that way, the report is too vague to verify and you need to go back for specifics. Reports that only say "this looks unsafe" or "possible null pointer" are not verifiable yet.
- Identify the exact conditions that trigger it. Extract the minimal inputs, configuration flags, user role, or data shape the AI says are required. Note anything the report leaves out, such as the order of calls, concurrency, or a time zone. Missing preconditions are the most common reason a report "does not reproduce".
- Try it by hand before writing any test. Check out the branch, open the file, and call the code path with those inputs in a REPL, a small script, or the running app. Do not fix anything yet. Your goal is one clear observation: the wrong value, the crash, the missing exception, or the security hole.
- Isolate the failure to one unit. Reduce the trigger until you have the smallest possible call that still fails. Remove unrelated arguments, log noise, and database records one at a time. A bug that reproduces from a three-line example is meaningful; one that needs the whole production dataset to show up is worth confirming, but the smaller case becomes your regression test.
- Write a test that fails for the right reason. Encode the minimal case in the project's existing test framework. Use the expected value you believe is correct, not the value the code currently produces. Run it and confirm it fails. Then read the failure output: it must match the AI's described symptom. A test that fails because of a typo, a missing import, or an unimplemented setup is a false positive and teaches you nothing.
- Confirm the test fails without the fix and passes with it. If you already know a proposed fix, apply it on a scratch commit, rerun the test, and check it goes green. Then revert the fix and check it goes red again. That red-green-red cycle is the strongest proof you can get on your own machine: the test responds to the defect and nothing else.
- Rule out flaky and shared state. Run the test at least three times in a row, then run it with the rest of the suite. If it passes suddenly, suspect ordering, leftover global state, cached responses, clock or time-zone dependence, or a random seed. Fix the test's isolation before you trust the result. A bug that only shows up in a full suite run is real and serious, but you must say so in the report.
- Capture a reproducible example others can run. Put together the shortest self-contained snippet or script that demonstrates the problem: the exact version or commit hash, the command you ran, the output you got, and the output you expected. Paste the command and output as text, not screenshots, so it can be copied and searched. If the project uses containers, a minimal reproduction that runs in one is the most durable form.
- Write down the impact in plain language. Note who is affected, under what conditions, and what happens (crash, silent wrong answer, data exposure). Distinguish confirmed from suspected. This is what lets a maintainer triage quickly and stops a cosmetic finding from being ranked alongside a data-loss one.
- Record and hand off. Add the test to the suite as a regression test, commit the reproduction snippet or link to it in the issue, and state clearly: reproduced, not reproduced, or part of the report reproduced. If you could not reproduce it, say what you tried and what differed in your setup, because that information often points straight at the real condition.
Common Mistakes
- Trusting the report without running it. AI tools confidently describe bugs that do not exist, often by misreading nullability, error handling, or library behavior. Verification means execution, not rereading the paragraph.
- Testing the fix instead of the bug. Writing a test that passes because you already changed the code proves nothing. Write it against the unmodified code first.
- Using a different environment. A different runtime, dependency version, locale, or platform routinely hides the issue. Match the project's pinned versions and note anything you had to change.
- Accepting a test that fails for the wrong reason. An unrelated error that produces a red result looks like confirmation but will not catch the bug later. Always read the failure message.
- Oversized reproductions. Pasting the entire application, or attaching a whole log file, makes a report hard to act on. Reduce first.
- Ignoring intermittent results. "It failed once" is not a confirmed bug. Establish whether it is timing, randomness, or environment, or mark it as unreproducible and ask for more detail.
Tips
- Keep the AI's exact wording next to your test. When you later find you misinterpreted the claim, you can correct the record instead of arguing from memory.
- Ask the AI for a reproduction script, not just a description. Then verify the script yourself; treat its suggestions as starting points.
- Store the minimal reproduction as a test case even if the bug turns out to be "working as intended". It documents the decision.
- Verify bug reports in order of blast radius: anything touching authentication, payments, or data deletion first, then correctness bugs, then performance and style.
- If the report cites a standard or library behavior, check the official documentation or specification directly before accepting the claim.
- Commit each reproduction on its own branch, so a failed verification leaves no debris in the main history.
Troubleshooting
- The bug does not reproduce at all. Compare the commit, dependency lockfile, runtime version, operating system, and configuration against what the AI saw. Ask the tool which version it analyzed; reports are sometimes generated against stale context.
- The test fails, but the failure message is unrelated. Strip the test down to the smallest setup, fix the unrelated error, and rerun. Do not mark the bug confirmed until the failure describes the defect.
- The bug only appears occasionally. Run it in a loop, increase logging around the suspect code, and look for shared state, races, or cached values. If it is a race, a test that loops under load is more convincing than a single run.
- The fix makes other tests fail. That may be a genuine design consequence rather than a bad fix. Identify which tests depend on the current behavior and decide deliberately whether they encode the bug. Warning: if a test was written to lock in the buggy output, change it and state why in the commit.
- The bug is real but only in production. Reproduce with anonymized copies of production data in a safe environment, and never paste real customer data into an AI tool or a public issue.
- You cannot tell whether it is a bug or a feature. Check the documentation and issue tracker, then ask the maintainer. Do not silently "fix" behavior that was intentional.
Frequently Asked Questions
Do I always need an automated test?
Not strictly, but it is the fastest way to prove a bug and it leaves something permanent behind. A manual reproduction with clear steps is acceptable when the code is hard to test, provided you record the exact inputs and output.
What if the AI bug report cannot be reproduced?
Treat it as unconfirmed. Document what you tried and which versions you used, then send that back. Never close it as fixed or file it as a real bug without evidence, because a later maintainer cannot tell the difference.
Is a passing test enough to close the issue?
Only when the test fails on the unfixed code. If it passed before you changed anything, it is not testing the defect and can give a false sense of safety.
How small should the reproducible example be?
As small as possible while still failing for the reported reason. A single function call with literal inputs is ideal, and a small script is acceptable when the bug genuinely needs several components.
Can I trust a reproduction script the AI wrote?
Use it as a draft and run it yourself. Scripts from AI tools often assume libraries, versions, or setup steps that are not present, so check every line before adding it to your project.
How do I report that only part of the finding was real?
Separate the report into individual claims and label each one reproduced, not reproduced, or uncertain. Quote the failing test and output for the reproduced ones so the maintainer can act immediately.