agentleFS
xcrrrxcrrr/claude-skills/skills/coding/debugger/SKILL.md

debugger

Skill6 starsChanged 8 months agoMITView on GitHub

Use this skill when tracking down a bug, understanding an error message, or diagnosing unexpected behavior in code. Trigger phrases: 'this is broken', 'I'm getting an error', 'why does this crash', 'help me debug'. Not for code review of working code or designing new features.

32 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use security-engineer, planner and 2 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • belokonmSkill

    security-engineer

    Expert in infrastructure security, DevSecOps pipelines, and zero-trust architecture design.

    Also in 4 projects that use this

  • am-willSkill

    planner

    Create comprehensive, phased implementation plans with sprints and atomic tasks. Use when user says: "make a plan", "create a plan", "plan this out", "plan the implementation", "help me plan", "design a plan", "draft a plan", "write a plan", "outline the steps", "break this down into tasks", "what's the plan for", or any similar planning request. Also triggers on explicit "/planner" or "/plan" commands.

    Also in 3 projects that use this

  • AnthropicSkill

    system-design

    Design systems, services, and architectures. Trigger with "design a system for", "how should we architect", "system design for", "what's the right architecture for", or when the user needs help with API design, data modeling, or service boundaries.

    Also in 3 projects that use this

  • CloudflareSkill

    security-audit

    Security guidance and vulnerability review for codebases, APIs, services, CLI tools, libraries, and daemons. Use for security questions, focused reviews, vulnerability research, security audits, or pen tests. Run the complete workflow only for explicit codebase audit or pen-test requests, full/comprehensive/end-to-end reviews, or requested report artifacts.

    Also in 3 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

22 rules. 0 are common, 21 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 29 edited versions we read keep these.

  • 21

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read the stack trace bottom-up: the bottom frame is usually where the error originated.

    line 51
  2. Distinctive:

    Read it top-down to see how it propagated to the surface.

    line 52
  3. Distinctive:

    Look for your own code in the stack — frames from frameworks are usually symptoms, not causes.

    line 54
  4. Distinctive:

    Use binary search: comment out half the code and see if the error persists.

    line 57
  5. Distinctive:

    Add logging/print statements at key boundaries to trace values.

    line 58
  6. Distinctive:

    Use git bisect if the bug appeared recently to find the introducing commit.

    line 59
  7. Distinctive:

    Write a failing unit test that captures the bug — this isolates it and becomes your regression guard.

    line 60
  8. Distinctive:

    Consider: wrong type, off-by-one, uninitialized variable, wrong variable, mutation side effect, async race condition, missing null check.

    line 65
  9. Distinctive:

    Add a targeted assertion or log to confirm or deny the hypothesis before changing code.

    line 68
  10. Distinctive:

    Run the reproduction case with the added diagnostic.

    line 69
  11. Distinctive:

    If the hypothesis is disproved, form a new one — do not change code until you have confirmed the root cause.

    line 70
  12. Distinctive:

    Run the full test suite to confirm no regression.

    line 75
  13. Distinctive:

    Add a regression test if one doesn't exist.

    line 76
  14. Distinctive:

    Write a clear commit message: what changed, why, and a reference to the issue.

    line 79
  15. Distinctive:

    Leave a comment in the code if the fix is non-obvious.

    line 80
  16. Very specific:

    Use the functional updater form of setCount which receives the latest state value, not the closed-over value:

    line 182
  17. Distinctive:

    Never change code to fix a bug until you have confirmed the root cause — you may fix a symptom and leave the root cause in place

    line 203
  18. Distinctive:

    Always write a failing test first that captures the bug before fixing it

    line 204
  19. Distinctive:

    Use the scientific method: one hypothesis, one experiment, one result at a time

    line 205
  20. Distinctive:

    Keep a short "debugging journal" for complex bugs to avoid revisiting dead ends

    line 206
  21. Distinctive:

    Check assumptions at every step: types, values, order of execution, scope

    line 208
  22. Distinctive:

    Not adding a regression test after fixing, allowing the bug to recur

    line 216

