Skip to content
Back to skills

Debugging

ASecurity

Find and fix a bug or regression with evidence, not guesses. Reproduce it with one command, shrink it, test ranked hypotheses, fix the root cause minimally and lock it in with a regression test. Use for anything broken, crashing, failing, flaky or slow.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 29, 2026
ai-agentsgotestingdebuggingrefactoringgitperformance

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 29, 2026

npx -y skills add k6w/baton --skill debugging --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Debugging?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Debugging
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/k6w-debugging/badge)](https://www.skillsdirectory.com/skills/k6w-debugging)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: debugging
description: "Find and fix a bug or regression with evidence, not guesses. Reproduce it with one command, shrink it, test ranked hypotheses, fix the root cause minimally and lock it in with a regression test. Use for anything broken, crashing, failing, flaky or slow."
keywords: [bug, debug, broken, crash, error, exception, failing, regression, flaky, slow, performance, stack trace, root cause, fix]
---
# Debugging

The rule: **no fix before a reproduction, no reproduction before a command.** A patch that was never
seen failing first is a guess, and guesses get reverted.

## 1. Build a loop that goes red

Spend most of your effort here. You need one command that:

- drives the real code path and checks **the exact symptom** that was reported (the wrong value, the
  message, the timing), not merely "it did not crash";
- gives the same verdict every run (for intermittent bugs: a known, high failure rate);
- runs in seconds and needs no human.

Run it and keep its output. If you catch yourself reading code to form a theory before this command
exists, stop and go back. Ideas for building one, from cheapest up, are in
`references/feedback-loops.md` (load with `load_skill("debugging", "references/feedback-loops.md")`).

If you truly cannot reproduce it, say so to the lead (`send_message`) with what you tried and what
you need (an environment, a log, a sample input). Do not continue on a hunch.

## 2. Shrink it

Remove inputs, config, steps and callers one at a time, rerunning after each cut. Stop when every
remaining piece matters: removing any one makes the loop pass. The small case becomes your
regression test and cuts the number of suspects.

## 3. Rank hypotheses, then test them

Write down three to five candidate causes before testing any, most likely first. Each must predict
something checkable: "if X is the cause, changing Y makes it pass and changing Z makes it worse". A
cause you cannot phrase that way is not a hypothesis yet.

Test one variable at a time:

- Prefer a debugger or REPL; then targeted logs at the boundary that separates two hypotheses.
- Tag every temporary log with a unique marker (e.g. `[dbg-7c1]`) so one grep removes them all.
- Regression between two known-good/known-bad states: bisect (`git bisect run <your command>`).
- Slowness: measure a baseline first (timer, profiler, query plan), then change one thing and measure
  again. Never optimise on intuition.

Write down which hypothesis the evidence confirmed and which it ruled out. That sentence goes in
your report.

## 4. Fix the root cause, minimally

- Grep every caller of the code you change. Fix the shared code once rather than patching one caller.
- Smallest change that removes the cause. No drive-by refactors in the same change (see `lean-code`
  for refactoring separately).
- Stay inside the files you were given or claimed (`claim_files`); if the cause lives elsewhere, tell
  the lead before touching it.

## 5. Lock it in

- Turn the shrunk case into a test at a seam that exercises the real bug pattern. Watch it **fail on
  the unfixed code**, apply the fix, watch it pass. (How to write that test well: `test-driven`.)
- If no honest seam exists (the bug needs a chain a unit test cannot reproduce), say so: that is a
  design finding worth reporting.
- Rerun the original, unshrunk loop. Run the full relevant suite and the task's acceptance command.

## 6. Clean up and report

- [ ] original repro now passes
- [ ] regression test fails without the fix, passes with it
- [ ] all tagged debug logs and scratch scripts removed (grep the marker)
- [ ] report to the lead: the cause in one or two sentences, the evidence, the fix, the test, the
      commands you ran with their results (see `shipping` for the hand-off format)

Never weaken, skip or delete a failing test to make a bug "go away".

Files in this skill

  • SKILL.md3.8 KB
  • references/feedback-loops.md1.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.