← All skills
Rewrite · 7 sources citedProtocolSoftware & games

systematic-debugging

Find the root cause of a bug before changing any code.

Use it when
Whenever something is already broken or behaving unexpectedly - a failing or flaky test, crash, exception, stack trace, regression, build break, performance problem or integration failure - when the user says "debug this", "why is this failing", "I can't reproduce it" or "it only fails sometimes", and especially when guessing at a fix is tempting. Covers building a repeatable reproduction, ranking causes by what they predict, one-change tests, and a regression test at the right seam. Not for writing new features or reviewing code that works.
What kind it is
A written method: it lays out how the work is done and what to check along the way.
Size
2,165 words. The whole text loads when the skill fires; only the 98-word description is always loaded.
Starts with
Ask for the job it describes.

How it is organised

What’s inside

The skill’s top-level sections, in order. The bar is each section’s share of the 2,165 words, so you can see where the weight sits before reading.

  1. 1The rule128 words
  2. 2Keep secrets out of what you show and log85 words
  3. 3Four phases1,205 words
  4. 4Three failed fixes means look at the design70 words
  5. 5Techniques for particular situations114 words
  6. 6When you cannot finish205 words
  7. 7Stop and go back to phase 1 if you catch yourself thinking140 words
  8. 8Quick reference118 words

How it runs

4 phases, in order

The skill names these phases in its headings. Open the text for what each one asks of you and what it holds back until you have answered.

  1. find the cause
  2. compare with what works
  3. rank causes, then test one
  4. fix the cause

The skill itself

Read it before you install it

systematic-debugging/SKILL.md · 2,165 wordsDownloadSkill on GitHub ↗
---
name: systematic-debugging
description: Find the root cause of a bug before changing any code. Use whenever something is already broken or behaving unexpectedly - a failing or flaky test, crash, exception, stack trace, regression, build break, performance problem or integration failure - when the user says "debug this", "why is this failing", "I can't reproduce it" or "it only fails sometimes", and especially when guessing at a fix is tempting. Covers building a repeatable reproduction, ranking causes by what they predict, one-change tests, and a regression test at the right seam. Not for writing new features or reviewing code that works.
license: MIT
---

# Systematic debugging

When something breaks, the fastest-feeling move is to edit the line where the error appears and run it again. That usually fixes where the problem shows up, not where it starts. The symptom goes quiet, the cause stays, and it comes back somewhere harder to see.

## The rule

```
NO FIX WITHOUT A ROOT CAUSE YOU CAN EXPLAIN
```

If you cannot say "this fails because X, and here is the evidence", you are not ready to propose a fix. Finish phase 1 first. A fix you cannot explain is a guess, and a guess adds a variable instead of removing the broken one.

The process matters most when it feels least affordable: under time pressure, when one quick fix looks obvious, after a fix did not work, and when you do not fully understand the problem. "I don't understand X yet" is the right state to be in before phase 1. Say it. "It is a simple bug" is not an exception, because simple bugs have causes too and the process is quick for them.

## Keep secrets out of what you show and log

Debugging reads configuration, environment values, requests and logs, and secrets live in all of them. Never print, log or paste a key, token, password, connection string or private key, in your own output or in a log line you add. Name the variable, not its value. When a repro needs credentials, have it read them from the environment. If the redacted output is not enough to diagnose the problem, say so and ask the user for another way in, rather than pasting the real value.

## Four phases

Finish each one before starting the next.

### Phase 1: find the cause

Do this before touching any code.

1. **Read the error properly.** The whole message and stack trace, line numbers, file paths, error codes. Errors often name the cause outright.
2. **Build a repeatable reproduction.** This is the step most debugging sessions get wrong. Get one command, one you have actually run, that fails on demand. A good one:
   - drives the real code path, not a look-alike,
   - fails with the user's exact symptom, not merely "it errors", so you can later prove the fix removed that failure and not a nearby one,
   - gives the same verdict every run, and runs fast and without a person at the keyboard.

   Pick the cheapest honest form: a failing test at the right seam, a scripted request, the command-line tool run against a saved input, a replayed trace or log, a small harness around the suspect code, or a script that shows a person one instruction at a time and records what they see, which they run in their own terminal and paste back. If it only fails sometimes, raise the rate rather than chase a clean repro: loop the trigger, run it in parallel, add load, narrow the timing window. Pin what you can: seed randomness, fix the clock, isolate files and network.

   Then **shrink it.** Remove inputs, callers, configuration and data one at a time, running it after each cut, until everything left is needed to fail. The smallest failing case is the best regression test and often names the cause.

   If you cannot build a repeatable reproduction, stop. Do not theorise. List what you tried and ask the user for what would help: an environment where it fails, a redacted artifact (a log, a request capture, a dump, a timestamped recording), or permission to add temporary instrumentation.
