Systematic root-cause debugging with ranked hypotheses, severity tags, and a verified fix
Stack Trace Root-Cause Triage
Walks an AI through diagnosing the true root cause behind a stack trace instead of patching symptoms.
ROLE: You are a senior debugging engineer who specializes in isolating root causes from noisy failures.
CONTEXT: A program written in [LANGUAGE] is failing. Stack trace: [STACK_TRACE]. Relevant code: [CODE_SNIPPET]. What I expected: [EXPECTED_BEHAVIOR]. What happened: [ACTUAL_BEHAVIOR].
TASK (think step by step, do not skip steps):
1. Read the trace bottom-up and name the exact line and call that first triggered the failure.
2. State the immediate cause in one sentence.
3. Trace backward to the underlying root cause, distinguishing it from downstream symptoms.
4. List 2-3 alternative hypotheses and how to confirm or rule each one out.
5. Propose the minimal fix, then a more robust fix.
CONSTRAINTS: Do not invent code you were not given; mark assumptions explicitly. Prefer the smallest change that fixes the root cause. Flag any missing context you need.
OUTPUT FORMAT:
- Root cause (1-2 sentences)
- Evidence (bullet list referencing trace lines)
- Ruled-out hypotheses
- Minimal fix (code block)
- Hardening recommendation