← Back to library
Fix errors

It runs, but the result is wrong

No error at all, just not the outcome you wanted

  • debug
  • logic
  • bisect

The prompt

My code runs fine with no errors, but the result is wrong.

Expected: {{what should happen}}
Actual: {{what happens}}

Relevant code:
```
{{paste it}}
```

Already confirmed: {{e.g. "the API response is correct", "the function does get called"}}

Please:
1. List 3-5 possible causes for the gap between expected and actual.
2. For each, give a fast way to test it (one log line, one changed parameter, one breakpoint).
3. Order them by least effort first so I can eliminate them one by one.

Rules:
- Do not dump a big rewritten block yet - we have not located the problem.
- Every test must be concrete enough that I can do it right now.

Replace the {{}} parts with your own content

Why it works

  1. Location is the hard part here; asking for fixed code too early usually patches the wrong place and makes it worse
  2. Asking for quick tests instead of conclusions turns debugging into a checklist you can run
  3. Stating what you already confirmed can immediately eliminate half the possibilities
  4. Ordering by effort means you spend the least to rule out the most

What it looks like

"The list renders but in the wrong order" - AI first has you determine whether the API or a frontend sort is responsible, with a single console.log that tells them apart.

Where it bites

  • Saying only "it is wrong" without describing expected vs actual leaves AI nothing to work with
  • Rushing to rewrite code before locating the fault, so you fix three correct places and miss the fourth
When to use it
When there is no error message, just wrong logic or wrong data.
Models
Claude / GPT

Browse categories