“Common” is measured: kept by at least 6 in 10 of the 29 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Debugger

Overview

The Debugger skill applies a systematic five-step methodology — Reproduce → Isolate → Hypothesize → Test → Fix — to diagnose and resolve software bugs efficiently. It covers reading stack traces, identifying common error patterns across languages, and using targeted strategies to narrow down root causes. Rather than guessing, this skill drives debugging as a structured investigation that produces a verified fix and prevents regression.

When to Use

  • You have an error message, stack trace, or crash report to analyze
  • Code produces unexpected output or behavior
  • A test is failing and you don't know why
  • An intermittent bug needs to be made reproducible
  • You need to understand what a piece of code is actually doing vs. what you thought it did

When NOT to Use

  • You want a general code quality review (use the code-reviewer skill)
  • You are designing a new system or feature from scratch
  • You need to optimize a working system for performance (use a profiler workflow)
  • The issue is an environment/infrastructure problem (networking, DNS, containers) rather than code logic

Quick Reference

StepAction
ReproduceConfirm the bug exists with a minimal, reliable test case
IsolateNarrow down which file, function, or line causes it
HypothesizeForm a specific, falsifiable theory about the root cause
TestProve or disprove the hypothesis with targeted experiments
FixApply the smallest correct change; verify and add a regression test
Stack tracesRead bottom-up (root cause) then top-down (propagation)
KeyError/IndexErrorCheck key existence before access; validate collection lengths
TypeErrorInspect actual types at runtime, not assumed types
Off-by-oneTrace loop bounds; use closed/open interval notation
Async bugsLog execution order; check promise chaining and race conditions

Instructions

  1. Reproduce the bug reliably
    • Get the exact steps to reproduce. If you can't reproduce it, you can't verify your fix.
    • Reduce the reproduction case to the smallest possible input that still triggers the bug.
    • Identify whether the bug is deterministic, intermittent, or environment-specific.
    • Record: OS, language/runtime version, relevant library versions, inputs, expected output, actual output.
  2. Read the error message and stack trace carefully
    • Read the stack trace bottom-up: the bottom frame is usually where the error originated.
    • Read it top-down to see how it propagated to the surface.
    • Extract: error type, error message, file name, line number, function name.
    • Look for your own code in the stack — frames from frameworks are usually symptoms, not causes.
  3. Isolate the failure
    • Use binary search: comment out half the code and see if the error persists. Narrow to a section, then a function, then a line.
    • Add logging/print statements at key boundaries to trace values.
    • Use git bisect if the bug appeared recently to find the introducing commit.
    • Write a failing unit test that captures the bug — this isolates it and becomes your regression guard.
  4. Hypothesize the root cause
    • Form a specific, falsifiable hypothesis: "The bug occurs because X is None when the function expects a string."
    • List all assumptions the code makes and check each one.
    • Consider: wrong type, off-by-one, uninitialized variable, wrong variable, mutation side effect, async race condition, missing null check.
  5. Test the hypothesis
    • Add a targeted assertion or log to confirm or deny the hypothesis before changing code.
    • Run the reproduction case with the added diagnostic.
    • If the hypothesis is disproved, form a new one — do not change code until you have confirmed the root cause.
  6. Apply the fix
    • Make the minimal change that correctly addresses the root cause (not just the symptom).
    • Re-run the reproduction case to confirm the bug is gone.
    • Run the full test suite to confirm no regression.
    • Add a regression test if one doesn't exist.
  7. Document the fix
    • Write a clear commit message: what changed, why, and a reference to the issue.
    • Leave a comment in the code if the fix is non-obvious.

Examples

Example 1: Debug a Python KeyError

Input:

Traceback (most recent call last):
  File "app.py", line 42, in process_order
    discount = DISCOUNT_MAP[user['tier']]
KeyError: 'gold'

Code:

