Debugging Prompt — the Investigation Contract
"Fix this error" gets guesses. The investigation contract gets a ten-stage diagnosis: facts separated from assumptions, alternatives weighed, fixes justified.
Read the trace bottom-up, find the frame where the bad value entered, and name what made it bad — the trace is a map, not an answer.
A stack trace shows the path to the crash — and teams still patch the top frame and move on. This setup analyzes a Python AttributeError from an import job: the trace says .strip() failed on a float at normalize.py line 31, but the investigation asks the real questions — where did a float enter a path that expects strings? which upstream frame stopped enforcing the contract? — tracing the execution path backward and treating the throw frame as the start of the investigation, not the end.
Paste the whole trace
Every frame matters — the detector recognizes it, and the analysis walks it bottom-up.
Find the entry frame
The investigation's pivot: the boundary where the bad value entered the failing path.
Fix at the contract, not the crash
The repair belongs where the contract broke — usually frames above the throw, sometimes in the data itself.
The INVESTIGATION FRAMEWORK forces stage 5 ROOT CAUSE ANALYSIS to separate the proximate cause (what threw) from the root trigger (what made it throw), and the ROOT CAUSE RULES state the symptom site and the cause site may be different places. For the sample AttributeError, that means asking where the float entered a path expecting .strip(), not patching normalize.py line 31.
It produces a prompt that makes the assistant work through ten named stages in order, from SYMPTOMS to POST-FIX VERIFICATION, and label every statement as FACT, ASSUMPTION, or HYPOTHESIS with its test per the EVIDENCE RULES. You copy that prompt and run it in your own assistant; NewPrompt does not run the investigation or confirm the diagnosis.
Skip it for intermittent failures, because this template's VALIDATION REQUIREMENTS lean on the gold standard of a reproduction that turns the failure on and off by toggling the suspected cause. Also skip minified production JS traces until you source-map them, since the bottom-up frame walk needs real file and line names like normalize.py line 31.
Yes — the AttributeError at normalize.py line 31 is a worked example, so replace the KNOWN FACTS block (Symptoms, Actual behavior, the Traceback) with your own trace, and adjust the SYSTEM CONTEXT Reported severity. The DEBUGGING CHECKLIST item on input that violates an implicit contract the code never checks generalizes to any type error surfacing far from its source.
"Fix this error" gets guesses. The investigation contract gets a ten-stage diagnosis: facts separated from assumptions, alternatives weighed, fixes justified.
An exception is a symptom, not a diagnosis: trace from the throw site back to the root trigger, with the runtime checklist on the table.
Measure before reasoning: find WHERE the time goes, separate latency from memory from throughput, and think at production scale.
"Review this code" gets shallow comments. The review contract gets findings with severities, a checklist, and a verdict.
getByRole over CSS chains, auto-wait over sleep, web-first assertions — Playwright tests written the way Playwright wants.
"Refactor this code" invites silent behavior changes. The refactoring contract preserves business rules, outputs, and side effects — and flags uncertainty instead of deciding it.
Build debugging prompts from symptoms, environment, and reproduction steps — root cause first, fix second.
A stack trace is precise about where execution stopped and nearly silent about why it started going wrong. Here is how to analyze a stack trace with AI: read the exception chain inside out, find the frames you own, and separate what the trace proves from what it merely suggests.