agentleFS
sebastienrousseausebastienrousseau/agtmls/skills/systematic-debugging/SKILL.md

systematic-debugging

Skill1 starsChanged 3 months agoApache-2.0View on GitHub

Find the root cause of a defect before changing anything. Load when something crashes, hangs, returns the wrong value, fails intermittently, or broke after a change, and the cause is not yet known. Drives reproduce, localize by bisection, explain the mechanism, then fix with a failing-first regression test. Replaces guess-and-check editing.

190 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use chinese-code-review, chinese-commit-conventions 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.
  • Leodorareluctant259Skill

    chinese-code-review

    中文代码审查规范——在保持专业严谨的同时,用符合国内团队文化的方式给出有效反馈

    Also in 8 projects that use this

  • Leodorareluctant259Skill

    chinese-commit-conventions

    中文 Git 提交规范 — 适配国内团队的 commit message 规范和 changelog 自动化

    Also in 8 projects that use this

  • obraSkill

    diagnosing-superpowers

    Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.

    Also in 20 projects that use this

  • mjunaidcaSkill

    building-chatgpt-apps

    Guides creation of ChatGPT Apps with interactive widgets using OpenAI Apps SDK and MCP servers. Use when building ChatGPT custom apps with visual UI components, embedded widgets, or rich interactive experiences. Covers widget architecture, MCP server setup with FastMCP, response metadata, and Developer Mode configuration. NOT when building standard MCP servers without widgets (use building-mcp-servers skill instead).

    Also in 4 projects that use this

  • mjunaidcaSkill

    building-chat-interfaces

    Build AI chat interfaces with custom backends, authentication, and context injection. Use when integrating chat UI with AI agents, adding auth to chat, injecting user/page context, or implementing httpOnly cookie proxies. Covers ChatKitServer, useChatKit, and MCP auth patterns. NOT when building simple chatbots without persistence or custom agent integration.

    Also in 4 projects that use this

  • +2 more from Leodorareluctant259
  • +5 more from mjunaidca

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 177 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Do not skip forward. Each phase has an exit condition.

    line 41
  2. Distinctive:

    Not a paraphrase — the literal text.

    line 49
  3. Very specific:

    Run it three times. If it fails 3/3, continue.

    line 53
  4. Distinctive:

    If you cannot reproduce it, say so and stop.

    line 56
  5. Distinctive:

    Verify the boundary: When you think you have found the transition point, confirm both sides: correct just before, incorrect just after.

    line 79
  6. Distinctive:

    Run the full suite. A fix that breaks two other things is not a fix.

    line 113
  7. Very specific:

    Check the explanation for siblings: if split(':') was wrong here, is the same pattern wrong in the three other places it appears?

    line 114

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

Systematic debugging

Trigger. Something is broken and you do not yet know why: a crash, a wrong result, a hang, a flake, a test that fails only in CI, a regression after an upgrade. Also load it when you catch yourself about to change code in the hope that it helps.

Reference material (localization techniques per symptom class, intermittent-failure playbook, and the instrumentation recipes): see reference.md in this directory.

The rule

No edit before an explanation. You must be able to say this input reaches this line, which does this wrong thing, which produces this symptom — before you touch the code.

Guess-and-check feels faster and is not. Each speculative edit changes the system you are trying to understand, and a "fix" that removes a symptom without an explanation has usually moved the bug somewhere less visible.

Four phases

Do not skip forward. Each phase has an exit condition; if you cannot meet it, you are still in that phase.

Phase 1 — Reproduce

Exit condition: one command that fails, reliably, on demand.

  1. Get the exact failure: full error, stack trace, exit code, wrong output. Not a paraphrase — the literal text.
  2. Establish the environment: branch, commit, dependency versions, config, platform. Bugs that "only happen for them" are usually environment deltas.
  3. Reduce the trigger to the smallest input and shortest command you can.
  4. Run it three times. If it fails 3/3, continue. If it fails 1/3, you have an intermittent bug — see reference.md §intermittent before proceeding.

If you cannot reproduce it, say so and stop. Debugging a failure you cannot observe is writing fiction. Ask for the input, the logs, the version.

Phase 2 — Localize

Exit condition: the smallest region of code where correct input goes in and incorrect output comes out.

Bisection is the workhorse — over anything ordered:

AxisMethod
Timegit bisect between a known-good and known-bad commit
Call stackAssert or log the invariant at the top, middle, and bottom
InputHalve the input until the failure disappears
ConfigDisable half the flags/plugins; repeat on the failing half
DataHalve the dataset; find the minimal failing record

The discipline is the same every time: form a binary question, answer it by observation, halve the space. Ten halvings cover a thousand candidates.

Two rules that keep this honest:

  • Verify the boundary. When you think you have found the transition point, confirm both sides: correct just before, incorrect just after.
  • Instrument, don't infer. Print the actual value. A variable you believe holds 3 is the reason the bug survived this long.

Phase 3 — Explain

Exit condition: a written sentence that connects cause to symptom, which predicts something you have not yet tested.

Write it out:

When parse() receives a key containing :, the split on line 88 takes the first segment only, so the map is built with a truncated key, so the lookup on line 140 misses and returns the default.

Then test the prediction. A correct explanation predicts more than the one failure you have: it says which other inputs fail, and which superficially similar ones do not. Check one of each. If the prediction is wrong, your explanation is wrong — return to Phase 2.

This is the step people skip, and skipping it is how you get a fix that works on the reported input and nothing else.

Phase 4 — Fix and pin

Exit condition: a regression test observed failing before the fix and passing after.

  1. Write the test first, from the explanation, and watch it fail with the real symptom — not ImportError, not a missing fixture.
  2. Make the smallest change the explanation calls for. If the explanation does not call for it, it is not part of the fix.
  3. Watch the test pass.
  4. Run the full suite. A fix that breaks two other things is not a fix.
  5. Check the explanation for siblings: if split(':') was wrong here, is the same pattern wrong in the three other places it appears?

Anti-patterns

  • Shotgun editing. Changing several things at once, then testing. If it works you have learned nothing; if it does not, you have a bigger space.
  • Fixing the symptom. Wrapping the crash in try/except, clamping the bad value, adding a retry. Legitimate only when the explanation says the condition is genuinely expected — and then it is not a bug fix.
  • Blaming the platform. The compiler, the runtime, the standard library. Occasionally right; assume it last, and only with a minimal reproduction.
  • Trusting the comment. Comments describe intent at writing time. Read the code.
  • Stopping at "it stopped happening." Especially for intermittent bugs. Absence of a symptom over ten runs is weak evidence about a race.
  • Rewriting to make the bug go away. Now you have an unexplained bug and a large diff.

When not to use

  • The project has a symptom-indexed triage playbook for its own subsystems — use that first; it will localize faster than a generic bisection.
  • You already know the cause and are just making the change.
  • The task is adding new behaviour, not restoring intended behaviour — that is test-driven-development.

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.