Capture a failure you can repeat
Write down the input, expected result, actual result, runtime version, and relevant configuration. Remove secrets from the reproduction. If the failure depends on external services, capture a sanitized response fixture so the investigation does not depend on changing network conditions.
Illustrative scenario: a generated checkout handler applies a discount twice after a retry. Reproduce the same request identifier twice against a test database. Record the persisted order and payment calls; a screenshot of the final page alone cannot explain the duplicate side effect.
Trace boundaries before rewriting
Follow the failing value across validation, business logic, storage, and external calls. Inspect assumptions introduced by generated code: invented method names, nullable values, implicit timezone conversions, and unhandled asynchronous work. Test one suspected boundary at a time to keep evidence interpretable.
Ask an assistant for competing hypotheses rather than a complete replacement file. Check each hypothesis against the repository and installed dependencies. If a proposed fix changes unrelated interfaces or suppresses errors, reduce its scope before evaluating whether it addresses the original failure.
Prove the repair and remove diagnostics
Create a regression test that fails on the original revision and passes with the patch. Include the adjacent case most likely to break, such as a legitimate second purchase using a different request identifier. Run the relevant integration checks before accepting the change.
Inspect the final diff for temporary logs, leaked payloads, broad exception handlers, and accidental dependency changes. Record the cause and verification in the issue. A refactor may follow after the defect is understood; combining it with diagnosis makes the evidence harder to interpret.
Working sheet
| Symptom | First experiment | Evidence to keep |
|---|---|---|
| Duplicate writes | Replay one request identifier | Row count and side-effect calls |
| Wrong total | Use fixed prices and rounding cases | Inputs and expected arithmetic |
| Intermittent timeout | Stub the remote response | Timing and retry sequence |
| Missing result | Await the operation explicitly | Promise completion and error path |
Questions about how to debug AI-generated code
Should I ask AI to rewrite the failing module?
Start with a small reproduction and a narrow patch. A rewrite changes too many variables before you know the cause.
What if the generated test passes already?
Check whether it reproduces the reported inputs and asserts the observable failure. A test copied from the implementation may preserve the same mistake.
How should I use the working sheet?
Download the CSV and replace the sample rows with evidence from your repository. Record a clear acceptance check and an owner for each item. Keep unresolved assumptions visible rather than treating the example as a completed assessment.
Sources and further reading
Examples are illustrative. They are not customer results, security guarantees, or a substitute for checking the documentation for your installed version.
