Example result: Find the root cause from a stack trace
AI-generated example · Debug · Root Cause
Updated

Find the root cause from a stack trace

This prompt makes the AI read your stack trace from the bottom up and find the line that really causes the failure, not just where it crashes. Paste the full trace, the code it points to and what you expected to happen.

text-code-stack-trace-root-cause — claude — 97 words

Act as a senior [LANGUAGE, e.g. Python / Django] developer helping me debug.

Error and full stack trace:
[PASTE THE STACK TRACE]

The code it points to:
[PASTE THE RELEVANT FILE OR FUNCTION]

What I expected to happen: [EXPECTED, e.g. the order saves and returns 201]

Walk the trace from the bottom up and tell me which line actually causes the failure, not just where it crashes. Give the most likely root cause, one or two other possible causes, a minimal fix as a code diff, and one check I can run to confirm the fix worked.

Paste the whole trace, not only the last line. The real cause is often a few frames above the crash.

Get a better result

What you will get

The line that truly causes the failure, found by reading the trace from the bottom up, plus the most likely root cause, one or two other causes, a minimal fix as a code diff and one check to confirm it worked.

Common mistake

You paste only the last line of the error.

Fix: Paste the whole trace, as the tip says. The real cause is often a few frames above the crash.

Also watch for
  • The fix changes much more code than needed. Add “smallest possible change, touch only the lines involved, no refactoring”.
  • It guesses about code it cannot see. Paste the file or function named in the trace and say “if you need another file, ask for it instead of guessing”.
Try a variation: add a test

Ask “then write one failing test that reproduces this error, and show that it passes after the fix”. A test helps keep the bug from coming back.

Still not right? Reply with this

Here is the exact error I got when I ran it. Explain the cause in one line, then show only the code that needs to change:

Guides that use this prompt

More chat & writing prompts

See all 465 →