Overview
Thedebug command uses scientific method and subagent isolation to systematically investigate and fix issues. Debug state persists across context resets, allowing deep investigation without burning main context.
Syntax
Brief description of the issue to debug. If omitted, GSD lists active debug sessions to resume.
How It Works
Orchestrator Role (Main Session)
- Gathers symptoms from user
- Spawns gsd-debugger subagents
- Handles checkpoints
- Spawns continuation agents
- Keeps main context lean
Debugger Subagent (Fresh 200k Context)
- Deep file investigation
- Hypothesis formation and testing
- Evidence gathering
- Root cause analysis
- Fix implementation
- Writes to
.planning/debug/{slug}.md
Why Subagents?
Investigation burns context fast (reading files, forming hypotheses, testing). Fresh 200k context per investigation allows thorough debugging without clogging main session.Debug Workflow
1. Symptom Gathering
GSD asks structured questions:- Expected behavior - What should happen?
- Actual behavior - What happens instead?
- Error messages - Any errors? (paste or describe)
- Timeline - When did this start? Ever worked?
- Reproduction - How do you trigger it?
2. Investigation
Debugger agent:- Reads relevant files
- Forms hypotheses
- Tests assumptions
- Gathers evidence
- Eliminates possibilities
- Identifies root cause
3. Checkpoints
Agent returns to orchestrator when:- Root cause found → Offers fix options
- Needs user input → Asks for clarification
- Verification needed → User tests the fix
- Context reset needed → Saves state, spawns fresh agent
4. Resolution
Once root cause confirmed:- Fix now - Spawn fix subagent
- Plan fix - Create phase plan (
--gapsmode) - Manual fix - User handles it
Usage Examples
New debug session
- Investigates OAuth flow
- Checks state parameter handling
- Reviews recent changes
- Finds: State stored in memory, lost on server restart
- Root cause: Missing session persistence
Resume existing session
Debug with checkpoints
Debug File Structure
Debug File Format
Checkpoint Types
human-verify
need-input
context-reset
Debug Modes
find_and_fix (default)
- Investigate root cause
- Propose fix
- Implement fix (if user approves)
investigate_only
- Find root cause
- Document findings
- Don’t implement fix
Status Values
investigating- Actively gathering evidencehypothesis_formed- Testing specific theoryroot_cause_found- Issue identifiedfix_proposed- Solution readyfixed- Fix implementedverified- User confirmed fixedresolved- Session complete
When to Use
Perfect for
- Production issues
- Intermittent bugs
- Performance problems
- Integration failures
- “It worked yesterday” scenarios
- Complex reproduction steps
- Deep investigation needed
Not needed for
- Syntax errors (clear from error message)
- Known bugs with known fixes
- Simple logic errors
- Tasks better suited for
/gsd:quick
Integration with Planning
If fix is complex, route to phase planning:--gaps flag passes debug findings to planner.
Success Criteria
- ✅ Active sessions checked
- ✅ Symptoms gathered (if new)
- ✅ gsd-debugger spawned with context
- ✅ Checkpoints handled correctly
- ✅ Root cause confirmed before fixing
- ✅ Debug state persisted in file
- ✅ User knows resolution status
Related Commands
quick- For simple fixes after debuggingplan-phase- For complex fixes needing full phaseadd-todo- Capture debug findings as todoshealth- Check for orphaned debug sessions