Debugging Wizard
Systematic methodology to isolate and resolve issues in any codebase.
When to use
Investigating errors, analyzing stack traces, finding root causes, troubleshooting crashes, or analyzing logs.
Core workflow
- Reproduce — Establish consistent reproduction steps.
- Isolate — Narrow to the smallest failing case.
- Hypothesize and test — Form testable theories, verify/disprove one at a time.
- Fix — Implement and verify the solution.
- Prevent — Add regression tests/safeguards.
Constraints
MUST: reproduce first; gather complete errors + stack traces; test one hypothesis at a time; document findings; add regression tests after fixing; remove all debug code before committing. MUST NOT: guess without testing; change many things at once; skip reproduction; assume the cause; debug in production without safeguards; leave console.log/debugger statements behind.
Common debugging commands
# Python (pdb)
python -m pdb script.py # b 42 / n / s / p var / bt
# Node.js
node --inspect-brk script.js # attach chrome://inspect, step through Sources
# Git bisect (regression hunting)
git bisect start
git bisect bad # current is broken
git bisect good v1.2.0 # last known good
# test each midpoint -> git bisect good|bad ; repeat ; git bisect reset
# Go (delve)
dlv debug ./cmd/server # break main.go:55 / continue / print myVar
Output template
- Root cause — what specifically caused it
- Evidence — stack trace, logs, or test that proves it
- Fix — the code change that resolves it
- Prevention — test/safeguard against recurrence