DISCOUNT_MAP = {
    'silver': 0.05,
    'platinum': 0.20,
}

def process_order(user, order_total):
    discount = DISCOUNT_MAP[user['tier']]
    return order_total * (1 - discount)

Output:

Step 1 – Read the trace The error is on line 42: DISCOUNT_MAP[user['tier']]. The key 'gold' does not exist in DISCOUNT_MAP.

Step 2 – Hypothesis DISCOUNT_MAP is missing the 'gold' tier that some users have. The code assumes the map is exhaustive.

Step 3 – Confirm

print(user['tier'])  # prints 'gold'
print(DISCOUNT_MAP.keys())  # dict_keys(['silver', 'platinum'])

Step 4 – Fix Option A — add the missing key:

DISCOUNT_MAP = {
    'silver': 0.05,
    'gold': 0.10,
    'platinum': 0.20,
}

Option B — use a safe default for unknown tiers:

discount = DISCOUNT_MAP.get(user['tier'], 0.0)

Regression test:

def test_process_order_unknown_tier():
    user = {'tier': 'bronze'}
    result = process_order(user, 100.0)
    assert result == 100.0  # no discount for unknown tier

Example 2: Debug a React state update issue

Input:

function Counter() {
  const [count, setCount] = useState(0);

  function handleTripleClick() {
    setCount(count + 1);
    setCount(count + 1);
    setCount(count + 1);
  }

  return <button onClick={handleTripleClick}>Count: {count}</button>;
}

Symptom: clicking the button only increments count by 1, not 3.

Output:

Step 1 – Reproduce The button increments count from 0 to 1, never to 3, regardless of how many times setCount is called in the handler.

Step 2 – Hypothesis React batches state updates within an event handler. All three calls to setCount(count + 1) read the same stale closure value of count (e.g., 0), so all three calls set count to 1.

Step 3 – Confirm Add a log:

function handleTripleClick() {
  console.log('before:', count); // logs 0 all three times
  setCount(count + 1);
  setCount(count + 1);
  setCount(count + 1);
}

Step 4 – Fix Use the functional updater form of setCount which receives the latest state value, not the closed-over value:

function handleTripleClick() {
  setCount(prev => prev + 1);
  setCount(prev => prev + 1);
  setCount(prev => prev + 1);
}

Now each call receives the result of the previous update, so count correctly reaches 3.

Regression test:

test('triple click increments by 3', async () => {
  render(<Counter />);
  const btn = screen.getByRole('button');
  await userEvent.click(btn);
  expect(btn).toHaveTextContent('Count: 3');
});

Best Practices

  • Never change code to fix a bug until you have confirmed the root cause — you may fix a symptom and leave the root cause in place
  • Always write a failing test first that captures the bug before fixing it
  • Use the scientific method: one hypothesis, one experiment, one result at a time
  • Keep a short "debugging journal" for complex bugs to avoid revisiting dead ends
  • print/console.log debugging is valid — use it freely, then clean up
  • Check assumptions at every step: types, values, order of execution, scope

Common Mistakes

  • Fixing symptoms instead of root causes (the bug returns in a different form)
  • Changing multiple things at once and not knowing which change fixed it
  • Assuming the bug is in your code when it's in a library (or vice versa)
  • Skipping reproduction and trying to reason about the bug abstractly
  • Forgetting to check environment differences (local vs CI, dev vs prod, Python 3.10 vs 3.11)
  • Not adding a regression test after fixing, allowing the bug to recur

Tips & Tricks

  • git bisect is the fastest way to find a regression in a large commit history
  • Rubber duck debugging: explain the bug out loud step by step — the explanation often reveals the answer
  • For async/concurrency bugs, add timestamps to logs to see actual execution order
  • Browser DevTools "Break on exception" or Python's pdb.post_mortem() drops you into the frame where the error occurred
  • For intermittent bugs, log everything and search for patterns across multiple occurrences

Related Skills

  • code-reviewer
  • test-writer
  • security-auditor

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.