| name | debugging |
| description | Systematic debugging that applies the scientific method to failures. Use when the user says "debug this", "why is this failing", "help me find the bug", or is stuck on a problem and thrashing without progress. |
Systematic Debugging
Overview
Apply the scientific method to software failures. Observe before theorizing. Form hypotheses, design experiments, narrow the cause. Refuse to jump to fixes until the cause is isolated.
The Scientific Debugging Loop
- Observe, What exactly happens? What did you expect?
- Hypothesize, What could cause this specific discrepancy?
- Predict, If the hypothesis is true, what else must be true?
- Test, Design the smallest experiment that confirms or refutes
- Conclude, Update understanding, repeat from step 2 if refuted
Never skip from Observe to Fix. The loop exists because human intuition about bug causes is wrong more often than right.
Build the Loop First
For a hard bug, this is the skill, everything else is mechanical. Before you hypothesize, build a tight, red-capable feedback loop: one command that drives the actual bug path and goes red on this bug, green once fixed. With it, bisection, hypothesis-testing, and instrumentation all just consume it. Without it, no amount of staring at code will save you. Spend disproportionate effort here, be aggressive, be creative, refuse to give up. See references/feedback-loops.md for the ten ways to construct one, how to tighten it, and what to do with non-deterministic bugs.
Completion criterion, a loop that goes red. Do not proceed to hypotheses until you can name one command you have already run at least once (paste the invocation and its output) that is: