Claude-skill-registry debugging-mastery

Systematic debugging methodologies for finding and resolving complex bugs. Use PROACTIVELY when encountering difficult bugs, mysterious failures, or issues that resist simple fixes. MUST BE USED when debugging spans multiple files, involves race conditions, or has eluded initial investigation attempts.

install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/debugging-mastery" ~/.claude/skills/majiayu000-claude-skill-registry-debugging-mastery && rm -rf "$T"
manifest: skills/data/debugging-mastery/SKILL.md
source content

Debugging Mastery Skill

Overview

Key Principle: Root cause over symptom treatment. Never be satisfied with making symptoms disappear. Understand WHY the bug occurred.

When to Use

MUST USE when:

  • Bug spans multiple files or components
  • Involves race conditions or timing issues
  • Has eluded initial investigation (>30 minutes)
  • Symptoms are intermittent or hard to reproduce
  • Previous fix attempts have failed

SHOULD USE when:

  • Bug is in unfamiliar code
  • Error messages are unclear or misleading
  • Multiple hypotheses are possible

The DEBUG Framework

D → E → B → U → G
│   │   │   │   │
│   │   │   │   └─ GUARD: Fix and prevent regression
│   │   │   └───── UNCOVER: Find root cause (5 Whys)
│   │   └───────── BISECT: Narrow down location
│   └───────────── EXPLORE: Gather evidence
└───────────────── DEFINE: Expected vs Actual
PhasePurposeKey ActionOutput
DDefineState expected vs actualProblem statement
EExploreGather evidence, logs, recent changesEvidence list
BBisectNarrow down with binary searchSuspect location
UUncoverApply 5 Whys to find root causeRoot cause
GGuardFix + regression testVerified fix

D - Define the Problem

State clearly: Expected vs Actual behavior, reproduction steps, environment.

E - Explore Evidence

Collect: Full stack traces, surrounding logs, recent changes (

git log
), affected scope.

B - Bisect and Narrow

Use binary search: Comment out code halves, use

git bisect
, create minimal reproduction.

U - Uncover Root Cause

Apply 5 Whys: Ask "why" until you reach an actionable fix point. Verify: "If we fix this, would the bug have been prevented?"

G - Guard Against Recurrence

Fix the root cause (not symptom), add regression test, check for similar patterns elsewhere.

Full framework details: reference/debugging-techniques.md


Bug Classification Quick Reference

By Reproducibility

TypeDebugging Approach
100% ReproducibleStandard: breakpoints, logging
IntermittentLogging, state capture, timing analysis
RareDefensive logging, assertions, monitoring

By Bug Type

TypeSymptomsPrimary Technique
LogicWrong outputCode review, test cases
StateCorruption, unexpected valuesState logging
TimingRace conditions, deadlocksThread analysis
ResourceLeaks, exhaustionProfiling
IntegrationAPI mismatchesInterface comparison
Environment"Works on my machine"Config diff

Full classification: reference/bug-classification.md


Core Techniques

TechniqueWhen to UseKey Command
5 WhysUnclear causeAsk "why" 5 times
Git BisectRegression
git bisect start/good/bad
Binary SearchLarge codebaseComment out halves
IsolationComplex bugCreate minimal repro
Rubber DuckStuckExplain code line-by-line
Printf DebugNo debuggerStrategic print statements

Git Bisect Quick Reference

git bisect start
git bisect bad HEAD
git bisect good <known-good-commit>
# Test and mark: git bisect good OR git bisect bad
# Repeat until culprit found
git bisect reset

Full techniques: reference/debugging-techniques.md


Root Cause Analysis

The 5 Whys Process

Problem: API returns 500 error
  ↓ Why?
Database query failed
  ↓ Why?
Connection pool exhausted
  ↓ Why?
Connections not released
  ↓ Why?
Exception handler missing close()
  ↓ Why?
Template code lacked finally block
  ↓
ROOT CAUSE: Missing resource cleanup pattern

Stop when: You reach an actionable fix within your control.

Verify: "If we fix this, would the problem have been prevented?"

Full RCA guide: reference/root-cause-analysis.md


Subagent Integration

When to Escalate to
debugger
Subagent

  • Standard techniques haven't worked after 3 attempts
  • Bug requires multi-codebase analysis
  • Need advanced reasoning (Ultrathink methodology)
  • Complex distributed system issues

Handoff Protocol

Provide: Bug summary, DEBUG progress so far, files involved, hypotheses tested, specific request.

Iteration Tracking

The debugger subagent has a 5-iteration limit. Track attempts and escalate if needed.


Quality Checklist

Must Pass

  • Root cause identified (not just symptom)
  • Fix tested (reproduction steps no longer work)
  • Regression test added
  • No new bugs introduced

Should Pass

  • Similar patterns checked elsewhere
  • Documentation updated if process gap found
  • Code review complete

Anti-Patterns

Anti-PatternWhy It's BadBetter Approach
Shotgun debuggingRandom changesUse DEBUG framework
Fixing symptomsBug will returnFind root cause
Skipping reproductionCan't verify fixAlways reproduce first
Ignoring intermittentGets worseAdd logging, capture state
Debug in productionHigh riskReproduce locally
Assuming the obviousWastes timeVerify with tests
Not adding testsBug will recurAlways add regression test

Full examples: reference/anti-patterns.md


Templates

TemplatePurpose
templates/debugging-session.mdTrack entire session
templates/root-cause-report.mdDocument RCA
templates/hypothesis-log.mdTrack hypotheses

Quick DEBUG Template

## Quick DEBUG

**D - Define:**
Expected: [what should happen]
Actual: [what happens]
Steps: [to reproduce]

**E - Explore:**
Error: [full message]
Changed: [recent changes]
Scope: [who's affected]

**B - Bisect:**
Last working: [commit/date]
First broken: [commit/date]
Narrowed to: [component/file]

**U - Uncover:**
Why 1: [symptom reason]
Why 2: [deeper reason]
Why 3: [root cause]

**G - Guard:**
Fix: [what to change]
Test: [regression test]

Reference Documentation


Remember: A bug isn't fixed until you understand WHY it occurred and have prevented it from recurring.