agentleFS
MorningStar0709MorningStar0709/trae-agent-enhancements/skills/systematic-debugging/SKILL.md

systematic-debugging

Skill18 starsChanged 7 months agoMITView on GitHub

Use when debugging bugs, test failures, build breaks, performance regressions, or unclear behavior before proposing a fix, including Chinese requests such as “逐步排查”“为什么失败”“先定位原因”“不要先猜修复”. Do not use for straightforward implementation tasks, pure document edits, or issues that already have a confirmed root cause and only need mechanical changes.

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 9 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

  • +8 more from mjunaidca

The file

Show its rules and text

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 173 edited versions we read keep these.

  • 12

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read the phenomenon itself completely first:

    line 42
  2. Distinctive:

    If the symptom is unclear, clarify it.

    line 48
  3. Distinctive:

    If it cannot be reproduced stably, continue adding logs and observation points instead of changing code directly.

    line 54
  4. Distinctive:

    Keep only one root cause hypothesis at a time, formatted as explicitly as possible:

    line 86
  5. Very specific:

    When these tools fail due to MCP unavailability, refer to environment-resilience rule for the graceful MCP degradation chain (retry → …

    line 110
  6. Very specific:

    When a command fails due to port conflicts or zombie processes, refer to port-conflict-recovery rule (identify → kill → verify → retry).

    line 111
  7. Distinctive:

    When running commands on a Windows host, use PowerShell-compatible syntax.

    line 112
  8. Distinctive:

    When needing to clarify reproduction steps, input conditions, or environment differences, use structured questions in the current …

    line 113
  9. Very specific:

    If a fix needs to be implemented later, switch to test-driven-development.

    line 114
  10. Distinctive:

    If you see these thoughts, return to the investigation phase immediately:

    line 118
  11. Distinctive:

    Cannot reproduce: Add logs, state outputs, or minimize inputs.

    line 128
  12. Distinctive:

    More than three fix attempts fail: Stop patching locally and switch to an architectural discussion.

    line 131
  13. Distinctive:

    After completing the debugging phase, the output must contain at least:

    line 135
  14. Distinctive:

    Use this fixed skeleton by default:

    line 142
  15. Distinctive:

    If the root cause is not yet located, do not output a fix.

    line 163
  16. Very specific:

    If the root cause is non-obvious or the debugging uncovered a subtle system behavior, invoke self-improvement to log the finding as a …

    line 180

“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

Use This Skill

  • The user reports a bug, test failure, build break, abnormal behavior, or performance issue.
  • You have already tried 1-2 fixes but the issue is not stably resolved.
  • The issue spans multiple components, scripts, services, threads, or async boundaries.
  • The user asks to "debug step by step", "locate the cause first", or "don't guess the fix".

Do Not Use

  • The user just wants you to implement a clear feature, with no abnormal or failing symptoms.
  • The user is asking for a normal code review; prioritize requesting-code-review or the environment's code review process.
  • The issue is already clear enough that only mechanical changes remain, needing no debugging.
  • The failure is a Chrome DevTools MCP connection, startup, or missing tool issue; prioritize troubleshooting.

Input Contract

Required Inputs:

  • At least one observable symptom, such as an error message, failing test, abnormal behavior, performance degradation, or build failure.

Optional but highly recommended inputs:

  • Reproduction steps.
  • Error logs, stack traces, exit codes.
  • Recent changes, environment differences, config differences.
  • Expected behavior vs. actual behavior.

Missing input handling:

  • Symptoms insufficient to judge the issue: Clarify the phenomenon first; do not modify code directly.
  • Unable to reproduce stably: Prioritize adding observation points and finding the minimal reproduction path.
  • Only "please fix it" without failure evidence: Collect evidence first, then decide whether to enter the fix phase.

Execution Protocol

1. Read the Symptom

Read the phenomenon itself completely first:

  • Error messages, stack traces, failing test names, exit codes.
  • Time of first occurrence and trigger conditions.
  • Whether it reproduces stably.
  • Recent code, config, dependency, or environment changes.

If the symptom is unclear, clarify it. Do not start fixing.

2. Reproduce Stably

Record minimal reproduction steps. Narrow down inputs, scope, and target files as much as possible. If it cannot be reproduced stably, continue adding logs and observation points instead of changing code directly.

3. Establish Evidence Chain

Record inputs, outputs, and state for each suspicious boundary:

  • What was received before entering the component.
  • What was produced after leaving the component.
  • Whether environment variables, configs, thread states, and network results are passed correctly.
  • At which layer it starts deviating from expectations.

Multi-layer system example:

Write-Host "=== Workflow layer ==="
Write-Host ("IDENTITY: " + ($(if ($env:IDENTITY) { "SET" } else { "UNSET" })))

Write-Host "=== Build script layer ==="
Get-ChildItem Env:IDENTITY -ErrorAction SilentlyContinue

Write-Host "=== Signing step ==="
& codesign --sign $env:IDENTITY --verbose=4 $env:APP

4. Compare with Normal Path

Find a "working similar implementation" first, then compare differences:

  • Normal tests, commands, or modules in the same repository.
  • Reference implementations under the same pattern.
  • Differences in dependencies, initialization order, config values, or boundary conditions. Base conclusions on traceable differences, not intuition.

5. Propose a Single Hypothesis

Keep only one root cause hypothesis at a time, formatted as explicitly as possible:

I believe X is the root cause because Y; if this judgment is correct, then minimal validation should show Z.

Then do only one minimal validation. Do not stack multiple fixes simultaneously.

6. Write Failing Validation First, Then Fix

Once the root cause is clear:

  • Prioritize writing a failing test or minimal reproduction script.
  • Fix only the root cause; do not refactor unrelated things along the way.
  • Re-run the reproduction path and related tests after the fix.

This step should integrate with test-driven-development.

7. Fallback on Fix Failure

  • 1st validation failure: Update hypothesis, return to Step 3.
  • 2nd validation failure: Expand evidence scope, re-check the call chain.
  • 3rd validation failure: Stop "trying one more time", start questioning the architecture or approach itself.

Trae / Windows Conventions

  • In Trae, prioritize using Read, Grep, SearchCodebase, GetDiagnostics, and RunCommand to collect evidence.
  • When these tools fail due to MCP unavailability, refer to environment-resilience rule for the graceful MCP degradation chain (retry → terminal fallback → report).
  • When a command fails due to port conflicts or zombie processes, refer to port-conflict-recovery rule (identify → kill → verify → retry).
  • When running commands on a Windows host, use PowerShell-compatible syntax; only use POSIX syntax when the command explicitly runs inside a container, remote Linux, or WSL.
  • When needing to clarify reproduction steps, input conditions, or environment differences, use structured questions in the current environment instead of guessing.
  • If a fix needs to be implemented later, switch to test-driven-development; if preparing to declare it fixed, switch to verification-before-completion.

Red Lines

If you see these thoughts, return to the investigation phase immediately:

  • "Let's fix it temporarily first, and look at it later."
  • "I guess the problem is here, let's change it and see."
  • "Let's change several places at once and run the tests."
  • "Skip the tests, let's click manually to see."
  • "Although I don't understand it yet, this change will probably work."
  • "Let's try one more time" when you have already tried more than twice.

Failure Handling

  • Cannot reproduce: Add logs, state outputs, or minimize inputs; do not fix directly.
  • Missing context: Confirm environment, data, commands, and expected behavior with the user.
  • External dependencies unstable: Explicitly mark dependency risks and isolate locally verifiable parts.
  • More than three fix attempts fail: Stop patching locally and switch to an architectural discussion.

Output Contract

After completing the debugging phase, the output must contain at least:

  • Phenomenon: What exactly failed.
  • Evidence: What logs, command outputs, or code differences you saw.
  • Root Cause Hypothesis: What is the most credible cause currently.
  • Validation: How you prove or disprove this hypothesis.
  • Next Steps: Enter fix, continue collecting evidence, or request clarification.

Use this fixed skeleton by default:

调试阶段已完成。

**Phenomenon:**
- [What failed]

**Evidence:**
- [Logs / command outputs / code diffs]

**Most Credible Root Cause Hypothesis:**
- [If not yet located, write `- Not yet located`]

**Validation Actions:**
- [How to prove or disprove]

**Next Steps:**
- [If verified: Enter `test-driven-development` for high-risk fixes, or `executing-plans` for straightforward changes / If unverified: Propose next diagnostic step / If blocked: Ask for missing context]

If the root cause is not yet located, do not output a fix.

Context Payload (for downstream handoff)

When handing off to the next skill (e.g., test-driven-development, executing-plans), append this context block to the output. It preserves the debugging journey so the fix agent does not lose prior context:

**[Context Payload]**
**Phenomenon:** [What exactly failed]
**Root Cause:** [Confirmed hypothesis or "not yet located"]
**Ruled Out:** [What was investigated and discarded, to avoid repeat work]
**Evidence Collected:** [Logs, command outputs, code diffs — or paths to them]
**Residual Risk:** [What is still uncertain, what edge cases remain]
**Affected Components:** [Files, services, or layers involved]
**Fix Guidance:** [One-sentence summary of what needs to change]

If the root cause is non-obvious or the debugging uncovered a subtle system behavior, invoke self-improvement to log the finding as a knowledge_gap or insight before exiting.

Resources

  • root-cause-tracing.md: Tracing the source of the problem backward along the call stack.
  • defense-in-depth.md: How to add layered validation after the root cause is confirmed.
  • condition-based-waiting.md: Replacing hardcoded sleeps with condition-based waiting.
  • condition-based-waiting-example.ts: Reference implementation of condition-based waiting.

Integration

  • test-driven-development: Establish a failing test for the bug and drive the fix.
  • executing-plans: Downstream — for straightforward fixes where the root cause is clear and no complex implementation plan is needed.
  • writing-plans: Downstream — for complex root cause fixes that need architectural design or multi-step planning before execution.
  • verification-before-completion: Downstream — re-verify whether the conclusion is supported by evidence after fixing.

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.