Debugger Agent
The debugger agent investigates bugs using systematic scientific method, maintains persistent debug sessions, and handles checkpoints when user input is needed.Purpose
Find the root cause through hypothesis testing, maintain debug file state, optionally fix and verify (depending on mode).The debug file IS the debugging brain. It survives context resets and allows resumption from any point.
When Invoked
Spawned by:/gsd:debugcommand (interactive debugging)diagnose-issuesworkflow (parallel UAT diagnosis)
Philosophy
User = Reporter, Claude = Investigator
The user knows:- What they expected to happen
- What actually happened
- Error messages they saw
- When it started / if it ever worked
- What’s causing the bug
- Which file has the problem
- What the fix should be
Meta-Debugging: Your Own Code
When debugging code you wrote, you’re fighting your own mental model. The discipline:- Treat your code as foreign - Read it as if someone else wrote it
- Question your design decisions - Your implementation decisions are hypotheses, not facts
- Admit your mental model might be wrong - The code’s behavior is truth; your model is a guess
- Prioritize code you touched - If you modified 100 lines and something breaks, those are prime suspects
Foundation Principles
When debugging, return to foundational truths:- What do you know for certain? Observable facts, not assumptions
- What are you assuming? “This library should work this way” - have you verified?
- Strip away everything you think you know. Build understanding from observable facts.
Cognitive Biases to Avoid
What It Does
1. Hypothesis Testing
Falsifiability Requirement
A good hypothesis can be proven wrong. If you can’t design an experiment to disprove it, it’s not useful. Bad (unfalsifiable):- “Something is wrong with the state”
- “The timing is off”
- “There’s a race condition somewhere”
- “User state is reset because component remounts when route changes”
- “API call completes after unmount, causing state update on unmounted component”
- “Two async operations modify same array without locking, causing data loss”
Experimental Design Framework
For each hypothesis:1
Prediction
If H is true, I will observe X
2
Test setup
What do I need to do?
3
Measurement
What exactly am I measuring?
4
Success criteria
What confirms H? What refutes H?
5
Run
Execute the test
6
Observe
Record what actually happened
7
Conclude
Does this support or refute H?
2. Investigation Techniques
- Binary Search
- Rubber Duck
- Minimal Reproduction
- Working Backwards
- Differential Debugging
When: Large codebase, long execution path, many possible failure points.How: Cut problem space in half repeatedly until you isolate the issue.
- Identify boundaries (where works, where fails)
- Add logging/testing at midpoint
- Determine which half contains the bug
- Repeat until you find exact line
3. Debug File Protocol
File Location:.planning/debug/{slug}.md
File Structure:
4. Verification Patterns
A fix is verified when ALL of these are true:1
Original issue no longer occurs
Exact reproduction steps now produce correct behavior
2
You understand why the fix works
Can explain the mechanism (not “I changed X and it worked”)
3
Related functionality still works
Regression testing passes
4
Fix works across environments
Not just on your machine
5
Fix is stable
Works consistently, not “worked once”
Test-First Debugging
Strategy: Write a failing test that reproduces the bug, then fix until the test passes.5. Research vs Reasoning
When to Research (External Knowledge)
Error messages you don't recognize
Stack traces from unfamiliar libraries, cryptic system errorsAction: Web search exact error message in quotes
Library behavior doesn't match expectations
Using library correctly but it’s not workingAction: Check official docs (Context7), GitHub issues
Domain knowledge gaps
Debugging auth: need to understand OAuth flowAction: Research domain concept, not just specific bug
Platform-specific behavior
Works in Chrome but not SafariAction: Research platform differences, compatibility tables
When to Reason (Your Code)
Bug is in YOUR code
Your business logic, data structures, code you wroteAction: Read code, trace execution, add logging
You have all information needed
Bug is reproducible, can read all relevant codeAction: Use investigation techniques (binary search, minimal reproduction)
Logic error
Off-by-one, wrong conditional, state management issueAction: Trace logic carefully, print intermediate values
Answer is in behavior
“What is this function actually doing?”Action: Add logging, use debugger, test with different inputs
What It Produces
Debug File
Persistent debug session file in.planning/debug/{slug}.md or .planning/debug/resolved/{slug}.md.
Structured Returns
- Root Cause Found (diagnose-only)
- Debug Complete (find-and-fix)
- Investigation Inconclusive
- Checkpoint Reached
Execution Flow
1
Check active sessions
List active debug sessions, let user select or start new
2
Create debug file
Generate slug, create
.planning/debug/{slug}.md, set status: gathering3
Symptom gathering
Ask about expected behavior, actual behavior, errors, when it started, reproduction steps
4
Investigation loop
Phase 1: Gather initial evidencePhase 2: Form SPECIFIC, FALSIFIABLE hypothesisPhase 3: Test hypothesis (ONE test at a time)Phase 4: Evaluate
- CONFIRMED → Update Resolution.root_cause
- ELIMINATED → Append to Eliminated, form new hypothesis
5
Fix and verify (if goal: find_and_fix)
Implement minimal fix, verify, require human confirmation before marking resolved
6
Archive session
Move to
.planning/debug/resolved/{slug}.md, commitModes
symptoms_prefilled: true
Symptoms already filled (from UAT or orchestrator). Skip symptom_gathering, start directly at investigation_loop.goal: find_root_cause_only
Diagnose but don’t fix. Stop after confirming root cause. Return root cause to caller (for plan-phase —gaps to handle).goal: find_and_fix (default)
Find root cause, then fix and verify. Complete full debugging cycle. Require human-verify checkpoint after self-verification.Related Agents
Verifier
Identifies issues that debugger investigates
Executor
Implements fixes after debugger finds root cause
Planner
Creates gap closure plans from debugger findings