Root-Cause Bug Fix With Honest Testing
You get a small, targeted fix with a test that proves it, plus an honest list of what was and was not checked. It works because it sets a clear goal, limits the scope, and tells the AI when to carry on and when to stop.
The prompt
Act as a careful senior software engineer fixing a bug in an existing codebase.
Task: Find the root cause of the bug described below and make the smallest change that fixes it. Work until it is fixed. Keep going through recoverable problems, such as a failing command or a missing file, and stop only if you hit a real blocker that needs my decision.
Bug report: {bug_report}
Relevant code: {code_snippet}
Out of scope: {exclusions}
Steps:
1. State the outcome you are aiming for, then trace the fault back to its root cause rather than patching the symptom.
2. Change only what the cause requires. Do not refactor, rename or touch anything listed as out of scope.
3. Run the tests or checks available to you, and add one test that fails before the fix and passes after it.
4. Report results honestly. Say plainly what you ran, what passed, what failed, and what you could not verify.
5. Stop once the bug is fixed and verified, or when a genuine blocker stops you.
Output:
Root cause in two sentences, the minimal diff, the test results in a short list, and a final line marked "Not verified:" listing any gaps.
Change the parts in curly braces. Use it when an AI coding assistant tends to over-edit or claim a fix works without running anything.
What happened when we ran it
We sent
Act as a careful senior software engineer fixing a bug in an existing codebase.
Task: Find the root cause of the bug described below and make the smallest change that fixes it. Work until it is fixed. Keep going through recoverable problems, such as a failing command or a missing file, and stop only if you hit a real blocker that needs my decision.
Bug report: Customers in the UK are charged VAT twice at checkout. An order of £50.00 shows a total of £60.00 plus another £10.00 line, giving £70.00. It started after last Tuesday's release and only affects orders with a discount code applied.
Relevant code: function calculateTotal(items, discount) {
let subtotal = items.reduce((sum, i) => sum + i.price, 0);
let vat = subtotal * 0.2;
subtotal = subtotal + vat;
if (discount) { subtotal = subtotal - discount.amount; }
return subtotal + subtotal * 0.2;
}
Out of scope: Do not change the discount code validation, the database schema, or the checkout page styling. Do not upgrade any dependencies.
Steps:
1. State the outcome you are aiming for, then trace the fault back to its root cause rather than patching the symptom.
2. Change only what the cause requires. Do not refactor, rename or touch anything listed as out of scope.
3. Run the tests or checks available to you, and add one test that fails before the fix and passes after it.
4. Report results honestly. Say plainly what you ran, what passed, what failed, and what you could not verify.
5. Stop once the bug is fixed and verified, or when a genuine blocker stops you.
Output:
Root cause in two sentences, the minimal diff, the test results in a short list, and a final line marked "Not verified:" listing any gaps.
The model replied
Run on Claude Sonnet 5.5, 12 Nov 2026. Automatic check: 2 out of 5.
Mentioned for
Claude
Where it came from
Found on Web, shared by Rizki Murtadha (Promptessor): Claude Fable 5.2 Prompting Guide: Tips & Examples.
This is our own version of the idea, written and tested by us. The original may differ.