3. **Check what changed.** Recent commits and diffs, new dependencies, config or environment differences. "It worked before" means something changed. When you know a good state and a bad one (a commit, a data set, a version), bisect between them: automate "set up at state X, run the repro, record pass or fail" so a bisect tool can drive it, or run old and new side by side and compare their output.
4. **Instrument the boundaries of a multi-part system.** For a chain such as CI, build, sign, or request, service, database, do not guess which part is at fault. At each boundary log what goes in and what comes out (redacted, see above), and check that config and environment values arrived intact. Run it once and let the output show where it breaks. Then investigate that part.
   - Prefer a debugger or an interactive session over logs. Add targeted logs only where they separate your candidate causes. Never log everything and search it.
   - Give every debug line you add one unique prefix, so removing them is one search.
   - Line up timestamps before blaming a log line: an error outside the failing step's time window is context, not the cause.
   - If you change anything temporarily to gather evidence (a log level, a flag, an environment variable), write down its original value first and restore exactly that, not a default. Ask before touching shared or production systems.
5. **Trace the bad value backward.** When the error is deep in a call stack, ask where the bad value came from and what called this code with it. Keep going up until you reach the origin, and fix it there, not where it blew up. If you cannot trace it by reading, add a temporary log or a stack trace at the point where the bad value first appears.
6. **For a slow or resource-hungry bug, measure first.** Logs are usually the wrong tool. Take a baseline with a timing harness, profiler or query plan, then bisect on that measurement. Measure first, fix second.

Phase 1 is done when you can state what is failing and why, with evidence.

### Phase 2: compare with what works

1. **Find a working example** of something similar in the same codebase.
2. **Read the reference completely** if you are following a pattern. Do not skim and do not adapt from memory.
3. **List every difference** between working and broken, however small. Do not decide "that cannot matter".
4. **Understand the dependencies:** what settings, config, environment and assumptions does the code need?

### Phase 3: rank causes, then test one

1. **List the candidate causes and rank them.** For each, write what it predicts: "if X is the cause, changing Y removes the bug and changing Z makes it worse." A cause with no prediction is a hunch. Show the ranked list to the user if they are around. They often know what changed or what is already ruled out. If they are away, go with your own ranking.
2. **Test the top one with the smallest change** that could prove it wrong. One variable at a time. Never fix several things at once.
3. **Check the result.** It worked: go to phase 4. It did not: strike that cause and move to the next. Do not add more fixes on top of the failed one.
4. **If you do not know, say so** and research or ask. Do not pretend.

### Phase 4: fix the cause

1. **Write a failing test that reproduces the bug**, at a seam where it fails the way it fails in real use. A test on a shallow seam (one caller, when the bug needs several) passes for the wrong reason and gives false confidence. If no seam reproduces it correctly, that is a finding about the design, so report it. Your minimised repro from phase 1 is usually the starting point. The `test-driven-development` skill covers the cycle. Have the test before the fix.
2. **List every caller of the defective code** before fixing, and fix where they meet, so sibling callers are not left broken. Do not stop at the path the report names. Keep the fix in the narrowest layer responsible, and leave unrelated behavior and the user's in-progress edits alone.
3. **Make one fix** for the cause you found. No "while I'm here" cleanups and no bundled refactoring.
4. **Verify.** The test passes, nothing else broke, and the original problem is gone. Run the original, un-shrunk reproduction and the whole suite, and check the exact symptom you recorded.
5. **If the fix did not work, stop and count.** Fewer than three attempts: go back to phase 1 with what you just learned. Three or more: do not try a fourth. Question the design, below.
6. **Finish cleanly.** Remove the debug lines and throwaway harnesses you added, only those, and restore anything you changed temporarily. State the confirmed cause in the commit or pull request message. After the fix lands, ask what would have prevented the bug (a test, a type, a check at a boundary) and recommend it. Do not start it unasked.

