/claude-kit:systematic-debuggingfrom Claude Kit
Systematic 4-phase debugging process (Root Cause → Pattern Analysis → Hypothesis → Implementation) for bugs, test failures, and unexpected behavior. Enforces root cause investigation before any fix.
Ships in Claude Kit. 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.
Random fixes waste time and create new bugs. Quick patches mask underlying issues.
Core principle: ALWAYS find root cause before attempting fixes. Symptom fixes are failure.
Violating the letter of this process is violating the spirit of debugging.
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
If you haven't completed Phase 1, you cannot propose fixes.
Use for ANY technical issue:
Use this ESPECIALLY when:
Don't skip when:
You MUST complete each phase before proceeding to the next.
BEFORE attempting ANY fix:
Read Error Messages Carefully
go test -v -run TestXxx ./... to see full outputReproduce Consistently
go test -count=1 -run TestXxx ./... (disables cache, ensures fresh run)Check Recent Changes
git diff HEAD~1, recent commitsGather Evidence in Multi-Component Systems
WHEN system has multiple components (handler → service → repository):
BEFORE proposing fixes, add diagnostic instrumentation:
For EACH component boundary:
- Log what data enters component
- Log what data exits component
- Verify context/config propagation
- Check state at each layer
Run once to gather evidence showing WHERE it breaks
THEN analyze evidence to identify failing component
THEN investigate that specific component
Example (Go multi-layer diagnostic):
// Layer 1: Handler
func (h *UserHandler) GetUser(w http.ResponseWriter, r *http.Request) {
id := chi.URLParam(r, "id")
slog.Debug("handler.GetUser", "id", id)
// Layer 2: Service
user, err := h.svc.GetUser(r.Context(), id)
slog.Debug("service.GetUser result", "id", id, "err", err)
}
// Layer 3: Repository (add temporarily in Find method)
// slog.Debug("repo.Find called", "id", id, "stack", string(debug.Stack()))
This reveals: Which layer receives invalid data
Trace Data Flow
WHEN error is deep in call stack:
See root-cause-tracing.md for the complete backward tracing technique.
Quick version:
Find the pattern before fixing:
Find Working Examples
grep -r "func.*GetUser" ./internal/ to find similar functionsCompare Against References
Identify Differences
Understand Dependencies
Scientific method:
Form Single Hypothesis
Test Minimally
go test -v -run TestXxx -count=1 ./...Verify Before Continuing
When You Don't Know
Fix the root cause, not the symptom:
Create Failing Test Case
go test -v -run TestXxx -count=1 ./... must FAIL before fixgo test -race -run TestXxx ./...Implement Single Fix
Verify Fix
go test -v -run TestXxx -count=1 ./... passes?go test ./... — no other tests broken?If Fix Doesn't Work
If 3+ Fixes Failed: Question Architecture
Pattern indicating architectural problem:
STOP and question fundamentals:
Discuss with your human partner before attempting more fixes
If you catch yourself thinking:
ALL of these mean: STOP. Return to Phase 1.
If 3+ fixes failed: Question the architecture (see Phase 4.5)
| Excuse | Reality |
|---|---|
| "Issue is simple, don't need process" | Simple issues have root causes too. Process is fast for simple bugs. |
| "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check thrashing. |
| "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |
| "I'll write test after confirming fix works" | Untested fixes don't stick. Test first proves it (use tdd-rules skill). |
| "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |
| "Reference too long, I'll adapt the pattern" | Partial understanding guarantees bugs. Read it completely. |
| "I see the problem, let me fix it" | Seeing symptoms ≠ understanding root cause. |
| "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. Question pattern, don't fix again. |
"go test is slow, I'll skip verification" | Unverified fixes are not fixes. Run go test -count=1 -run TestXxx ./.... |
Auto-trigger: Load this skill when tests fail 3x consecutively in /coder VERIFY.
Entry point: Start at Phase 1 with the failing go test -v ./... output as evidence.
Exit: Once root cause found and single fix applied, return to VERIFY:
go vet ./... && make fmt && make lint && make test
If investigation reveals architectural issue → escalate to user (do NOT attempt Fix #4).
| Phase | Key Activities | Success Criteria |
|---|---|---|
| 1. Root Cause | Read errors, reproduce, check changes, gather evidence | Understand WHAT and WHY |
| 2. Pattern | Find working examples, compare | Identify differences |
| 3. Hypothesis | Form theory, test minimally | Confirmed or new hypothesis |
| 4. Implementation | Create test, fix, verify | Bug resolved, tests pass |
root-cause-tracing.md — Trace bugs backward through call stack to find original triggerdefense-in-depth.md — Add validation at multiple layers after finding root causecondition-based-waiting.md — Replace arbitrary time.Sleep with condition pollingRelated skills:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
debugging, root-cause-analysis, test-failure, bug-fix, iron-law
9 skills in this plugin
/cavemanProject-local terse-output mode for /workflow pipeline. Cuts Messages token cost via concise prose. Loaded only at SessionStart by .claude/scripts/caveman-activate.sh — not auto-invoked on user prompts.
/code-review-rulesReview standards for code-reviewer agent. Loaded by explicit Read in the code-reviewer STARTUP step (disable-model-invocation blocks subagent preload). Covers: severity classification (BLOCKER/MAJOR/MINOR/NIT), decision matrix (APPROVED/APPROVED_WITH_COMMENTS/CHANGES_REQUESTED), auto-escalation rules, grep search patterns for automated checks./coder-rulesImplementation rules and patterns for /coder command. Load at /coder startup (step 0) or when /workflow enters Phase 3. Covers: 6 CRITICAL rules (plan-only, import matrix, clean domain, no log+return, tests pass, comment quality), the comment policy for source files, evaluate protocol (PROCEED/REVISE/RETURN), dependency-ordered implementation.npx claudepluginhub hex0xdeadbeef/claude-kit --plugin claude-kitOther plugins' skills for the same job