Skip to content
DebuggingBeginnerVersion 1.0Works with any capable model

Stack Trace Root-Cause Analysis

Read a stack trace alongside the relevant code and produce ranked hypotheses for the root cause, each with a way to test it.

When to use it

Use it when an error has a stack trace and you want to move from the symptom to a cause. The prompt asks for competing hypotheses rather than one confident answer, and for a cheap check that would confirm or rule out each, so you debug by evidence instead of by trusting a guess.

When not to use it: Do not use it when you have no trace, no code and no way to reproduce: it will produce plausible guesses that sound authoritative. Never paste traces that contain secrets, tokens or personal data; redact them first.

Required inputs

PlaceholderWhat to provideExample
{{stack_trace}}The full trace or error message, redacted of secrets and personal data.TypeError: Cannot read properties of undefined (reading 'quantity') at applyDiscount (basket.js:48) at checkout (checkout.js:112)
{{relevant_code}}The functions named in the trace, with line numbers if possible.applyDiscount and the part of checkout that builds the line items.
{{what_changed_and_how_it_happens}}How often it happens, what triggers it, what changed recently, and what you have already ruled out.Started after Tuesday's release. Only some baskets. Not reproducible locally. Ruled out: browser version.

The prompt

Fill in each {{placeholder}} before you send it.

You are a methodical debugging partner. Your job is to help me find the root cause by evidence, not to guess a fix.

<stack_trace>
{{stack_trace}}
</stack_trace>

<relevant_code>
{{relevant_code}}
</relevant_code>

<what_changed_and_how_it_happens>
{{what_changed_and_how_it_happens}}
</what_changed_and_how_it_happens>

Steps:
1. State in plain words what the trace says happened, frame by frame from the failure point up. Distinguish where the error was raised from where the bad value probably originated.
2. List between two and five hypotheses for the root cause, ranked by how well they fit ALL the evidence above. For each: the mechanism, the evidence for it, and the evidence against it or missing.
3. For each hypothesis give the cheapest check that would confirm or rule it out, such as a log line, a breakpoint condition, a query, a unit test or a diff of the recent change. Say what result would confirm and what would refute.
4. Recommend the first check to run and why.
5. Only after the cause is confirmed, describe a fix direction. Do not provide a full fix now.

Rules:
- Use only the information supplied. Do not assume the contents of files, variables or services you have not been shown. If a hypothesis depends on something unseen, say what you would need to see.
- Do not present a hypothesis as fact. Use words that reflect your actual confidence, and state the evidence that would change your mind.
- Do not suggest broad changes such as upgrading dependencies or rewriting the module unless the evidence points to them.
- If the trace is truncated or the code does not match the trace, say so before analysing.

Output format:
What the trace says
Hypotheses (table: rank | mechanism | evidence for | evidence against or missing | check to run | what would confirm or refute)
First check to run
Information that would help most
Fix direction (only if one hypothesis is strongly supported)

Expected output

A frame-by-frame reading of the trace, then two to five ranked hypotheses that fit the evidence, each with a specific, inexpensive check. Output should separate where the error surfaced from where the bad data probably originated, say what the evidence for and against is, and name one check to run first. It should not jump straight to a rewrite.

Sample response (excerpt)Illustrative — your output will differ
What the trace says
The error is raised at basket.js:48 when applyDiscount reads .quantity of a value that is undefined. checkout.js:112 passes that value in, so the missing item probably originated in how line items were built.

Hypotheses
1 | A line item with no matching product is created when a product has been withdrawn from sale | For: failures only on some baskets; started after a release (if the release changed product lookup: not yet seen) | Against: no code shown that looks up products | Log the basket id and the item list when applyDiscount receives an undefined entry | Confirmed if failing baskets contain a withdrawn product; refuted if all items resolve
2 | The release changed the shape of line items so some baskets use a different field name | For: timing | Against: would likely affect every basket | Diff the line-item builder across Tuesday's release | Confirmed if the field changed for some basket types

First check to run
The log in hypothesis 1: it is cheap and discriminates between the two.

Limitations

  • The assistant reasons only from the trace and code you gave it. Real causes often lie in data, configuration or timing that is not visible.
  • Ranked hypotheses are not probabilities. Rank order can be wrong, so run the cheap checks for the top few, not just the first.
  • It may be misled by a trace that shows the symptom far from the cause, especially in asynchronous code.
  • If you only describe the problem loosely, it may fill gaps with plausible but unsupported detail. Include the actual code.

How to validate the output

Do these before relying on anything the model returns.

Written by
PromptFable Editorial
Last updated 13 Nov 2026
Review
Not yet reviewed

PromptFable is independent and is not affiliated with, endorsed by or sponsored by Anthropic, Google, OpenAI or any other vendor. Claude, Gemini, Google AI Studio and other product names are trademarks of their respective owners.