Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

bug-diagnosis

FreeRuns bundled scriptsNot checked

Find the root cause of hard bugs with a fast pass/fail repro, ranked falsifiable hypotheses and bisection. Use when a bug resists quick fixes, a failure is…

borgheiby borghei★ 1,250 GitHub stars

About this skill

Bug Diagnosis

A disciplined loop for bugs that survived the first obvious fix. The order is fixed: build a signal that says "bug present / bug absent" in seconds, write down competing explanations with predictions that could prove them wrong, test the cheapest likely one, narrow the search space by halving, and lock the cause in with a regression test that was seen failing. Most wasted debugging time comes from skipping the first step and reading code to build a theory with nothing to check it against.

When to use this skill

  • A bug resisted a first fix — the patch went in and the symptom came back, or moved
  • The failure is intermittent — passes locally, fails in CI one run in five
  • A regression appeared between two releases and nobody knows which change caused it
  • The symptom is far from the cause — wrong totals, corrupted records, a hang with no error
  • A performance regression needs a measured cause rather than a guess
  • Logs or traces need sharing with a teammate, vendor or assistant and may contain credentials

Inputs the skill expects

  • The reported symptom in exact terms: error text, wrong value, measured latency
  • Where it reproduces (local, CI, staging, production only) and how often
  • The last known-good state if one exists: a release, a commit, a dataset, a flag set
  • Access the agent has: can it run the code, the tests, a local database, git bisect?
  • Any artefacts already captured (logs, dumps, traces) — redacted before they are pasted

Clarify First

What most shapes a diagnosis is whether a reproduction signal can be built and how far the cause might hide. Settle the inputs below before producing anything. When one is missing or vague and would change the result, ask about it; when it wouldn't, use a sensible default and say which one you used.

  • The exact symptom: a signal must assert this specific symptom; "it's broken" yields a check that goes red on the wrong bug.
  • Where it reproduces: decides the harness — a local test, a recorded request replay, or a request for environment access.
  • Last known-good state: if one exists, bisection usually beats hypothesis testing and should come first.
  • Blast-radius limits: whether the agent may touch shared environments, production data or code outside the failing module.

Ask about the two or three inputs that matter most for this request, not the whole list. If the user wants a result straight away, produce it and state your assumptions at the top.

Quick Start

# Validate a diagnosis log and see which hypothesis to test next
python3 engineering/bug-diagnosis/scripts/hypothesis_log.py \
  --input engineering/bug-diagnosis/assets/sample_diagnosis_log_passing.json

# Check a log file for secrets before pasting it anywhere
python3 engineering/bug-diagnosis/scripts/redact_scan.py \
  --paths engineering/bug-diagnosis/assets/sample_debug_log.txt --pii

Workflows

Workflow 1 — Build the reproduction signal [PROVEN]

No signal, no hypotheses. The agent spends disproportionate effort here because every later step consumes this one command.

  1. Pick the harness from the bug class: failing test at the narrowest seam, replayed request, fixture-driven CLI run, timing harness for performance, or a differential run between versions (see references/reproduction-signals.md).
  2. Start from assets/repro-script-template.sh so the signal exits 0 for good, 1 for bad and 125 for untestable — directly usable by git bisect run.
  3. Make it assert the reported symptom. A check for "no exception" is not a signal.
  4. Pin clock, random seeds, locale, network and worker count. Run it 3+ times; record runs, red runs and runtime.
  5. If the failure is intermittent, raise its rate (loop in-process, parallel copies, smaller timeouts, injected delay) until at least 30% of runs go red.
  6. Minimise: remove inputs, records, steps and config one at a time, keeping only what keeps the signal red.

Validation checkpoint: the signal is one command, asserts the symptom, red on 3+ runs (or ≥30% for intermittent bugs), and runs in under 30 seconds. If it cannot be built within the timebox, stop and ask for access, a redacted artefact, or permission for tagged instrumentation.

Workflow 2 — Hypothesise, rank, test one at a time [PROVEN]

  1. Write 3–5 hypotheses before testing any, each naming a mechanism and a prediction in the form "if X is the cause, then changing Y makes the symptom disappear".
  2. Give each a prior (0–1) and an experiment cost in minutes. Record them in a diagnosis log JSON (shape: assets/sample_diagnosis_log_passing.json).
  3. Show the ranked list to the reporter before testing; their context often re-ranks it.
  4. Run the validator. It ranks open hypotheses by prior ÷ cost and rejects vague predictions, multi-variable experiments and confirmations with no evidence.
  5. Run the top experiment, record the result and evidence, re-run the validator, repeat.
python3 engineering/
Full SKILL.md on GitHub

Install bug-diagnosis in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

assets/diagnosis-log-template.mdassets/repro-script-template.shassets/sample_debug_log.txtassets/sample_diagnosis_log.jsonassets/sample_diagnosis_log_passing.jsonreferences/bisection-instrumentation-redaction.mdreferences/reproduction-signals.mdscripts/hypothesis_log.pyscripts/redact_scan.py

FAQ

What does the bug-diagnosis skill do?

Find the root cause of hard bugs with a fast pass/fail repro, ranked falsifiable hypotheses and bisection. Use when a bug resists quick fixes, a failure is intermittent, or a regression needs tracing to its cause.

How do I install the bug-diagnosis skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the bug-diagnosis skill run scripts?

Yes, this skill bundles executable scripts. Review the source before installing.

Related skills

Compare bug-diagnosis with