Browse
Coding

Find the bug before you fix it

Stops Claude from patching symptoms. It ranks the likely causes, tells you what to check first, and only then writes the fix.

No votes yet this week
Output
Text
Added
Updated

The prompt

Help me debug this. I'm after the actual cause, not a patch that makes the error go away.

What I expected: [EXPECTED BEHAVIOUR]
What happens instead: [ACTUAL BEHAVIOUR]
When it started, if I know: [e.g. after upgrading a package, only in production, only for some users]

The error:
```
[PASTE THE ERROR AND STACK TRACE]
```

The code:
```
[PASTE THE CODE]
```

Go in this order:
1. Tell me in one sentence what the error message actually means.
2. Give me the three most likely causes, most likely first, and say what in my code or error points to each.
3. For the top one, give me a quick check (a log line, a command, a value to print) that would confirm it or rule it out.
4. Only then write the fix. Explain why it fixes the cause and not just the symptom.
5. Tell me what would have caught this earlier: a test, a type, a lint rule.

If you need another file to be sure, ask for it before writing any fix.
  • debugging
  • errors
  • root-cause

What it generates

Example

NoteThis is an example. Results change between runs and model versions. Claude Prompts is a fan project and is not affiliated with Anthropic.

Getting the most from this prompt

Use it when

You've got an error message and you're about to paste it in and type "fix this". It earns its keep on bugs that come and go: race conditions, things that only break in production, problems that showed up after an upgrade.

Give it more to work with

Fill in the "when it started" line even if you're only half sure. "After upgrading React" or "only for logged-out users" narrows things down more than another hundred lines of code would. Paste the whole stack trace, not just the last line. For a performance problem, replace the error block with your measurements and ask for the same ranked list of causes.

The trap

Run the quick check from step three before you apply anything. If it rules out the top cause, say so and have Claude move on to the second one. That back and forth is why this beats guessing. And be suspicious of a fix that only adds optional chaining or wraps things in a try and catch. It usually hides the crash and leaves the cause exactly where it was.

How to use this prompt

  1. [01] Copy

    Copy the prompt

    Use the copy button above. The full text is included, nothing is cut off.

  2. [02] Fill in

    Replace the yellow parts

    Everything highlighted in yellow is a placeholder. Swap it for your own topic, audience or data.

  3. [03] Vote

    Run it in Claude and vote

    If the result helped, press the heart. Votes decide which prompts make the weekly top 10.

More like this

All coding prompts
Text output

In one paragraph. This is a bookings app for small gyms. A React front end talks to an Express API in /server. Data lives in Postgres and is accessed through Prisma. Anything slow (emails, PDF invoices) goes through a job...

First day codebase tour

Paste a file tree and a few key files and get the tour a senior engineer would give you: how a request flows, where things live, what to avoid.

Learn the technique

All articles