Systematic debugging with 5-step loop for issues in spaces/[project]/. Use when encountering bugs, test failures, or unexpected behavior.
Systematic debugging using a 5-step loop: Research → Hypothesize → Implement → Test → Document.
/troubleshoot yourbench "tests failing after auth changes"
/troubleshoot yourbench 001 # Debug in context of issue
/troubleshoot coordinatr # General debugging session
┌─────────────────────────────────────────────┐
│ │
│ 1. Research → 2. Hypothesize → 3. Implement│
│ ↑ ↓ │
│ │ │ │
│ └──────── 5. Document ← 4. Test ──────│
│ │ │
│ ↓ │
│ (if not fixed, repeat) │
│ │
└─────────────────────────────────────────────┘
Before guessing, understand:
# Check existing research
Glob: resources/research/*.md
Glob: ideas/[project]/notes/research/*.md
# Search for similar issues in codebase
Grep: spaces/[project]/ for error message
# Check library docs via Context7
# WebSearch for error messages, known issues
Spawn research-specialist agent for:
Form ONE hypothesis:
Hypothesis: Query fires before auth state is set
Evidence:
- isLoading is true when query executes
- Error occurs only on initial load
- Works after manual refresh
Debug Plan:
1. Add console.log before query
2. Check auth state timing
3. Verify order of operations
Only one hypothesis at a time. Multiple theories = confusion.
Apply fix + add debugging:
// Add liberal debug logging
console.log('[Auth] State before query:', authState);
console.log('[Query] Executing with user:', user?.id);
// Implement the fix
if (!authState.isReady) {
console.log('[Query] Waiting for auth...');
return;
}
Validate the fix:
cd spaces/[project]
# Run specific tests
npm test -- --grep "auth"
# Run full suite
npm test
# Manual verification if needed
npm run dev
NEVER claim "fixed" without tests passing.
Update WORKLOG with findings:
## YYYY-MM-DD - Troubleshooting Loop 1
**Hypothesis**: Query fires before auth state is set
**Debug findings**:
- isLoading was true when query executed
- Auth state not propagating to component
- Race condition between auth init and query
**Implementation**: Added auth state check before query
**Result**: ✓ Fixed - 47/47 tests passing
**Gotcha**: Auth state needs explicit ready check, not just truthy
git checkout -- ./troubleshoot yourbench 001 "tests failing"
/implement when fixed/troubleshoot yourbench "login broken on Safari"
console.log('[Component] State:', data)/implement → (issue occurs) → /troubleshoot → /worklog → /implement
After fixing: