agentleFS
takleb3rrytakleb3rry/claude-global-appbuilding-skills/skills/diagnose/SKILL.md

diagnose

Skill6 starsChanged 8 months agoMITView on GitHub

Systematic root cause analysis for bugs and failures. Use when something is broken, failing, or behaving unexpectedly — not for quick typos or obvious one-line fixes. Trigger on "diagnose this", "root cause", "why is this broken", "this isn't working", "investigate this error", "what's causing this", "trace this issue". Also use when /execute-phase Layer 1 or Layer 2 fails twice on the same task.

193 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use zoom-out, to-prd 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.
  • victorgarciaesgiSkill

    zoom-out

    Tell the agent to zoom out and give broader context or a higher-level perspective. Use when you're unfamiliar with a section of code or need to understand how it fits into the bigger picture.

    Also in 62 projects that use this

  • GoogleSkill

    to-prd

    Turn the current conversation into a PRD and publish it to the project issue tracker — no interview, just synthesis of what you've already discussed.

    Also in 58 projects that use this

  • GoogleSkill

    to-issues

    Break a plan, spec, or PRD into independently-grabbable issues on the project issue tracker using tracer-bullet vertical slices.

    Also in 54 projects that use this

  • simo97Skill

    write-a-skill

    Create new agent skills with proper structure, progressive disclosure, and bundled resources. Use when user wants to create, write, or build a new skill.

    Also in 46 projects that use this

  • simo97Skill

    edit-article

    The user will invoke this skill to help them edit an article.

    Also in 17 projects that use this

  • kennethkeimSkill

    ubiquitous-language

    Extract a DDD-style ubiquitous language glossary from the current conversation, flagging ambiguities and proposing canonical terms. Saves to UBIQUITOUS_LANGUAGE.md. Use when user wants to define domain terms, build a glossary, harden terminology, create a ubiquitous language, or mentions "domain model" or "DDD".

    Also in 16 projects that use this

  • +5 more from simo97

The file

Show its rules and text

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 175 edited versions we read keep these.

  • 12

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Reproduce consistently: Run the failing command or scenario.

    line 18
  2. Distinctive:

    Check recent changes: Run git diff and git log --oneline -10.

    line 20
  3. Distinctive:

    Trace backward through the call chain: Start at the error location and trace the data flow backward, level by level.

    line 22
  4. Distinctive:

    Find working examples: Search the codebase for similar code that works correctly.

    line 42
  5. Distinctive:

    Check documentation: If the failure involves a library, framework, or external API, read the relevant docs.

    line 46
  6. Distinctive:

    If three fix attempts have failed, STOP.

    line 66
  7. Distinctive:

    Write a failing test first: Create a test that reproduces the bug — it should fail with the current code and pass after the fix.

    line 87
  8. Distinctive:

    Run the full relevant test suite: Not just the new test — run related tests to verify no regressions.

    line 91
  9. Very specific:

    Verify with the /verify checklist: Before declaring the bug fixed:

    line 93
  10. Distinctive:

    READ: Read the full output

    line 96
  11. Distinctive:

    CHECK: Does it confirm the fix?

    line 97
  12. Distinctive:

    Do not say "fixed" without this evidence.

    line 99
  13. Distinctive:

    If you catch yourself thinking any of these, stop and follow the counter-action.

    line 105

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

Diagnose

Find the root cause. Fix the root cause. Prove the fix works. Do not guess.


Phase 1: Root Cause Investigation

Complete this phase before forming any hypothesis. No fixes, no theories — only evidence.

  1. Read the error completely. Full stack trace, full log output. Don't skim. Don't stop at the first line that looks relevant.
  2. Reproduce consistently. Run the failing command or scenario. If it doesn't fail reliably, you don't understand the trigger yet — vary inputs until you find the pattern.
  3. Check recent changes. Run git diff and git log --oneline -10. Correlate the failure with what changed. If the failure started after a specific commit, that's your search space.
  4. Trace backward through the call chain. Start at the error location and trace the data flow backward, level by level. Write it down explicitly:
Level 1: Error at [file:line] — [what failed]
Level 2: Called by [file:line] — [what it passed]
Level 3: Data came from [file:line] — [how it was constructed]
Level 4: That value originated at [file:line] — [source: DB query / API call / user input / config]
Level 5: Root input — [the actual source of the bad state]

Adapt depth to the problem. Stop when you reach the source of the incorrect state.

  1. For multi-component systems (frontend + API + database, or service-to-service): Add diagnostic logging at every component boundary BEFORE analyzing. Run the failing scenario once with instrumentation. Collect evidence from all boundaries. THEN analyze. Don't assume which component is at fault.

