From Claude Kit
Systematic 4-phase debugging process (Root Cause Investigation → Pattern Analysis → Hypothesis & Testing → Implementation) for bugs, test failures, and unexpected behavior. Enforces root cause analysis before fixes.
How this skill is triggered — by the user, by Claude, or both
Slash command
/claude-kit:systematic-debuggingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Random fixes waste time and create new bugs. Quick patches mask underlying issues.
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:
npx claudepluginhub hex0xdeadbeef/claude-kit --plugin claude-kitEnforces systematic root cause investigation for bugs, test failures, and unexpected behavior through four phases: investigation, pattern analysis, hypothesis testing, and implementation.
Enforces 4-phase root cause investigation for bugs, errors, test failures, unexpected behavior, and technical issues before proposing fixes.
Enforces systematic root cause analysis before fixes for bugs, test failures, unexpected behavior, performance issues, and build failures.