If you were handed this work by another agent or a person, report back as blocked with your evidence instead of trying a fourth fix yourself, so the one who owns the decision can make it.

## Three failed fixes means look at the design

Suspect the architecture when each fix reveals a new shared-state or coupling problem somewhere else, when fixes would need a large refactor, or when each fix creates new symptoms elsewhere. That is not a failed hypothesis. It is a design that keeps producing the bug. Stop patching, ask whether the pattern is sound or whether you are continuing out of inertia, and raise it with the user before another fix.

## Techniques for particular situations

**Bad data arriving from far away.** After you find the origin, also validate at the layers between the origin and the failure, so the same bad value is rejected early next time instead of travelling.

**Flaky or timing-dependent tests.** Do not guess at a delay. Wait for the actual condition: poll until the thing you need is true, with a timeout and a clear failure message. An arbitrary sleep hides the race instead of fixing it.

**One test breaks another.** The first test is leaving state behind. Bisect: run the suspect pair, then halve the set of tests that run before the failing one until the polluter is alone. Fix the state it leaks.

## When you cannot finish

Two honest endings exist, and either is better than a guess.

- **Inconclusive.** Every safe observation you could make failed to separate the candidate causes. Say which observations you made, what is still missing, and what would resume the work.
- **Blocked.** The only way to reproduce it would be unsafe, destructive, or possible only in production. Do not force it. Write down the missing evidence and what you need to proceed.

If a symptom you thought was fixed returns, run one observation that could disprove the earlier diagnosis before accepting it again. If the user asks only why something happens, stop after the cause, its evidence, and where it is safe to fix it, and do not edit code.

Sometimes a thorough investigation shows the problem really is environmental, timing-dependent or external. Then you have completed the process, and that is a legitimate result. Write down what you checked and ruled out, handle it properly (a retry, a timeout, a clear error message, waiting on the condition), and add logging so a recurrence leaves evidence. Be honest, though: most "there is no root cause" conclusions are really "I stopped investigating too early". Check that you traced the data flow before you reach for this.

## Stop and go back to phase 1 if you catch yourself thinking

- "Quick fix for now, investigate later."
- "Let me just try changing X and see."
- "I'll make several changes and run the tests."
- "I'll skip the test and check it by hand."
- "It's probably X." Said from the symptom alone.
- "I do not fully understand it, but this might work."
- "I'll theorise about it, since I can't reproduce it." A theory is not a cause.
- Listing fixes before you have traced the data.
- "One more attempt", after two failed ones.

Other people's questions are signals too. "Is that actually happening?" means you assumed without checking. "Will that show us where it breaks?" means gather evidence first. "Stop guessing" means you are proposing fixes without understanding. "Are we stuck?" means the current approach is not working, so change it instead of repeating it.

## Quick reference

| Phase | What you do | Done when |
|---|---|---|
| 1. Find the cause | Read the error, build and shrink a repro, check changes, instrument boundaries, trace backward | You can say what fails and why, with evidence |
| 2. Compare | Find working examples, list every difference | You know what differs |
| 3. Rank and test | Rank causes by prediction, test one with the smallest change | It is confirmed, or you move to the next |
| 4. Fix | Failing test at the right seam, list callers, one fix, verify, clean up | The bug is gone, the suite is green, and your debug traces are removed |

The second audit

What we found in the sources

It keeps the four-phase process of the version most others derive from (obra/superpowers), makes it stand alone, removes claims no source backs up, and was extended on 2026-10-28 with the reproduction, ranking, regression-seam and safety material from a second lineage (mattpocock/skills and its copies). Every source below was read at the commit the auditor recorded. Nothing was taken from a source without a permissive license.

What each source contributed

  • obra/superpowers ↗ · Primary basis · MIT

    The rule (no fix without a root cause), the four phases, instrumenting component boundaries, the three-failed-fixes-means-question-the-design rule, the red-flags list, the excuses table and the quick reference.

  • phmatray/ai-migration-kit ↗ · Structure and wording · MIT

    The framing that a symptom fix hides the cause, the sharper trigger description with an explicit "not for" clause, the point that "I don't understand yet" is the correct starting state, the "no single cause is a legitimate result, but check you did not stop early" section, and the list of companion techniques (tracing, defense in depth, condition-based waiting, bisecting for a polluting test).

  • lsy041015/orchestra ↗ · Added idea · MIT

    When you were handed the work, report blocked with the evidence instead of making a fourth attempt.

  • mattpocock/skills ↗ · Added ideas · MIT

    Building a repeatable reproduction that fails for the reported symptom, shrinking it, raising the reproduction rate of a flaky bug, ranking several candidate causes by what each predicts, instrumentation hygiene (debugger first, targeted logs, one unique prefix), measuring a performance bug before fixing it, a regression test at a correct seam, finishing cleanly, and the rule against showing or logging secrets.

  • dougborg/harness-kit ↗ · Added ideas · Apache-2.0

    Listing every caller of the defective code before fixing so sibling callers are not left broken, and the procedure for a script a person runs and pastes back.

  • haru3613/harness-ship ↗ · Added ideas · MIT

    Honest endings (inconclusive, and blocked when the only reproduction would be unsafe), never forcing an unsafe or production-only reproduction, re-checking a recurrence against the earlier diagnosis, and the diagnose-only mode.

  • markusleben/ha-nova ↗ · Added ideas · MIT

    Record the original value of anything changed temporarily and restore exactly that, and line up timestamps before blaming a log line.

What changed

  • The description says what the skill does and what it is not for, with the symptoms that should trigger it. Upstream's was only "Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes".
  • The four companion techniques (tracing a value backward, defense in depth, waiting on a condition, bisecting a test that pollutes state) were separate files in the sources. They are now short sections in the skill so a lone copy is complete. These were written fresh from the one-line descriptions the sources give; the companion files themselves were not fetched or read.
  • Dropped every statistic. Upstream says "95% of no-root-cause cases are incomplete investigation", and older clones add a "Real-World Impact" table of timings and success rates. No source gives a basis for any of those numbers. The qualitative point is kept.
  • Fixed upstream's dangling pointer "see Phase 4.5" (the section is Phase 4, step 5), and removed the "superpowers:" namespace on the skills it names.
  • Replaced "your human partner" with "the user" or "a person", and the section of user catch-phrases with the same signals in neutral wording.
  • Removed the macOS code-signing example for boundary logging in favor of a description that works for any chain of components.
  • Phase 1 now has a real reproduction step (done criteria, shrinking, flaky bugs, stop-and-ask when none can be built) where the first version had one line, and a performance branch.
  • Phase 3 now ranks candidate causes by what each predicts before testing one at a time; phase 4 adds the correct-seam rule, caller enumeration, and a cleanup step.
  • Added a rule against printing or logging secrets, because boundary logging in the first version could expose configuration values. One variant of the second lineage (leobbaroni/cockpit) had removed the equivalent rule from its source; this skill keeps it.
  • Shortened the excuses table out of the skill, since the red-flags list already says the same things.

Problems found in the sources

  • obra/superpowers: The description gives only the trigger. The skill points to three companion files and to skills by a "superpowers:" namespace, so a lone copy has dangling references. It cites "Phase 4.5", which does not exist (the section is Phase 4, step 5). It states "95% of no-root-cause cases are incomplete investigation" with no basis given.
  • jsonlee12138/agent-team: Adds a "Real-World Impact" section: 15 to 30 minutes versus 2 to 3 hours, and a 95% versus 40% first-time fix rate. No source or measurement is given. The same table appears in gylove1994/superpowers-deepseek-v4.
  • gylove1994/superpowers-deepseek-v4: Adds an instruction to invoke confirming-worktree-before-edit before any edit, a skill that is not part of this one. Cannot be satisfied without it.
  • phmatray/ai-migration-kit: Names companion files (root-cause-tracing.md, defense-in-depth.md, condition-based-waiting.md, find-polluter.sh) and says they are in the same directory, but only SKILL.md was audited, so a lone copy points at files that are not there.
  • mattpocock/skills: States "the bug is 90% fixed" and gives numeric thresholds as if they were rules, with no basis. Points to a hitl script, CONTEXT.md and the /improve-codebase-architecture skill that a lone copy lacks. Its Redact section is a strength.
  • leobbaroni/cockpit: In its diagnosing-bugs, the Redact section of the original is removed while the step telling the agent to paste commands and outputs remains, which is a safety regression from the original.
  • dariovr1/sixth-sense: Reads and appends .sixth-sense/learnings.jsonl, creating the file if absent, so it writes into the user's repository without asking.
  • lilmgenius/win-hooks: Not general debugging: a Windows plugin-hook fixer whose Fix section runs a script that rewrites other plugins' hook files and a command that copies a backup over hooks.json with no confirmation step.

