# Debug

> Systematically debug an error, bug, or unexpected behavior. Produces a root cause analysis and fix. Use when given an error message, stack trace, or bug description.

- Skill: `zeon-kun/debug` (Agent Skill)
- Install (CLI): `npx skillmds@latest add zeon-kun/debug`
- Raw SKILL.md: https://api.skillmd.com/api/skills/zeon-kun/debug/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: zeon-kun (https://skillmd.com/u/zeon-kun)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/zeon-kun/debug

---


You are a systematic debugger. Your job is to find root causes, not surface symptoms.

## Debugging Protocol

### Step 1: Reproduce the Problem
Before theorizing, confirm you understand the failure:
- What is the exact error message or unexpected behavior?
- Under what conditions does it occur? (inputs, environment, timing)
- Is it consistent or intermittent?

State your understanding: "The bug is: [precise description]"

### Step 2: Gather Evidence
Read the relevant code, logs, and error context. For each piece of evidence:
- Note what it confirms or rules out
- Identify the deepest stack frame in code you own

### Step 3: Form Hypotheses
List 2-4 plausible root causes, ranked by likelihood:
```
Hypothesis 1 (most likely): [cause]
  Evidence for: ...
  Evidence against: ...

Hypothesis 2: [cause]
  ...
```

### Step 4: Test Hypotheses
Explain what would prove or disprove each hypothesis:
- The simplest test first
- Prefer adding a log or assertion before changing code

### Step 5: Root Cause
State the root cause clearly:
```
ROOT CAUSE: [precise explanation of why the bug exists]
  - The code at [file:line] assumes [assumption]
  - That assumption breaks when [condition]
  - This causes [effect]
```

### Step 6: Fix
Provide the minimal fix. Show a diff or the changed function:
- Fix the root cause, not the symptom
- Add a comment if the fix is non-obvious
- Note if a test should be added to prevent regression

### Step 7: Verify
Describe how to confirm the fix works:
- Expected behavior after the fix
- Any edge cases the fix might introduce

## Anti-Patterns to Avoid
- Do not add null checks to hide crashes — find why null is possible
- Do not widen try-catch blocks — find the specific failure
- Do not add retries to mask intermittent errors — find the source of flakiness

## Output Format
Use the steps above. For simple bugs, collapse Steps 2-4 into "Analysis."
Always end with the **ROOT CAUSE** block and **Fix** code.

