PromptScan: pass
Debug From a Stack Trace
Reads a stack trace and the relevant source, forms ranked hypotheses with evidence, and proposes the single cheapest experiment to confirm the root cause.
Add a trust badge to your README
[](https://waxmark.app/items/debug-from-stack-trace/scan)
Diagnose the failure below. Your job is root cause, not a patch that hides the symptom. Treat every claim you make as something a skeptical teammate will ask you to point at in the trace or the code.
<stack_trace>
{{STACK_TRACE}}
</stack_trace>
<code>
{{CODE}}
</code>
<context>
{{CONTEXT}}
</context>
Language/runtime: {{LANGUAGE}}. <context> may include: what changed recently, how often it reproduces, environment differences, and what has already been tried. Treat "already tried" items as ruled out unless you can explain why the attempt was invalid.
Method:
1. Read the trace bottom-up to the first frame inside the project's own code (skip framework and library frames unless the message implicates them). Quote that frame and the error message verbatim.
2. Restate the failure as a fact about program state: not "null pointer" but "`user.profile` was null when `render()` ran, which means `loadProfile()` returned without setting it or was never awaited".
3. Generate 2-4 hypotheses that would produce exactly this state. For each, cite the specific lines in <code> that make it possible and name what evidence in the trace or <context> supports or weakens it. Do not list hypotheses the evidence already excludes.
4. Rank them by likelihood. Say what ranking you would change if <context> were different (for example, "if this reproduces only in production, hypothesis 2 moves to first").
5. Design the one cheapest experiment that distinguishes the top hypothesis from the runner-up: a log line, a breakpoint condition, a unit test, a query. State the expected observation under each hypothesis.
6. Only then propose a fix for the top hypothesis. Label it as conditional on the experiment. If the fix changes behavior for other callers, say so.
Resist the pull toward the most familiar bug. If the trace points at line 40 but line 40 is a symptom of state set on line 12, say so.
## Output format
**Failure, precisely** - 1-2 sentences in the form from step 2, plus the quoted first project frame.
**Hypotheses** - numbered, ranked. Each: one-line statement, `Evidence for:` with line or trace references, `Evidence against:` or "none found", `Likelihood:` high / medium / low.
**Confirming experiment** - what to do, how long it takes, and a two-row table: hypothesis, expected observation.
**Proposed fix (conditional)** - a fenced diff or code block for the top hypothesis only, followed by one sentence on side effects for other callers.
**If I'm wrong** - one sentence on what to do if the experiment contradicts the top hypothesis.