agentleFS
getappzgetappz/agentflare/.claude/skills/systematic-debugging/SKILL.md

systematic-debugging

Skill3 starsChanged 38 days agoApache-2.0View on GitHub

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes — walks through root-cause investigation, pattern comparison, and a single tested hypothesis before any code changes. Skip when there's no failure to explain yet (greenfield feature work) — use algorithm-pseudocode-design or system-architecture-design instead.

190 other projects use a version of this, 1 of them edited.

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, 7 are distinctive, and 0 are 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.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Especially: when under time pressure, when "just one quick change" seems obvious, or when a previous fix attempt didn't work — those are …

    line 24
  2. Distinctive:

    Before touching any code:

    line 33
  3. Distinctive:

    If a working example exists (a similar endpoint, a sibling test, a reference implementation), read it completely before comparing — …

    line 52
  4. Distinctive:

    Read it in full, not just the parts that look relevant.

    line 57
  5. Distinctive:

    If you genuinely don't understand a piece of the system, say so and investigate further rather than proceeding on a guess.

    line 73
  6. Distinctive:

    Write a failing test that reproduces the bug, if the codebase has a test framework in reach.

    line 78
  7. Distinctive:

    Verify: the new test passes, no other tests regressed, the original symptom is gone — verify with fresh evidence, not a stale earlier test …

    line 84

“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

The Iron Law

NO FIX WITHOUT ROOT-CAUSE INVESTIGATION FIRST

A fix proposed before Phase 1 is complete is a guess, not a fix. Guesses that happen to work are indistinguishable from guesses that don't until the bug resurfaces somewhere else.

When to use

Any technical issue: a failing test, a production bug, unexpected output, a performance regression, a build failure, an integration that doesn't behave as documented.

Especially when under time pressure, when "just one quick change" seems obvious, or when a previous fix attempt didn't work — those are exactly the conditions where guessing feels fastest and costs the most.

Don't skip because the bug looks simple. Simple bugs have root causes too, and finding one usually takes minutes, not hours.

Phase 1: Root-cause investigation

Before touching any code:

  1. Read the actual error. Full stack trace, not the first line. Note exact file paths, line numbers, and error codes — they often name the fix directly.
  2. Reproduce it. Confirm exact, repeatable steps. If it won't reproduce reliably, that's information — gather more data (logging, a tighter repro case) rather than guessing at a fix for a moving target.
  3. Check recent changes. git log/git diff on the affected paths, recent dependency bumps, config or environment drift. Most bugs are introduced by something that changed, not something that was always broken.
  4. Trace the data flow backward. Find where the bad value or bad state actually originates, not just where it's first observed. Follow it through each call/component boundary until you reach the source, and fix there — not at the symptom.

Phase 2: Pattern analysis

If a working example exists (a similar endpoint, a sibling test, a reference implementation), read it completely before comparing — skimming guarantees you miss the difference that matters:

  1. Locate the closest working analog in the same codebase.
  2. Read it in full, not just the parts that look relevant.
  3. List every difference from the broken code, however small. Don't discard one because "that can't matter" — verify it doesn't.
  4. Note what the working version depends on (config, environment, call order) that the broken version might be missing.

Phase 3: Single hypothesis, minimal test

  1. State the hypothesis explicitly: "X is the root cause because Y." Vague hypotheses ("something about the config") aren't testable — sharpen them until they are.
  2. Make the smallest possible change that tests it — one variable, not a bundle of plausible fixes.
  3. Confirmed → proceed to Phase 4. Not confirmed → form a new hypothesis and repeat this phase. Don't layer a second fix on top of an unconfirmed first one.
  4. If you genuinely don't understand a piece of the system, say so and investigate further rather than proceeding on a guess.

Phase 4: Implementation

  1. Write a failing test that reproduces the bug, if the codebase has a test framework in reach. If a proper test isn't practical, a minimal repro script still counts; either way, confirm it fails before touching the fix.
  2. Apply one fix addressing the confirmed root cause. No bundled cleanup, no "while I'm here" changes — those hide whether the fix actually worked.
  3. Verify: the new test passes, no other tests regressed, the original symptom is gone — verify with fresh evidence, not a stale earlier test run, before claiming the bug is fixed.
  4. If the fix doesn't work, stop and count attempts. Fewer than three → return to Phase 1 with what you just learned. Three or more failed fixes on the same bug is not bad luck — it's a signal to stop fixing and question the architecture: is the pattern you're patching around fundamentally sound, or is each fix surfacing new coupling/shared state somewhere else? Raise that with the user before attempting a fourth fix.

Red flags — stop and return to Phase 1

  • "Quick fix now, investigate properly later"
  • "Let me just try changing X and see"
  • "I don't fully understand this but it might work"
  • Proposing a fix before tracing the data flow to its source
  • A third attempt at fixing the same symptom

When investigation genuinely finds no root cause

Rare, but real for timing-dependent or external failures. Only claim this after actually completing Phases 1–3 — most "no root cause" conclusions are an incomplete investigation, not an environmental bug. If it really is environmental: document what was checked, implement the appropriate handling (retry, timeout, explicit error), and add logging so the next occurrence isn't starting from zero.

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.