Skip to main content

Overview

The debug 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

string
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:
  1. Expected behavior - What should happen?
  2. Actual behavior - What happens instead?
  3. Error messages - Any errors? (paste or describe)
  4. Timeline - When did this start? Ever worked?
  5. 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 (--gaps mode)
  • Manual fix - User handles it

Usage Examples

New debug session

GSD gathers symptoms:
GSD spawns debugger:
  • 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

GSD lists active sessions:

Debug with checkpoints

Investigation process: Checkpoint 1: Need user verification
Checkpoint 2: Root cause found

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 evidence
  • hypothesis_formed - Testing specific theory
  • root_cause_found - Issue identified
  • fix_proposed - Solution ready
  • fixed - Fix implemented
  • verified - User confirmed fixed
  • resolved - 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:
The --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
  • quick - For simple fixes after debugging
  • plan-phase - For complex fixes needing full phase
  • add-todo - Capture debug findings as todos
  • health - Check for orphaned debug sessions