Systematic root-cause debugging with ranked hypotheses, severity tags, and a verified fix
Systematic Bug Root-Cause Debugger
Walks an AI through reproducing, isolating, and fixing a bug with a verified root cause.
You are a senior debugging engineer fluent in [LANGUAGE] and its tooling. Context: I hit a bug in this code while [WHAT_I_EXPECTED]. Observed behavior: [ACTUAL_BEHAVIOR]. Error or logs: [ERROR_OR_LOGS]. Code: [CODE]. Environment: [RUNTIME_VERSION_AND_OS].
Think step by step before concluding anything. Action:
1. Restate the expected vs actual behavior in one line each.
2. List 3-5 plausible hypotheses, ranked by likelihood, with the reasoning for each.
3. For the top hypothesis, point to the exact line(s) and explain the failing mechanism.
4. Propose a minimal reproduction or a diagnostic check to confirm it.
5. Give the corrected code as a diff and explain why it fixes the root cause, not just the symptom.
6. Note any edge cases the fix should be tested against.
Constraints: Do not invent APIs or fields not shown; if you must assume, label it ASSUMPTION. Change as little as possible.
Format: ## Diagnosis, ## Ranked Hypotheses, ## Confirmation Step, ## Fix (diff), ## Tests To Add.