agentleFS
XData-siXData-si/xdata-agenthub/skills/debugging-root-cause/SKILL.md

debugging-root-cause

Skill1 starsChanged 32 days agoMITView on GitHub

Systematically find the root cause of a bug, failing test or production error through reproduction, hypotheses and evidence before changing code. Use when something fails and the cause is not yet proven.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    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:

    Reproduce: Write down the smallest command, request or test that shows the failure.

    line 17
  2. Distinctive:

    Narrow down: Add targeted logging or assertions, shrink the input, isolate components.

    line 21
  3. Distinctive:

    Fix and protect: Add a regression test that fails without the fix.

    line 23
  4. Distinctive:

    Clean up: Remove temporary logging, and document the cause in the commit or PR description.

    line 24
  5. Distinctive:

    Only reproducible in production → collect read-only evidence.

    line 29
  6. Distinctive:

    No unrelated changes are included.

    line 53
  7. Distinctive:

    Do not run destructive commands, alter production data or disable security controls to "see if it helps".

    line 59

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “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

Debugging to Root Cause

Goal

Fix the cause, not the symptom. Every fix is backed by a reproduction that failed before and passes after.

Inputs

  • Exact error text, stack trace, logs, failing command or test, and when it started.
  • Environment: versions, configuration, data shape, recent changes (commits, deploys, dependency updates).

Procedure

  1. Reproduce. Write down the smallest command, request or test that shows the failure. If it is intermittent, measure the failure rate (for example 7 of 50 runs). No reproduction means the next step is collecting evidence, not editing code.
  2. Read the evidence completely. The whole stack trace, the first error rather than the last, logs around the timestamp. Note what is observed separately from what is assumed.
  3. Find what changed. Compare a working and a failing state: git log and git bisect, dependency lock diffs, configuration and environment differences, input data.
  4. Hypothesise. List 2–4 candidate causes, each with a test that would confirm or eliminate it. Test the cheapest discriminating one first.
  5. Narrow down. Add targeted logging or assertions, shrink the input, isolate components. Change one variable at a time and record results.
  6. Confirm the root cause. You can explain the full chain from trigger to symptom, and a deliberate change to the suspected cause toggles the failure.
  7. Fix and protect. Add a regression test that fails without the fix. Make the minimal change, then run the related test suites. Search for the same pattern elsewhere.
  8. Clean up. Remove temporary logging, and document the cause in the commit or PR description.

Decision points

  • Three failed fix attempts → stop patching; return to step 2 and question the architecture or assumptions.
  • The cause is in a dependency → pin or work around locally, and report upstream with the minimal reproduction.
  • Only reproducible in production → collect read-only evidence; do not experiment on production without authorization.

Anti-patterns

Changing several things at once; catching and ignoring the exception; adding retries or sleeps to hide races; "works on my machine" without an environment diff; declaring success without rerunning the original reproduction.

Example fixture

Symptom: test_invoice_total fails on CI only, passes locally.
Hypotheses: (1) timezone differs (CI=UTC) (2) locale decimal separator (3) test order dependency.
Discriminator: run locally with TZ=UTC → fails → hypothesis 1 confirmed; date boundary at 23:30 local time.

Common rationalizations

RationalizationReality
I know what it is, let me just fix it.Fixing without a reproduction means you cannot prove the fix. Write the failing reproduction first; it takes minutes.
Adding a retry or sleep makes it pass.That hides a race or dependency failure and makes it rarer, not gone. Find the mechanism.
It only fails on CI, so CI is broken.CI differs in a specific, discoverable way (timezone, parallelism, versions). Diff the environments.
Three attempts failed, one more tweak will do it.Repeated failed patches mean the mental model is wrong. Return to the evidence and question assumptions.

Acceptance checks

  • A reproduction exists and its before/after result is reported exactly.
  • The root cause statement explains the mechanism, not only the location.
  • A regression test fails without the fix (shown or stated as NOT RUN with a reason).
  • No unrelated changes are included.

Output

Reproduction, evidence log, root cause, fix, regression test, and any remaining risk.

Safety

Do not run destructive commands, alter production data or disable security controls to "see if it helps". Redact secrets from logs before sharing them.

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.