agentleFS
ehnruizehnruiz/claude-skills/skills/diagnosing-bugs/SKILL.md

diagnosing-bugs

Skill3 starsChanged 29 days agoMITView on GitHub

A disciplined loop for hard bugs, flaky tests and performance regressions - build a red-capable feedback loop first, reproduce and minimize, rank falsifiable hypotheses, instrument one variable at a time, then repair and remove the probes. Use when the user says "diagnose", "debug this" or "why is this failing", reports a wrong result, a crash, a timeout, a flaky test or a slowdown, or when a first-glance fix did not hold.

193 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use setup-ts-deep-modules, loop-me and 10 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.
  • liufeng1976Skill

    setup-ts-deep-modules

    Wire dependency-cruiser into a TypeScript repo so each package is a deep module — implementation hidden in subfolders, reachable only through its entry-point files. User-invoked.

    Also in 43 projects that use this

  • RoentekSkill

    loop-me

    Grill me about specs for the workflows I want to build, within this workspace.

    Also in 55 projects that use this

  • LesaniSkill

    writing-beats

    Shape an article as a journey of beats, choose-your-own-adventure style. The user picks a starting beat from the raw material, you write only that beat, then offer options for where to pivot next, beat by beat, until the article reaches a natural end. Use when the user has raw material and wants to assemble it as a narrative rather than an argument.

    Also in 58 projects that use this

  • AWSSkill

    to-questionnaire

    Turn a decision you can't fully answer into a questionnaire for someone else to fill in.

    Also in 88 projects that use this

  • LesaniSkill

    writing-shape

    Take a markdown file of raw material and shape it into an article through a conversational session — drafting candidate openings, growing the piece paragraph by paragraph, arguing about format (lists, tables, callouts, quotes) at each step. Use when the user has a pile of notes, fragments, or a rough draft and wants help turning it into something publishable.

    Also in 56 projects that use this

  • AWSSkill

    wizard

    Generate an interactive bash wizard that walks a human through steps only they can perform. Use when provisioning infrastructure, setting up credentials or CI secrets, walking an unfamiliar third-party dashboard, or running a one-off migration or cutover. Don't invoke this for steps the agent can perform itself.

    Also in 122 projects that use this

  • +1 more from Lesani
  • +2 more from aws

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 7 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 180 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before exploring, read the project's architecture and known-limitations docs if it has them.

    line 13
  2. Distinctive:

    Bisection: when the bug appeared between two known states, automate "check out, run the loop, report" so git bisect run drives it.

    line 40
  3. Distinctive:

    Phase 1 is done: when you can name one command you have already run at least once (show it and its exit code, redacted) that goes red on …

    line 53
  4. Distinctive:

    If you catch yourself reading code to build a theory before that command exists, stop: that is the exact failure this skill prevents.

    line 57
  5. Distinctive:

    Run the loop and watch it go red.

    line 62
  6. Distinctive:

    Write 3 to 5 ranked hypotheses before testing any.

    line 68
  7. Distinctive:

    Write the regression test before the fix, at a real seam, exercising the actual bug pattern.

    line 81

“Common” is measured: kept by at least 6 in 10 of the 180 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

Diagnosing bugs

A discipline for hard bugs. Skip a phase only when you can say why. Credit and license: LICENSE.md in this folder.

Project copy first. If the repository has its own .claude/skills/diagnosing-bugs/SKILL.md, read it and follow it instead of this file. A skill installed for all your projects outranks a project skill with the same name, so without this step a repository's own version of this skill would never run.

Before exploring, read the project's architecture and known-limitations docs if it has them; some "bugs" are documented gaps.

Redact

You will show commands, outputs and captured artifacts. Redact every secret first: write <REDACTED> in its place. Build loops against environment variables so tokens, webhook URLs and cookies stay in the environment, not in what you show. Quote only the lines that carry the signal.

Phase 1: Build a feedback loop

This is the skill. With a tight pass/fail signal that goes red on this bug, you will find the cause; bisection, hypotheses and instrumentation all just consume it. Without one, no amount of reading code will save you. Spend disproportionate effort here.

Ways to build one, roughly cheapest first:

  1. A failing unit test at the public seam closest to the symptom, with hand-built input.
  2. A fixture or integration test: plant the defect in test data and assert on it.
  3. The real entry point, narrowed: the CLI, endpoint or job run against one input, with everything not under suspicion turned off.
  4. Replay: capture the input once (a request, a payload, a saved page) and replay it offline, so the network or browser leaves the loop.
  5. A throwaway script that drives the browser, API or queue and asserts on the symptom.
  6. Differential: the same input through the last known-good commit and HEAD, diffing the output. Compare runtime and dependency versions first.
  7. Bisection: when the bug appeared between two known states, automate "check out, run the loop, report" so git bisect run drives it.
  8. Loop the trigger for a flaky test (shuffle with a fixed seed, run 100 times) until the reproduction rate is high enough to debug.

Tighten the loop once you have one: faster (one test, one input), sharper (assert the exact symptom, not "did not crash"), deterministic (pin time, seed randomness, freeze the network).

If you cannot build one, stop and say so. List what you tried and ask the user for the artifact you need: a redacted log, the failing run's link, a captured payload, access to the environment. Do not move to hypotheses without a loop.

Phase 1 is done when you can name one command you have already run at least once (show it and its exit code, redacted) that goes red on this bug and will go green when it is fixed, is deterministic, runs in seconds and needs no human.

If you catch yourself reading code to build a theory before that command exists, stop: that is the exact failure this skill prevents.

Phase 2: Reproduce and minimize

Run the loop and watch it go red. Confirm it is the failure the user described, not a nearby one. Then cut inputs, config and steps one at a time, re-running after each cut, until every remaining element is load-bearing.

Phase 3: Hypothesize

Write 3 to 5 ranked hypotheses before testing any. Each must be falsifiable: "if X is the cause, changing Y makes the bug disappear." Show the list to the user before testing; continue with your ranking if they are away.

Phase 4: Instrument

One probe per prediction. Change one variable at a time. Prefer a debugger session to logging; when you log, tag every line with a unique prefix such as [DEBUG-a4f2] so cleanup is one grep. For a slowdown, measure before you bisect: find which stage grew, then time only that stage.

Phase 5: Fix behind a regression test

Write the regression test before the fix, at a real seam, exercising the actual bug pattern. If the only seam available is too shallow to catch it, that is a finding; record it. Watch the test fail. If you forced the red by editing code or a fixture, diff it against an untouched copy to prove the edit landed before you trust the failure. An edit that silently changed nothing would otherwise pass as a failing test. Then apply the fix, watch it pass, and re-run the Phase 1 loop on the original scenario. The regression-proof skill shows how to prove the test fails without the fix.

Phase 6: Clean up

Before declaring done:

  • The original repro no longer reproduces (re-run the Phase 1 loop; show the exit code)
  • The regression test passes, or the missing seam is documented in the PR
  • Every [DEBUG-...] line is gone (grep -rn "DEBUG-" over the source and tests)
  • Scratch scripts, configs and captured artifacts are deleted
  • The hypothesis that turned out right is in the commit message, so the next person debugging learns from it

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.