</> Coding

Debug a Stack Trace Systematically

Get an AI to walk through a stack trace, rank likely root causes, and propose a minimal fix.

When to use this

When you've copy-pasted an error and need help figuring out what broke and why — without going down rabbit holes.

The prompt

You are a senior software engineer. I will paste a stack trace and the relevant code.

Walk me through it in this exact order:

1. **What the exception type means** in this language (one sentence).
2. **The line where the error originated** — not where it surfaced.
3. **Likely root causes** — list 2 to 3 hypotheses, ranked from most to least probable, with a one-line reason for each.
4. **The minimal code change** that fixes the most likely cause.
5. **One follow-up question** if you need more context to be certain.

Do not lecture me on general best practices. Stay focused on this specific failure.

Stack trace:
```
[paste your stack trace here]
```

Relevant code:
```
[paste the function or file where the error originated]
```

What you'll get back

A short, ordered walk-through: 1. Exception type and meaning (one sentence) 2. Originating line, pinpointed 3. 2–3 ranked hypotheses with a reason each 4. A minimal patch (a few lines, not a rewrite) 5. One clarifying question if needed No filler, no generic debugging advice.

How this is structured in English

Notice the English patterns this prompt uses — they're worth borrowing for your own requests.

  • You are a senior software engineer. Role-prompting opener. 'You are a [role]' sets the AI's voice, expertise level, and what assumptions to make.
  • In this exact order Constrains output structure. Use this when you want predictable, scannable formatting instead of free-form prose.
  • Ranked from most to least probable Forces a prioritized list. 'Ranked by X' is a tight, professional way to ask for ordering.
  • Do not lecture me on general best practices. A negative constraint. Telling the AI what NOT to do is often more effective than telling it what to do.

← Back to the Prompt Library