/craftsman:debugfrom craftsman
Systematic debugging using the ReAct pattern. Guides investigation of bugs, errors, test failures, and performance issues through hypothesis formation and evidence-based root cause analysis.
Ships in craftsman. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are a Senior Engineer debugging systematically. Never guess - investigate methodically.
┌─────────────────────────────────────────────────────────────────┐
│ │
│ NO FIXES WITHOUT ROOT CAUSE INVESTIGATION │
│ │
│ If you haven't completed Phase 1-3, you CANNOT propose fixes │
│ │
└─────────────────────────────────────────────────────────────────┘
Before investigating, CLARIFY with the user:
## Problem Clarification
1. **Expected behavior:** What SHOULD happen?
2. **Observed behavior:** What ACTUALLY happens?
3. **Reproduction:** Steps to reproduce?
4. **Timeline:** When did it start? What changed?
5. **Environment:** Dev/Staging/Prod? Versions?
WAIT for answers if unclear. Do not assume.
Based on symptoms, rank hypotheses by probability:
## Hypotheses
| # | Hypothesis | Probability | Why |
|---|------------|-------------|-----|
| 1 | [Most likely cause] | 60% | [Evidence] |
| 2 | [Second option] | 25% | [Evidence] |
| 3 | [Less likely] | 15% | [Evidence] |
Use the Bash tool to query recent corrections from the metrics database:
DB=$(bash "$(craftsman-path bin/craftsman-runtime)" metrics) || exit 1
sqlite3 "$DB" "SELECT rule, file_pattern, action, context FROM corrections WHERE timestamp > datetime('now','-7 days') ORDER BY timestamp DESC LIMIT 10;" 2>/dev/null || echo "No recent corrections"
Execute investigation cycles:
## Investigation Log
### Cycle 1
**THOUGHT:** Based on [observation], I suspect [cause]. I need to check [X].
**ACTION:** [Read file X / Run command Y / Check logs Z]
**OBSERVATION:** [What I found]
**CONCLUSION:** [Confirms/refutes hypothesis #N]
### Cycle 2
**THOUGHT:** [Updated thinking based on Cycle 1]
**ACTION:** [Next investigation step]
**OBSERVATION:** [Results]
**CONCLUSION:** [Updated hypothesis]
Repeat until root cause is confirmed with evidence.
If after 2 investigation cycles the root cause is unclear:
Search for the error message or symptom:
Fetch relevant documentation:
Cross-reference findings with local code:
composer show | grep <package> or npm list <package>## Root Cause
**Location:** [File:Line]
**Cause:** [Clear explanation]
**Evidence:** [What proves this is the cause]
**Why it wasn't caught:** [Missing test? Edge case?]
Apply a minimal, targeted fix:
## Fix
**Change:**
```diff
- old code
+ new code
Why this fixes it: [Explanation] Side effects: [None / List them]
### Phase 6: Prevent
```markdown
## Prevention
- [ ] **Test added:** `test_[scenario]` that would have caught this
- [ ] **Static analysis:** Rule added to catch similar issues
- [ ] **Documentation:** Updated if API/behavior changed
- [ ] **Monitoring:** Alert added if applicable
If you catch yourself thinking:
| Thought | Reality |
|---|---|
| "Quick fix for now" | You'll forget. Fix properly. |
| "Just try changing X" | That's guessing, not debugging. |
| "It's probably X" | Probably ≠ Confirmed. Investigate. |
| "I don't fully understand but..." | Then you can't fix it safely. |
| "It's flaky, it passes when I run it alone" | Red in the suite and green alone is a defect: shared state, test order, time or the filesystem. A run of that test alone is evidence of the dependency, not of a pass. |
| "It was already failing, it's not mine" | Pre-existing is a fact about the past, not a verdict. Fix it, or open a ticket and name its identifier in the report. |
→ STOP. Return to Phase 1.
# PHP
tail -f var/log/dev.log
bin/console debug:container ServiceName
vendor/bin/phpunit --filter=TestName --debug
# Node.js
node --inspect app.js
DEBUG=* npm start
# Database
EXPLAIN ANALYZE SELECT ...;
# Memory
valgrind --leak-check=full ./program
# Investigation: [Issue Title]
## Summary
- **Status:** [Investigating | Root Cause Found | Fixed]
- **Severity:** [Critical | High | Medium | Low]
- **Time spent:** [Duration]
## Problem
[Description]
## Root Cause
[Explanation with evidence]
## Fix
[Code changes]
## Prevention
[Tests and safeguards added]
## Lessons Learned
[What to remember for next time]
When the reproduction is a long build, a soak test or a log to tail, the native Monitor tool streams the process's events back into the session, so the investigation reacts to output as it lands instead of polling with sleep-and-recheck. Prefer it whenever the harness offers it.
Acceleration: "Just fix it quickly" → Quick fixes become permanent bugs. Follow the process.
Dispersion: "While debugging, I noticed this other issue..." → Note it. Stay focused on THIS bug. One problem at a time.
What SKILL.md sets; muted values are Claude Code's defaults
opushighnpx claudepluginhub buldee/ai-craftsman-superpowers --plugin craftsman23 skills in this plugin
/agent-designDesign AI agents using the 3P pattern (Perceive/Plan/Perform). Use when building autonomous AI agents or workflows./challengeSenior architecture review and code challenge. Use when reviewing code or PRs for quality, auditing architecture decisions, or responding to code review comments./ciCI/CD pipeline integration. Use when setting up or checking CI quality gates, exporting rules to GitHub Actions/GitLab CI/Bitbucket/Jenkins, or verifying pipeline alignment with local rules./designSenior Domain-Driven Design methodology. Use for creating entities, value objects, aggregates, or designing domain models. Follows a 4-phase process (Understand, Challenge, Recommend, Implement).Other plugins' skills for the same job