agentleFS
TomSzenessyTomSzenessy/AI_TEMPLATE/.agents/skills/systematic-debugging/SKILL.md

systematic-debugging

Skill0 starsChanged 8 days agoMITView on GitHub

Finds and proves the root cause of a failure before any fix; Use when a test, build, or flaky check fails, behavior is unexpected, a fix did not work, the user asks "why does this happen", or you are about to guess at a change.

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

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

  • 0

    Common

    Most of the 177 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Trace backward: when the error is deep in a call chain: symptom, the line that causes it, its caller, the value passed, who produced that …

    line 31
  2. Distinctive:

    Write one sentence: "The cause is X because Y" (Y is an observation).

    line 47
  3. Distinctive:

    Test it with the smallest change or probe.

    line 48
  4. Distinctive:

    Not understood: say "I do not understand X", research, or ask.

    line 51
  5. Distinctive:

    Defense in depth: when bad data caused it: after fixing the source, add validation at the layers the data crosses (entry validation, domain …

    line 67
  6. Very specific:

    Add the ledger row and close out per operations.

    line 72
  7. Distinctive:

    Never say fixed, passing, or done on "should", "probably", or an earlier run.

    line 101
  8. Distinctive:

    Run the command now, read the whole output and exit code, then state the claim with that evidence.

    line 102

“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

Iron law: no fix without a confirmed root cause. A symptom fix is a new bug. The incident loop (observe, search the ledger, reproduce, diagnose, repair, verify, reconcile) and the EL-### error ledger are owned by docs/operations.md; this skill is how to do its Diagnose and Repair steps well. Do not restate them.

Hurried, "obvious", or already-tried-something situations are exactly when this applies. Systematic is faster than thrash.

Phase 1: Investigate (no edits yet)

  1. Read the whole error: full stack, exit code, file:line, warnings above it. The message usually names the cause.
  2. Search first: make where Q="<distinctive error text>". A known EL-### row means the fix is recorded; use it.
  3. Reproduce deterministically: exact command, input, environment. Cannot reproduce: gather more data (logs, versions, timing); do not guess a fix.
  4. Check what changed: git diff, git log -p -- <path>, new dependency, config, environment. A regression: git bisect run <cmd>.
  5. Multi-component flow (CI to build to deploy, API to service to store): instrument every boundary once (what enters, what leaves, which env/config arrived), run, and read where the data first goes wrong. Then dig into that one component.
  6. Trace backward when the error is deep in a call chain: symptom, the line that causes it, its caller, the value passed, who produced that value; repeat until you reach the original trigger. Fix there, never where it surfaced. No visible chain: log new Error().stack plus the inputs just before the failing call (to stderr; loggers may be silenced in tests). Test pollution (a stray file or state appears): run tests one at a time to find the polluter.

Phase 2: Pattern

Find similar working code in this repo. Read the reference completely, not a skim. List every difference between working and broken, however small. Name the assumptions and dependencies (config, env, ordering) each side relies on.

Phase 3: Hypothesis

  1. Write one sentence: "The cause is X because Y" (Y is an observation).
  2. Test it with the smallest change or probe; one variable at a time.
  3. Wrong: discard it, form a new one from the new evidence. Do not stack fixes on a failed one.
  4. Not understood: say "I do not understand X", research, or ask. Never pretend.

Separate in your notes: confirmed cause, contributing factors, hypotheses.

Phase 4: Fix

  1. Failing test first. The smallest automated reproduction (a script if there is no framework). Run it and watch it fail for the right reason (the bug, not a typo or setup error). A test that never failed proves nothing.
  2. One fix at the root cause. No "while I am here" cleanups, no bundled refactor.
  3. Green: the new test passes, the surrounding suite still passes.
  4. Prove the test guards the fix: revert only the fix, the test must fail; restore, it must pass.
  5. Defense in depth when bad data caused it: after fixing the source, add validation at the layers the data crosses (entry validation, domain invariant, environment guard that refuses the dangerous action, and a forensic log) so a different path cannot reintroduce it. Test that each layer catches the bypass.
  6. Add the ledger row and close out per operations; verify the real artifact per docs/verification.md.

Three failed fixes: stop

Counting every attempt. At three, do not try a fourth. Signs of a structural problem: each fix exposes shared state or coupling elsewhere, a fix needs a large refactor, each fix creates a new symptom. Question the design (is this pattern sound, are we continuing from inertia?), write what you learned to the issue, and decide the redesign with the owner before more patches. That is a wrong architecture, not a bad hypothesis.

Flaky tests: wait for conditions, not time

A fixed sleep/setTimeout guesses at timing and fails under load. Poll the real condition with a short interval (about 10 ms), a hard timeout, and an error that names what was awaited; re-read state inside the loop, never cache it.

wait_for(lambda: job.state == "done", what="job done", timeout=5)

A fixed delay is right only when testing real timing (debounce, throttle) or after the trigger condition fired and the interval is known; comment why. Also look for leaked shared state and order dependence (run the test alone).

Evidence before claims

Never say fixed, passing, or done on "should", "probably", or an earlier run. Run the command now, read the whole output and exit code, then state the claim with that evidence. Linter green is not build green; a changed line is not a fixed bug; a subagent's "success" is verified against the diff.

Red flags and the truth

ThoughtReality
"Quick fix now, investigate later"The first patch sets the pattern. Investigate first.
"Just try changing X and see"Guessing; it hides which change mattered.
"It is simple, no process needed"Simple bugs have root causes; the process is quick for them.
"Emergency, no time"Thrash costs more than diagnosis.
"I see the problem, fixing it"Seeing a symptom is not understanding the cause.
"I will add the test after it works"Untested fixes regress; test first.
"Several fixes at once saves time"You cannot tell which worked and you add bugs.
"One more attempt" (after two)Three failures mean question the design.
"No root cause, it is environmental"Usually an unfinished investigation; if truly external, document what you ruled out and add a retry/timeout and logging.
"I will adapt the reference without reading it all"Partial understanding guarantees bugs.

Any of these: stop, return to Phase 1.

Done

Cause confirmed with evidence, red-then-green test in the suite, one root-cause change, make done fresh, real path observed, ledger and issue updated.

Superpowers (make upstream ID=superpowers-workflow): the long-form debugging guides this skill condenses. Pull root-cause-tracing for a deep call chain or find-polluter.sh for test pollution, only when the phase above stalls.

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.