agentleFS
dafaalzdafaalz/agent-skills/skills/systematic-debugging/SKILL.md

systematic-debugging

Skill2 starsChanged 2 months agoMITView on GitHub

Use when debugging any bug, test failure, unexpected behavior, or performance issue before proposing fixes. Don't use for feature additions, code generation, or routine refactoring.

191 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use diagnosing-superpowers, building-chatgpt-apps 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.
  • 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 6 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

  • MorningStar0709Skill

    chinese-git-workflow

    Configure Git for domestic platforms and manage branching strategies suitable for Chinese teams. Use when the user asks to configure remotes, set up SSH, or manage Git workflows for Gitee, Coding, Jihu GitLab, or CNB, including requests like "配置国内 Git", "设置 Gitee 远程仓库", "推荐适合小团队的 Git 流程".

    Also in 4 projects that use this

  • +8 more from mjunaidca

The file

Show its rules and text

We split this skill into the rules it gives an agent

19 rules. 0 are common, 17 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 173 edited versions we read keep these.

  • 17

    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 write code, edit files, or propose fixes until Phase 1 investigation is complete.

    line 11
  2. Distinctive:

    Use this workflow for any technical fault:

    line 16
  3. Distinctive:

    Test failures and regressions

    line 17
  4. Distinctive:

    Error inspection: Read stack traces, error messages, and logs in full.

    line 33
  5. Distinctive:

    Boundary instrumentation: If the fault spans multiple layers or services such as CI workflows, build scripts, API services, or databases, …

    line 42
  6. Very specific:

    Upstream data flow tracing: If the error originates deep in the call stack, trace bad values backward to their origin.

    line 45
  7. Distinctive:

    Large-scale scope and context compaction defense: If the investigation requires surveying massive logs, hundreds of database files, or …

    line 48
  8. Distinctive:

    Test assumptions with isolated probes.

    line 69
  9. Distinctive:

    Falsifiable hypothesis: Write a single hypothesis specifying the cause and the expected outcome.

    line 71
  10. Distinctive:

    Failing regression test: Write the simplest reproducible automated test case that exposes the root cause before changing implementation …

    line 83
  11. Distinctive:

    Never reformat, "improve", or refactor adjacent unbroken code or comments.

    line 88
  12. Distinctive:

    Do not delete pre-existing dead code unless explicitly requested.

    line 89
  13. Very specific:

    Verification: Run the reproduction test and the broader test suite to confirm the fix works without regressions.

    line 93
  14. Distinctive:

    If fix 1 or fix 2 fails, return to Phase 1 to re-evaluate evidence.

    line 97
  15. Distinctive:

    If 3 fixes fail consecutively, stop immediately.

    line 98
  16. Distinctive:

    When you reach 3 failed fixes:

    line 109
  17. Distinctive:

    Document the 3 failed approaches and the architectural conflict they revealed.

    line 112
  18. Distinctive:

    Stop and ask the human partner to discuss redesigning the module boundary or data model.

    line 113
  19. Distinctive:

    When debugging multi-component systems, log state at each component boundary before proposing changes:

    line 117

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

Find the root cause before attempting fixes. Symptom fixes create new bugs and mask underlying flaws.

<HARD-GATE> Do not write code, edit files, or propose fixes until Phase 1 investigation is complete. Every technical issue requires an identified root cause before implementation. </HARD-GATE>

When to use

Use this workflow for any technical fault:

  • Test failures and regressions
  • Production bugs and runtime crashes
  • Unexpected behavior or corrupted state
  • Performance bottlenecks
  • Build failures and configuration faults

Apply this process especially when you feel pressure to apply a fast fix, when a previous fix failed, or when you have already attempted two or more changes.

The four phases

Complete each phase in order before moving to the next.

Phase 1. Root cause investigation

Gather evidence to explain what failed and why before touching production code.

  1. Error inspection. Read stack traces, error messages, and logs in full. Identify line numbers, file paths, and error codes without skipping warnings.
    • Completion criterion. Exact error text, file path, failing line number, and initial call site identified in notes.
  2. Reproduction. Execute the minimal command, script, or test case that triggers the defect deterministically. Consult references/reproduction-and-loops.md for fast feedback harness patterns, input minimization, and secret redaction rules.
    • Completion criterion. A single command or test triggers the failure consistently across consecutive runs.
  3. Change audit. Inspect git history and environment changes. Run git diff against the last known working commit. Check recent dependency updates and configuration changes.
    • Completion criterion. List of modified files, dependencies, and settings mapped against the failure symptom.
  4. Boundary instrumentation. If the fault spans multiple layers or services such as CI workflows, build scripts, API services, or databases, add diagnostic logging at each boundary. Log inputs, outputs, and environment variables across each boundary before running again.
    • Completion criterion. Diagnostic output isolates the exact boundary where expected state diverges.
  5. Upstream data flow tracing. If the error originates deep in the call stack, trace bad values backward to their origin. Consult root-cause-tracing.md in this directory for backward tracing instructions.
    • Completion criterion. Code location that produced the initial invalid value identified.
  6. Large-scale scope and context compaction defense. If the investigation requires surveying massive logs, hundreds of database files, or multi-repository history:
    • Dispatch a dedicated research or self subagent via invoke_subagent to isolate heavy tool outputs and prevent context window compaction in the primary agent session.
    • Persist intermediate findings directly to disk artifacts (<appDataDir>/brain/<conversation-id>/ or scratch/) instead of relying solely on chat memory.
    • Completion criterion. Heavy data collection delegated to a subagent and key synthesis written to a disk artifact.