Phase 1 is complete when: You can state where the incorrect state originates and how it propagates to the error site. If you can't, keep investigating.


Phase 2: Pattern Analysis

  1. Find working examples. Search the codebase for similar code that works correctly. Same pattern, different module. Same API, different caller.
  2. Diff working vs. broken. List every difference — imports, argument order, types, middleware, configuration, environment. Don't assume any difference is irrelevant.
  3. Check documentation. If the failure involves a library, framework, or external API, read the relevant docs. Don't rely on memory of how it works.

Phase 2 is complete when: You have a concrete comparison between working and broken code, with differences enumerated.


Phase 3: Hypothesis and Testing

  1. Form one specific hypothesis. State it explicitly: "I think [X] because [Y]." Not "it might be" — commit to a specific, testable claim.
  2. Test with the smallest possible change. One variable at a time. If the hypothesis involves two potential causes, isolate and test each separately.
  3. If the hypothesis is wrong: Discard it cleanly. Form a NEW hypothesis from the evidence. Do not stack a second fix on top of a failed first fix — revert the failed attempt, then try the new approach from a clean state.
  4. Track your attempts. Mentally note: Attempt 1 — [hypothesis] — [result]. Attempt 2 — [hypothesis] — [result]. This prevents re-trying the same thing.

Phase 3 is complete when: You have a confirmed hypothesis — a change that makes the failure disappear, and you understand WHY it works.

Hard Gate: 3-Fix Limit

If three fix attempts have failed, STOP. Do not attempt fix #4. Instead:

"I've tried three approaches and none resolved the root cause:

  1. [Attempt 1] — [why it failed]
  2. [Attempt 2] — [why it failed]
  3. [Attempt 3] — [why it failed]

This suggests the issue may be architectural rather than a local bug. Here's what I think is actually going on: [assessment].

Options:

  1. [Different architectural approach]
  2. [Workaround with tradeoffs stated]
  3. [More investigation in a specific direction]

Which direction do you want to take?"


Phase 4: Implementation

  1. Write a failing test first. Create a test that reproduces the bug — it should fail with the current code and pass after the fix. This proves the fix actually addresses the problem and prevents regression.
  2. Implement the fix. Target the root cause identified in Phase 3. One fix, one cause. If you find yourself fixing multiple things, you haven't isolated the root cause.
  3. Run the full relevant test suite. Not just the new test — run related tests to verify no regressions.
  4. Verify with the /verify checklist. Before declaring the bug fixed:

    • IDENTIFY: What command proves the fix works? (the test suite, the original failing scenario, a specific curl/request)
    • RUN: Execute it
    • READ: Read the full output
    • CHECK: Does it confirm the fix? State the evidence. If not, return to Phase 3.

    Do not say "fixed" without this evidence.


Anti-Rationalization Table

If you catch yourself thinking any of these, stop and follow the counter-action.

If you're thinking...Do this instead
"It's probably just X""Probably" means you haven't traced it. Complete Phase 1 before theorizing.
"Let me just try this quick fix"Quick fixes without diagnosis create new bugs. Trace first, fix second.
"I already know what's wrong"Then the 5-level trace will take 30 seconds. Do it anyway. Your confidence is not evidence.
"This worked before, it must be something else"Check git diff. "Worked before" means something changed. Find what.
"I'll add some error handling to be safe"Error handling is not a fix. It's a mask. Find why the error happens, don't catch and suppress it.
"The error message is misleading"Maybe. But trace through the code to confirm. Don't dismiss the error — disprove it with evidence.
"This is a framework/library bug"Possible but unlikely. Verify by reproducing outside your code first. 95% of the time, it's your code.
"I need to refactor this whole thing"Not during diagnosis. Fix the bug first. Refactoring is a separate task.
"Let me restart from scratch on this part"Rewriting masks the bug instead of understanding it. The bug will likely reappear in the rewrite. Diagnose first.
"This is too complex to trace"Break it into smaller segments. Trace one component boundary at a time. Complexity is not an excuse to guess.

When to Use

  • Something is broken, failing, or behaving unexpectedly
  • /execute-phase Layer 1 or Layer 2 has failed twice on the same task
  • User says "diagnose", "root cause", "why is this broken", "trace this"
  • A test passes locally but fails in CI (environment-dependent bug)
  • A feature works in isolation but fails when integrated

When NOT to Use

  • Obvious one-line fix (typo, missing import, wrong variable name) — just fix it
  • The problem is "I don't know how to build X" — that's design, not debugging
  • Performance optimization — different methodology
  • The bundled /debug skill is available for quick, informal debugging sessions where the full 4-phase process is overkill

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.