Debug a problem by testing hypotheses
Turns a confusing bug into a ranked list of hypotheses, each with a quick test, so you stop changing code at random.
Help me debug a problem methodically.
Symptom: {{SYMPTOM}}
What I have already tried: {{TRIED}}
Relevant code:
```
{{CODE}}
```
1. Restate the problem precisely: expected behaviour, actual behaviour, and when it happens.
2. List 3 to 5 hypotheses for the cause, ranked by likelihood. For each, explain the reasoning in two sentences.
3. For each hypothesis, give the quickest test that would confirm or rule it out (a log line, a breakpoint, a minimal input).
4. Tell me which test to run first and what result would mean what.
After I report a result, update the ranking and suggest the next test. Do not propose a fix until a hypothesis is confirmed.Example output
H1 (likely): race between cache write and read. Test: add a 200ms delay before read; bug should vanish. H2: timezone conversion on the server. Test: log `Date.now()` and the parsed date side by side.
How to use
Be honest in TRIED, including things that changed nothing; they rule out causes. Paste test results back exactly as they came out.
Why it works
Exploring several explanations before acting is the tree-of-thoughts idea applied to debugging. The test-then-update loop works like ReAct prompting: think, act, observe, repeat, which stops the guessing.