Phase 1 exit criterion. The exact line of code, bad input, or environmental discrepancy causing the defect is identified.

Phase 2. Pattern analysis

Analyze the mechanism before designing a fix.

  1. Reference comparison. Locate similar working code in the same repository or official documentation. Read the reference implementation completely.
    • Completion criterion. Working reference implementation identified and reviewed.
  2. Difference inventory. Compare the working reference against the failing code line by line. Note differences in arguments, types, lifecycle timing, environment dependencies, and caller assumptions.
    • Completion criterion. Documented list of differences between working and broken components with zero unverified assumptions.

Phase 2 exit criterion. Structural and contextual differences between broken code and working code are documented.

Phase 3. Hypothesis and testing

Test assumptions with isolated probes.

  1. Falsifiable hypothesis. Write a single hypothesis specifying the cause and the expected outcome. Format as "The failure occurs because [cause], and changing [variable] will [outcome]."
    • Completion criterion. Written hypothesis documented in working notes.
  2. Targeted probe. Make the smallest possible change to confirm or refute the hypothesis. Change one variable at a time. Do not apply a complete fix during this step.
    • Completion criterion. Test or probe execution confirms or refutes the hypothesis. If refuted, return to Phase 1 with the new data.

Phase 3 exit criterion. Root cause hypothesis confirmed by probe results.

Phase 4. Implementation and verification

Apply the targeted fix at the source.

  1. Failing regression test. Write the simplest reproducible automated test case that exposes the root cause before changing implementation code. If testing frameworks are unavailable, create a standalone test script. Follow the test-driven-development skill.
    • Completion criterion. Automated test fails with the expected error against unfixed code.
  2. Surgical root cause fix. Modify code strictly at the identified root cause.
    • Touch only what must be changed to fix the defect. Match existing indentation and conventions.
    • Never reformat, "improve", or refactor adjacent unbroken code or comments.
    • Do not delete pre-existing dead code unless explicitly requested.
    • Clean up only orphan variables, imports, or functions created by the fix.
    • Completion criterion. Code edit confined strictly to the root cause with zero unrelated diff lines.
  3. Verification. Run the reproduction test and the broader test suite to confirm the fix works without regressions. Follow the verification-before-completion skill.
    • Completion criterion. New test passes, all existing tests pass, and diagnostic logs confirm clean execution.
  4. Failure loop limit.
    • If fix 1 or fix 2 fails, return to Phase 1 to re-evaluate evidence.
    • If 3 fixes fail consecutively, stop immediately. Do not attempt a fourth fix. Question the architecture.

Phase 4 exit criterion. Automated test passes, full test suite passes, and root cause is resolved at the source.

Escalation for repeated failures

Three consecutive failed fixes signal an architectural flaw rather than a localized bug. Signs of architectural flaws include:

  • Each fix introduces a new bug in a different component.
  • The fix requires broad refactoring across multiple files.
  • The fix requires complex workarounds to bypass existing abstractions.

When you reach 3 failed fixes:

  1. Halt all code modifications.
  2. Revert failed attempts to restore a clean state.
  3. Document the 3 failed approaches and the architectural conflict they revealed.
  4. Stop and ask the human partner to discuss redesigning the module boundary or data model.

Diagnostic instrumentation

When debugging multi-component systems, log state at each component boundary before proposing changes:

# Boundary 1: Workflow environment
echo "IDENTITY: ${IDENTITY:+SET}${IDENTITY:-UNSET}"

# Boundary 2: Build environment
env | grep IDENTITY || echo "IDENTITY not in environment"

# Boundary 3: Keychain access
security list-keychains
security find-identity -v

# Boundary 4: Signing invocation
codesign --sign "$IDENTITY" --verbose=4 "$APP"

This instrumentation identifies the exact layer where data or environment variables fail to propagate.

Disclosed reference

Consult these files in this directory for specialized debugging techniques:

  • root-cause-tracing.md for backward tracing through call stacks.
  • defense-in-depth.md for adding multi-layer validation after fixing root causes.
  • condition-based-waiting.md for replacing arbitrary sleeps with condition polling.

Related skills to invoke during debugging:

  • test-driven-development for writing red regression tests before fixing code.
  • verification-before-completion for verifying fixes before claiming resolution.

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.