Debugging
Track down a bug that only happens sometimes
It fails one time in ten, and every fix seems to work until it doesn’t.
- What you get
- The conditions that make it fail, a way to trigger it on demand, then a fix.
- Paste it into
- Your AI tool, in your project
The prompt
This bug only happens sometimes: [describe it]. Don't propose a fix yet. First work out what could vary between a good run and a bad one: timing and the order two requests finish in, double clicks, a slow or failed network call, leftover state from a previous action, time of day, or data that only some records have. For the most likely causes, find a way to force the failure every time, for example by adding a delay or sending the same request twice. Once you can trigger it reliably, show me. Then fix the cause and run the same trigger again to prove it's gone.
Use it
Open your AI tool (Claude Code, Codex or Cursor) in your project folder and paste it in. Replace the parts in [brackets] with your own details first.
More in Debugging
Fix an error you don’t understand
The AI patches the line the error names, and a new error appears somewhere else.
Break out of a fix-and-break loop
Each fix causes a new bug, and you’ve been going round for an hour.
Fix a CORS error properly
The browser blocks a request, and the quick fix is to allow everything.
The page is blank and the terminal shows nothing
No error where you’re looking, only a white screen or a page that never finishes loading.