agentleFS
cohen-lielcohen-liel/agent-skills/root-cause-first/SKILL.md

root-cause-first

Skill15 starsChanged 5 months agoMITView on GitHub

Root-cause-first debugging and repair workflow. Use when asked to fix a bug, runtime error, failing test, broken tool/agent behavior, unexpected logs, regression, flaky behavior, architecture issue, or any request that says "fix", "debug", "solve from the root", "no band-aids", "no fallback", or "understand what is happening before changing code". Do not use for greenfield feature work, mechanical edits, or cleanup without an observed failure.

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. benjaminard/fable-skills★ 30same name
    2. Tcuzzo/backs-aios-skills★ 2same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repositoryOne other file it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

20 rules. About 0 are common, 15 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈15

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill to prevent premature patches.

    line 8
  2. Very specific:

    If the root cause is duplicated constants, scattered policy, parallel calculations, copied parsing, or multiple modules answering the same …

    line 25
  3. Distinctive:

    Do not use this skill for:

    line 29
  4. Distinctive:

    Read the code that produces the failure and the code that consumes its output.

    line 45
  5. Distinctive:

    Prefer logs, tests, traces, raw API responses, local reproduction, and call sites over assumptions.

    line 46
  6. Distinctive:

    If there are multiple plausible causes, list what evidence confirms or eliminates each one.

    line 51
  7. Distinctive:

    Do not implement until there is one primary cause or a clearly bounded uncertainty.

    line 52
  8. Distinctive:

    Do not add fallback, retry, catch-and-continue, synthetic success, timeout inflation, broad parsing, or error suppression unless the root …

    line 55
  9. Distinctive:

    If such handling is truly needed, state why it is not masking the failure and what invariant it preserves.

    line 56
  10. Distinctive:

    Keep the patch scoped to the root cause.

    line 60
  11. Very specific:

    If the source of the bad state is duplicated or scattered truth, consolidate it through ssot-enforcer instead of adding a local workaround.

    line 61
  12. Distinctive:

    Add diagnostics when future failures would otherwise be ambiguous.

    line 62
  13. Distinctive:

    Verify against the original failure.

    line 64
  14. Distinctive:

    Add or update a regression test that fails on the old behavior.

    line 65
  15. Distinctive:

    Run the narrow test first, then broader typecheck/test coverage as risk requires.

    line 66
  16. Very specific:

    If the fix cannot be fully verified in-environment (visual/UI/device-only behavior, or unavailable services), say so explicitly and name …

    line 67
  17. Very specific:

    Root-cause trace: Follow where user is built.

    line 83
  18. Very specific:

    Verification: Add a regression test: loadUser() for a pre-backfill account returns a non-null profile.

    line 97
  19. Distinctive:

    Stop and ask or report a blocker when:

    line 101
  20. Distinctive:

    Keep the close-out short:

    line 108

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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

Root Cause First

Use this skill to prevent premature patches. The goal is to make the smallest correct change only after the failure mechanism is understood.

Red Flags — Stop If You Catch Yourself Thinking

These thoughts mean you are about to ship a band-aid. Stop and find the mechanism first.

ThoughtReality
"I'll add a ?. or null-check so it stops crashing"You are hiding the signal. Ask why it is null and fix that.
"Wrapping it in try/catch makes the error go away"Catch-and-continue turns a loud bug into a silent one.
"The test is flaky, let me add a retry or a longer timeout"Flaky means a real race or order dependency. Retry hides it.
"I'll widen the parser to accept the weird input too"The weird input is the clue. Find who produced it.
"I'll return a default on error so the flow continues"Synthetic success masks the failure from everyone downstream.
"It works now, I am not sure why"Then it is not fixed. You moved the bug.

Relationship To SSOT Enforcer

If the root cause is duplicated constants, scattered policy, parallel calculations, copied parsing, or multiple modules answering the same question, switch to ssot-enforcer for the consolidation step. After consolidation, return here to verify the fix against the original failure.

When Not To Use

Do not use this skill for:

  • New features or design work where there is no failure to explain.
  • Mechanical edits such as renames, formatting, dependency bumps, or documentation cleanup.
  • Broad architecture cleanup unless it is tied to a concrete symptom, failing test, bad runtime behavior, or user-reported regression.

Required Workflow

  1. State the observed failure in concrete terms.
    • Quote the exact error, log line, failed assertion, bad behavior, or user-visible symptom.
    • Identify where in the execution path the failure happens.
  2. Reconstruct the intended contract.
    • Determine what the component is supposed to guarantee.
    • Identify upstream inputs, downstream consumers, and invariants that must hold.
  3. Trace the real path before editing.
    • Read the code that produces the failure and the code that consumes its output.
    • Prefer logs, tests, traces, raw API responses, local reproduction, and call sites over assumptions.
    • Distinguish provider/tool behavior from adapter/parser/orchestrator behavior.
  4. Name the root cause.
    • Explain the mechanism that makes the observed failure inevitable or likely.
    • If there are multiple plausible causes, list what evidence confirms or eliminates each one.
    • Do not implement until there is one primary cause or a clearly bounded uncertainty.
  5. Reject band-aids explicitly.
    • Do not add fallback, retry, catch-and-continue, synthetic success, timeout inflation, broad parsing, or error suppression unless the root cause proves that behavior is the correct product contract.
    • If such handling is truly needed, state why it is not masking the failure and what invariant it preserves.
  6. Implement the root fix.
    • Change the source of the bad state or the incorrect contract boundary.
    • Keep the patch scoped to the root cause.
    • If the source of the bad state is duplicated or scattered truth, consolidate it through ssot-enforcer instead of adding a local workaround.
    • Add diagnostics when future failures would otherwise be ambiguous.
  7. Verify against the original failure.
    • Add or update a regression test that fails on the old behavior.
    • Run the narrow test first, then broader typecheck/test coverage as risk requires.
    • If the fix cannot be fully verified in-environment (visual/UI/device-only behavior, or unavailable services), say so explicitly and name exactly what a human must check. Do not claim success you could not observe.
    • In the final answer, report root cause, fix, and verification.

Worked Example

Symptom. TypeError: cannot read 'email' of undefined thrown in renderProfile() for ~2% of users.

Band-aid (what to avoid).

// Crash disappears, but those users now silently render a blank email.
const email = user.profile?.email ?? "";

The optional chain suppresses the only signal that something upstream is wrong.

Root-cause trace. Follow where user is built. loadUser() returns the record before profile is hydrated for accounts created before the profile backfill. The invariant "every user has a profile" is violated at the data layer, not in the view.

Root fix. Enforce the invariant at the source so every consumer can trust it:

// loadUser() now owns the invariant: it always returns a non-null profile.
function loadUser(id) {
  const row = db.fetchUser(id);
  return { ...row, profile: row.profile ?? defaultProfile(row.id) };
}

Now renderProfile() can trust its input and the ?. is unnecessary. (The invariant has exactly one owner — see ssot-enforcer.)

Verification. Add a regression test: loadUser() for a pre-backfill account returns a non-null profile; renderProfile() renders without optional chaining and the old input reproduces the original crash on the unpatched code.

Stop Conditions

Stop and ask or report a blocker when:

  • The failure cannot be reproduced or located after reading the relevant path.
  • Required credentials, services, logs, or artifacts are unavailable.
  • Fixing the real cause requires a product decision rather than an engineering correction.

Final Answer Shape

Keep the close-out short:

  • Root cause: one concrete mechanism.
  • Fix: what changed and where.
  • Verification: commands/tests run and any remaining risk.

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.