agentleFS
aegnticaegntic/compound-engineering/skills/systematic-debugging/SKILL.md

systematic-debugging

Skill1 starsChanged 5 months agoMITView on GitHub

Use when debugging unexpected errors during implementation -- provides a structured 4-phase methodology instead of trial-and-error

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

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

  • 0

    Common

    Most of the 177 edited versions we read keep these.

  • 12

    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:

    When it happens (always, sometimes, under specific conditions)

    line 47
  2. Distinctive:

    Start fixing before completing this phase

    line 66
  3. Distinctive:

    Verify or eliminate each hypothesis systematically.

    line 72
  4. Distinctive:

    Add a diagnostic check (log statement, assertion, breakpoint, print)

    line 75
  5. Distinctive:

    Run the failing scenario

    line 76
  6. Distinctive:

    If ruled out: Test the next hypothesis

    line 80
  7. Distinctive:

    Isolation: Run the failing code in isolation (unit test, REPL, minimal reproduction)

    line 85
  8. Distinctive:

    Minimal reproduction: Create the smallest possible case that reproduces the error

    line 87
  9. Distinctive:

    Run the exact same command/test that originally failed

    line 103
  10. Distinctive:

    Run related tests to check you did not break anything else

    line 105
  11. Distinctive:

    If the fix introduces new failures, return to Phase 1 with the new error

    line 106
  12. Distinctive:

    If you discovered a pattern that would help prevent this issue in the future:

    line 130

“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

A structured methodology for debugging unexpected errors encountered during implementation. Prevents trial-and-error guessing by enforcing a disciplined observe-hypothesize-test-fix cycle.

Announce at start: "I'm using the systematic-debugging skill to diagnose this issue."

When to Use

  • A test fails unexpectedly during implementation
  • An error occurs that you did not anticipate
  • A subagent has retried 2+ times without success
  • Something "should work" but does not
  • You are tempted to make random changes hoping something fixes it

When NOT to Use

  • The error message is clear and the fix is obvious (just fix it)
  • You are validating a reported bug (use the bug-reproduction-validator agent instead)
  • The failure is a known issue documented in docs/solutions/

The 4-Phase Process

Phase 1: Observe

Gather evidence before forming any theories. Do not skip this phase.

  1. Reproduce the error -- Run the exact command that failed. Confirm you see the same error.
  2. Read the full error -- Read the COMPLETE error message, stack trace, and any surrounding output. Do not skim.
  3. Check the context -- What changed recently? What was the last thing that worked? What is different now?
  4. Gather state -- Check relevant logs, database state, environment variables, configuration files, or any other state that could be relevant.
  5. Note the symptoms -- Write down exactly what you observe:
    • What happens (the error)
    • What should happen (expected behavior)
    • When it happens (always, sometimes, under specific conditions)

Output of Phase 1: A clear, factual description of the symptoms with no theories attached.

Phase 2: Hypothesize

Form structured theories about the root cause. Do not jump to fixing yet.

  1. List 3 possible root causes ranked by likelihood:
    • Most likely: [hypothesis based on error message and context]
    • Possible: [alternative explanation]
    • Less likely but worth checking: [edge case or environmental cause]
  2. For each hypothesis, identify:
    • What evidence would confirm it
    • What evidence would rule it out
    • How to test it without changing production code

Do NOT:

  • Start fixing before completing this phase
  • Settle on one theory without considering alternatives
  • Assume the most obvious cause is correct without verification

Phase 3: Test

Verify or eliminate each hypothesis systematically. Start with the most likely.

  1. Test the most likely hypothesis first:
    • Add a diagnostic check (log statement, assertion, breakpoint, print)
    • Run the failing scenario
    • Does the evidence confirm or rule out this hypothesis?
  2. If confirmed: Move to Phase 4 (Fix)
  3. If ruled out: Test the next hypothesis
  4. If all 3 ruled out: Return to Phase 2 with new hypotheses based on what you learned

Techniques:

  • Binary search: Comment out half the changes, see if the error persists. Narrow down.
  • Isolation: Run the failing code in isolation (unit test, REPL, minimal reproduction)
  • Comparison: Compare working state (git stash, previous commit) with broken state
  • Minimal reproduction: Create the smallest possible case that reproduces the error

Do NOT:

  • Make changes to fix the problem while still in this phase
  • Skip hypotheses because you "feel" the first one is right
  • Change multiple things at once (change one variable at a time)

Phase 4: Fix

Apply a targeted fix to the confirmed root cause.

  1. Fix the root cause -- not the symptom. If the error is "undefined is not a function," the fix is not adding a null check -- it is understanding WHY the value is undefined and fixing THAT.
  2. Make the minimal fix -- Change as little as possible. Do not refactor, clean up, or "improve" other code while fixing the bug.
  3. Verify the fix:
    • Run the exact same command/test that originally failed
    • Confirm it passes
    • Run related tests to check you did not break anything else
    • If the fix introduces new failures, return to Phase 1 with the new error
  4. Check for siblings -- Is this same bug likely to exist in similar code elsewhere? If so, fix those too.
  5. Remove diagnostics -- Remove any log statements, debug prints, or breakpoints added during Phase 3.

After Debugging

Document the Root Cause

Include in your execution report:

### Debugging Session
- **Symptom:** [what failed]
- **Root cause:** [what was actually wrong]
- **Fix:** [what was changed]
- **Prevention:** [how to prevent this in the future]

This information feeds into the learnings brief for subsequent tasks and can be captured in docs/solutions/ via /workflows:compound.

Feed Forward

If you discovered a pattern that would help prevent this issue in the future:

  • Note it in the "Patterns Discovered" section of your execution report
  • The orchestrator will add it to the learnings brief for subsequent tasks

Anti-Patterns (What NOT to Do)

  • Shotgun debugging: Making random changes hoping something works. Always hypothesize first.
  • Fix-and-pray: Applying a fix without understanding why it works. If you cannot explain the root cause, you have not found it.
  • Stack Overflow driven development: Copying a fix from the internet without understanding what it does or why it applies to your situation.
  • Symptom masking: Adding a try/catch, null check, or default value that hides the real problem instead of fixing it.
  • Tunnel vision: Fixating on one hypothesis without considering alternatives. The first theory is often wrong.

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.