How to ask an AI to fix a bug
Use this form when something you built or run is broken: an app, a website, a script, a formula. Correcting software errors was the most common single task on Claude.ai in November 2025, at 6% of usage, according to Anthropic’s Economic Index.
Why the recommended questions matter
- What goes wrong, and what should happen instead. Anthropic’s guide to Claude Code says that describing the symptom and saying what “fixed” looks like up front usually saves a round of corrections.
- How to make it happen. Mozilla’s bug-writing guidelines call the steps to reproduce the most important part of a bug report, and OpenAI’s Codex guide says reproduction steps and constraints matter more than a high-level description. In a survey published in 2010 of developers and bug reporters on three open-source projects, Apache, Eclipse and Mozilla (466 responses in all), the developers rated steps to reproduce the most important item in a report.
- The exact error text. Replit’s guide asks for the exact error message. Lovable’s says that for an error outside its preview, pasting the exact message from your browser’s developer tools or your backend logs still helps.
- The part involved. Claude Code’s guide says to name the file, and GitHub’s guide asks for directions about which files need to change. If you do not know the file, this site suggests naming the page or button instead.
What the form adds for you
- In every prompt, a request to find the cause before changing anything. Lovable’s debugging guide says that repeated blind fixes tend to pile up code that hides the real problem, and Cursor’s Debug Mode forms hypotheses and gathers evidence from logs before it edits.
- In every prompt, a request for the smallest change that fixes the cause, as the bug-fix example in OpenAI’s Codex guide asks for a minimal fix.
- An answer to “Can the AI open your project?” Choose Yes, for an app builder or coding agent, and the prompt asks it to reproduce the problem first, as the Codex example does, and to add a failing test if the project has tests. Choose No, for a chat, and it tells the AI to work from what you pasted and to ask you for anything else it needs. Leave it unanswered and the prompt carries neither line.
- If you list what you have tried, a request not to repeat it.
If it has already failed twice
Anthropic’s Claude Code guide says that after two failed corrections, clearing the conversation and writing one new prompt that folds in what you learned works better almost every time. Lovable’s debugging guide says that switching to Plan mode after one or two failed attempts is usually faster than trying again.
A worked example
An app builder, a visitor who is not a programmer, and two fixes that did not work:
Find and fix this problem: On my shared grocery list, when I tick off an item on my phone it comes back unticked a few seconds later.
<context>
Steps that make it happen:
1. Open the list on phone A and phone B.
2. On phone A, tick "milk".
3. Wait about five seconds.
4. "Milk" is unticked again on both phones.
What changed before it broke: It worked until yesterday, when I asked for household invites to be added.
What I have already tried: Asked for a fix twice in the same chat. Each time it said it was fixed, and it was not.
It happens every time.
I am not a programmer. Explain the cause in everyday words, and give me exact steps for anything I need to do myself.
</context>
<source_material>
The exact error text: PATCH /rest/v1/items?id=eq.42 403 (Forbidden)
Where to look: The grocery list page. I don't know which file.
</source_material>
<task>
Fixed means: A ticked item stays ticked on both phones, even after I refresh the page.
Find the cause before you change anything.
Reproduce the problem first. If the project has tests, add one that fails because of this problem. After the fix, run the steps and that test again and show me the results.
</task>
<constraints>
Leave these as they are: The new invite feature and the look of the page.
Stop once you have found the cause. Tell me what it is and how you would fix it, then wait for my OK.
Fix the cause, not only the symptom, with the smallest change that does it. Leave everything else as it is.
Do not repeat the fixes I have already tried. If they did not work, look for a different cause.
</constraints>
<output_format>
When you are done, tell me the cause in plain words, what you changed, and how I can confirm it is fixed.
</output_format>
If you cannot be sure of the cause, list the likely causes in order and say what would tell them apart before you change anything. If the information here is not enough to answer well, say so and tell me what you would need. If something missing would materially change the result, ask me up to 3 short questions first. Otherwise proceed and state your assumptions.