Investigate and diagnose issues without necessarily fixing them
Investigates bugs and errors to identify root causes and gather evidence for fixes.
/plugin marketplace add thebushidocollective/han/plugin install core@hanhan-core:debug - Investigate and diagnose issues without necessarily fixing them
/debug [arguments]
Investigate and diagnose issues without necessarily fixing them
Investigate and diagnose bugs, errors, or unexpected behavior to understand what's happening and why.
Use the debugging skill from bushido to:
Use /debug when:
Use /fix when:
1. **Hypothesis:** The database query is slow
**Test:** Add query timing logs
**Result:** Query takes 2ms, not the issue
2. **Hypothesis:** Network latency is high
**Test:** Add network timing logs
**Result:** Network takes 3 seconds - FOUND IT
1. Comment out second half of function
- Bug still happens → It's in first half
2. Comment out second quarter
- Bug disappears → It's in third quarter
3. Continue narrowing until isolated
# Find which commit introduced the bug
git bisect start
git bisect bad # Current version has bug
git bisect good v1.0.0 # This version was working
# Git checks out middle commit
npm test # Test if bug exists
git bisect good/bad # Mark accordingly
# Repeat until bug-introducing commit found
// Strategic logging
console.log('1. Starting process')
console.log('2. Input value:', input)
console.log('3. After transformation:', transformed)
console.log('4. Before API call')
const result = await api.call()
console.log('5. API result:', result)
console.log('6. Final output:', output)
Explain the problem out loud (or write it down) step by step. Often this reveals the issue.
# Application logs
tail -f logs/app.log
# Filter for errors
grep ERROR logs/app.log
# Search for specific request
grep "request_id=abc123" logs/app.log
// Browser
debugger; // Execution pauses here
// Node.js
node --inspect app.js
// Then attach Chrome DevTools
function processData(data) {
console.trace('processData called') // Shows call stack
// ...
}
# Browser DevTools > Network tab
# Look for:
# - Failed requests (4xx, 5xx)
# - Slow requests (> 1s)
# - Large payloads
# Browser DevTools > Performance tab
# Record interaction, look for:
# - Long tasks (> 50ms)
# - Layout thrashing
# - Memory leaks
// React DevTools - inspect component state
// Redux DevTools - inspect store state
// Vue DevTools - inspect component data
// Or add logging
useEffect(() => {
console.log('Current state:', state)
}, [state])
## Investigation: [Issue description]
### Symptoms
[What's happening that's wrong?]
### Evidence
- Error message: [exact text]
- When it happens: [conditions]
- Frequency: [always/sometimes/rarely]
- Affected users: [all/some/specific group]
### Reproduction Steps
1. [Step 1]
2. [Step 2]
3. [Observe error]
### Investigation Timeline
**Hypothesis 1:** [What I thought might be wrong]
- Tested by: [What I did to test]
- Result: [What I found]
- Conclusion: [Ruled out / Confirmed]
**Hypothesis 2:** [Next theory]
- Tested by: [What I did]
- Result: [What I found]
- Conclusion: [Ruled out / Confirmed]
### Root Cause
[What's actually causing the issue]
**Evidence:**
- [Log showing the problem]
- [Stack trace pointing to source]
- [Data showing the pattern]
### Impact
- Severity: [Critical/High/Medium/Low]
- Scope: [How many users/scenarios affected]
- Workaround: [Any temporary solutions]
### Next Steps
- [ ] [What should be done to fix]
- [ ] [Any additional investigation needed]
- [ ] [Related issues to check]
When the user says:
Frontend:
Backend:
Database:
"It doesn't work":
"It's slow":
"It works locally but not in production":
"It works sometimes":