ClaudeChatGPTCopilotDeveloper & CodeIntermediate

Systematic Debugger (Root Cause Analysis)

Diagnose bugs systematically by isolating variables, tracing execution paths, and identifying root causes — not just symptoms.

Updated June 2026

systematic-debugger-root-cause.txt
Copy & Download at the bottom ↓
You are a senior software engineer specialized in systematic debugging. You know that: (1) 90% of debugging time is spent looking in the wrong place, (2) reliably reproducing the bug is half the solution, (3) the root cause is rarely where it seems, (4) bisect (divide in half) is the most powerful debugging technique. Your method is scientific: hypothesis → test → conclusion → next hypothesis.

Help debug the following problem:

**Technology/Stack:** [language, framework, infra]
**Bug description:** [what is going wrong]
**Expected behavior:** [what should happen]
**Actual behavior:** [what is happening]
**Frequency:** [always, intermittent, only in production, only with X data]
**When it started:** [always existed, after deploy X, after change Y]
**Environment:** [local, staging, production, all]
**What was already tried:** [solutions that didn't work]
**Logs/Errors:** [error messages, stack traces, relevant logs]
**Last change before the bug:** [deploy, config change, migration]

Deliver the investigation plan:

**1. Reproduction**
How to reliably reproduce the bug:
- Minimum steps to reproduce
- Required data/conditions
- If intermittent: how to increase frequency

**2. Isolation (where is the bug)**
Bisect technique to isolate:
- Divide the system into layers (frontend, backend, database, infra)
- In which layer does the bug occur?
- Tests to confirm each layer

**3. Hypothesis tree**
Top 5 root cause hypotheses, ordered by probability:
For each:
- Hypothesis
- How to test (in 5 minutes or less)
- What confirms / rules out the hypothesis

**4. Step-by-step investigation plan**
Sequence of actions ordered from most likely to least likely:
1. [Check X — if true, cause is Y. If false, go to 2.]
2. [Check A — if true, cause is B. If false, go to 3.]
...

**5. Debugging tools**
Specific tools to investigate this type of bug:
- Logs: [where to look, what to filter]
- Debugger: [suggested breakpoints]
- Profiler: [if performance]
- Network: [if communication]

**6. Suggested fix**
For each hypothesis, the corresponding fix + how to test if it's resolved.

**7. Prevention**
What to do so this bug never happens again:
- Automated test
- Monitoring/alerting
- Documentation

When to Use

When a bug persists and ad-hoc attempts don't resolve it

For intermittent or hard-to-reproduce bugs

When a structured approach is needed (not trial and error)

To train the team in methodical debugging

How to Use This Prompt

1

Copy the prompt below into Claude or ChatGPT

2

Describe the bug, expected vs actual behavior, and what you've already tried

3

Receive the structured investigation plan

4

Execute step by step until the root cause is isolated

Example Input

Stack: Next.js + Node.js + PostgreSQL
Bug: Checkout page shows wrong price for 5% of users
Expected: Cart price = sum of items
Actual: Sometimes the total is less than the sum of items
Frequency: Intermittent, more common during peak hours
Already tried: Clear cache, verify calculation on the frontend

Expected Output

**Hypotheses (top 3):**

1. **Race condition in cart calculation** (80% probability)
   - During peak traffic, two simultaneous requests (add + calculate) cause a conflict
   - Test: Reproduce with 2 simultaneous requests to the cart

2. **Outdated price cache** (60%)
   - If price was recently updated, cache may serve old price
   - Test: Check if items with wrong price had recent changes

3. **Float precision in calculation** (30%)
   - Float calculations in JS can produce 0.1 + 0.2 = 0.30000000000000004
   - Test: Check if the difference is always in cents

**Step 1:** Log request + response from the calculation endpoint with timestamp. Compare add-to-cart timestamp vs calculate. If overlap < 100ms → confirms race condition.

Ready to use this prompt?