What was dropped

  • The "Real-World Impact" timings and success rates found in older clones (see findings).
  • The worktree hard-gate added by gylove1994/superpowers-deepseek-v4, which depends on a skill that is not here.
  • The Codex-delegation machinery of mzored/superpowers-cc-to-codex, which is tied to those tools.
  • Numeric thresholds in mattpocock/skills (100 repetitions, 1,000 random inputs, "50% flaky is debuggable, 1% is not", a 30-second versus 2-second loop) and its "the bug is 90% fixed" line: no basis is given for any of them.
  • The scripts/hitl-loop.template.sh file and the walkthrough skill that copies of mattpocock/skills point to; they were not in the download and are dangling there. The idea is kept as the host-neutral "script a person runs".
  • The .sixth-sense/learnings.jsonl ledger from dariovr1/sixth-sense, which writes a new file into the user's project without asking, and its Java, Spring and Gradle specifics.
  • The three unrelated diagnose skills in the same bundle (Windows plugin hooks, Home Assistant, a receipts-based workflow) apart from the two ideas credited above.
Read but not used (16)
  • VictorStochero/fluxo-orca: Upstream with only the skill names re-pointed (identical apart from two lines).
  • gylove1994/superpowers-deepseek-v4: Upstream plus the worktree gate, an opening sentence and the unsourced statistics.
  • jnmetacode/superpowers-zh: A Chinese translation of upstream.
  • leodorareluctant259/superpowers-zh: A Chinese translation of upstream.
  • cheng6563/litepowers: A short Chinese-language summary (about 1 KB).
  • jsonlee12138/agent-team: Upstream with its skill names changed plus the unsourced statistics.
  • mzored/superpowers-cc-to-codex: A port that hands investigation and fixes to Codex tools, invocable only on request. Its header says it diverges from upstream deliberately.
  • sitien173/superpowers-ccg: A very short summary that leaves delegation and the regression-test cycle to other skills.
  • thepragmaticbear/bearpaws: Upstream recast in XML tags and shortened.
  • the-inconvenience-store/skills: Byte-identical to mattpocock/skills (same SHA-256).
  • Bossmann007/cursor-kit: A near copy of mattpocock/skills with punctuation changes and the last paragraph of the final phase removed.
  • CapitalCantrip/quality-gates: A near copy of mattpocock/skills; reads GLOSSARY.md where the original reads CONTEXT.md.
  • MokeyBytes/capstan: A near copy of mattpocock/skills ported to that tool's folders; the human-script step becomes a skill that is not in the download.
  • helderberto/agent-skills: A reworded variant of mattpocock/skills without the redaction rule; hands off to a skill that is not present.
  • RollRollRoll/agent-toolkit: A Chinese translation of mattpocock/skills (Apache-2.0), read and verified.
  • dariovr1/sixth-sense: A different skill with the same name, short and Java-specific, with a three-failures rule like this skill's. Only the narrowest-layer idea overlaps and is credited to dougborg.
Left out for license (5)

No license is declared on these, so nothing was taken from them: Athyrr/aikit, Fintama/swisper-superpowers, Itzalive/resistance-ai, lukekeith/builder, orkeren21/shipshape.

Same text, wherever you work

Use it where you work

Copy the folder into your skills directory, then ask for the job or type its start command.

git clone https://github.com/nikbearbrown/skills
cp -R skills/skills/systematic-debugging ~/.claude/skills/

Pairs with