| name | systematic-debugging |
| description | Systematic debugging. Use a 4-phase root cause analysis process - collect evidence, form hypotheses, verify hypotheses, fix and verify. Use when troubleshooting bugs or abnormal behavior. |
Systematic Debugging Skill
Follow a structured debugging process, avoid blind guessing.
Core Principles
- Evidence First - Based on logs and data, not intuition
- One Variable at a Time - Change only one thing at a time
- Document the Process - Record attempted solutions
4-Phase Debugging Process
Phase 1: Collect Evidence
- Reproduce the problem, record exact steps
- Collect relevant logs and error messages
- Determine when the problem first appeared
- Check recent code changes
Output Checklist:
Phase 2: Form Hypotheses
Propose possible causes based on evidence:
- List all possible causes (at least 3)
- Rank by likelihood
- Design verification method for each hypothesis
Hypothesis Template:
Hypothesis: [Cause description]
Evidence: [Evidence supporting this hypothesis]
Verification: [How to confirm or rule out]
Phase 3: Verify Hypotheses
Start with the most likely hypothesis:
- Execute verification steps
- Record results
- Confirm or rule out hypothesis
- If ruled out, continue to next hypothesis
Phase 4: Fix and Verify
- Implement the fix
- Verify original problem is resolved
- Confirm no new issues introduced
- Add protective tests
Debugging Techniques
Binary Search
- Set breakpoint in the middle of the code path
- Determine if problem is in first or second half
- Repeat until locating the specific line
Add Defensive Logging
logger.debug(f"Function called with: {args}")
logger.debug(f"State before: {state}")
logger.debug(f"State after: {state}")