diagnose
Skill72 starsChanged 7 months agoMITView on GitHub
Each stage produces a required artifact saved to .investigations/<task_id>/ and a handoff contract (per Rule 16) to the next agent. Goal: Build the fastest reliable pass/fail signal for the exact symptom before explaining the cause. The feedback loop is the highest-leverage part of diagnosis. Do not proceed to root-cause analysis until there is a loop that can reproduce the user's symptom or a documented reason why no loop is possible. Try these in roughly this order: Improve the loop before…
126 other projects use a version of this.
Adopted by
Most recently taken up by
- MagicJosh/rastheir own version, first seen Oct 6, 2026
- hmjBill/skillstheir own version, first seen Oct 5, 2026
- morodomi/dev-crewtheir own version, first seen Oct 5, 2026
- timmo001/skillstheir own version, first seen Oct 5, 2026
- 5dive-ai/skillstheir own version, first seen Oct 5, 2026
- gilsmt/skillstheir own version, first seen Oct 4, 2026
Used with
Projects with it also use zoom-out, to-issues 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.
Hollis36Skillzoom-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 38 projects that use this
ninehillsSkillto-issues
Break a plan, spec, or PRD into independently-grabbable issues on the project issue tracker using tracer-bullet vertical slices.
Also in 34 projects that use this
Hollis36Skillto-prd
Turn the current conversation context into a PRD and publish it to the project issue tracker. Use when user wants to create a PRD from the current context.
Also in 38 projects that use this
kayamanSkilledit-article
Edit and improve articles by restructuring sections, improving clarity, and tightening prose. Use when user wants to edit, revise, or improve an article draft.
Also in 11 projects that use this
kayamanSkillrequest-refactor-plan
Guides creating a detailed refactor plan with tiny commits via user interview, then files it as a GitHub issue. Use when user wants to plan a refactor, create a refactoring RFC, or break a refactor into safe incremental steps.
Also in 9 projects that use this
AnasX7Skillscaffold-exercises
Create exercise directory structures with sections, problems, solutions, and explainers that pass linting. Use when user wants to scaffold exercises, create exercise stubs, or set up a new course section.
Also in 13 projects that use this
- +2 more from kayaman
Other versions126 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 126
- github/awesome-copilot★ 40ksame name
- pedrohcgs/claude-code-my-workflow★ 1.6ksame name
- getagentseal/founder-playbook★ 711same name
- amazingloft999-droid/mattpocock-skills★ 422same name
- openvetta/open-vetta★ 287same name
- microsoft/AutoSaddler★ 236same name
- alex-on-ai/WebReaper★ 149same name
- aurorasoft2/Matt_Pocock_Skills★ 133same name
- avibebuilder/claude-prime★ 120same name
- KerberosClaw/kc_ai_skills★ 79same name
116 more not listed
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 repository117 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agent-healthSkill
- agent-styleSkill
- angular-best-practicesSkill
- annotateSkill
- api-designSkill
- architecture-decision-recordsSkill
- aws-serverlessSkill
- backend-architectSkill
- backend-patternsSkill
- brainstormSkill
- bug-reportSkill
- changelogSkill
- claude-apiSkill
- cloud-architectSkill
- cloud-run-puppeteerSkill
- code-review-checklistSkill
- code-reviewSkill
- code-simplificationSkill
- codex-sddSkill
- commitSkill
- context-engineeringSkill
- database-architectSkill
- db-reviewSkill
- deep-interviewSkill
- design-reviewSkill
- design-systemSkill
- devops-deploySkill
- django-patternsSkill
- docker-patternsSkill
- dotnet-backend-patternsSkill
- dreamSkill
- drizzle-orm-expertSkill
- estimateSkill
- event-sourcing-architectSkill
- fastapi-proSkill
- fork-joinSkill
- freezeSkill
- frontend-designSkill
- frontend-patternsSkill
- frontend-ui-dark-tsSkill
- gate-checkSkill
- gemini-api-integrationSkill
- gitlab-ci-patternsSkill
- guardSkill
- handoffSkill
- hotfixSkill
- hybrid-cloud-architectSkill
- kubernetes-architectSkill
- laravel-patternsSkill
- launch-checklistSkill
- learnerSkill
- llm-app-patternsSkill
- localizeSkill
- map-systemsSkill
- map-workflowSkill
- markdown-injection-scannerSkill
- microservices-patternsSkill
- milestone-reviewSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
10 rules. 0 are common, 5 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 114 edited versions we read keep these.
5
Distinctive
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
- Distinctive: line 71
Do not treat Stage 0 as warm-up.
- Distinctive: line 74
If no credible loop can be built, stop and report what was tried.
- Distinctive: line 218
All 3 options must have distinct scope (not three flavors of the same fix)
- Very specific: line 232
Create A2A handoff contract (Rule 16) via /handoff:
- Very specific: line 242
All intermediate reports MUST be saved to .investigations/<task_id>/:
- Very specific: line 255
Retention: Keep until bug is closed + 30 days, then archive to .investigations/archive/.
- Distinctive: line 269
Rule 6 (Layered Recovery): If any stage fails once, retry with fresh context before escalating
- Very specific: line 270
Rule 14 (Circuit Breaker): Read production/session-state/circuit-state.json before invoking each agent
- Very specific: line 271
Rule 15 (Decision Ledger): Every stage transition logs to decision_ledger.jsonl
- Distinctive: line 320
After Stage 4 completes, summarize in ≤ 5 lines:
“Common” is measured: kept by at least 6 in 10 of the 114 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.
Files
Skill: /diagnose — Complex Bug Diagnostic Pipeline
When to invoke (and when NOT to)
Use /diagnose when:
- Bug reproduces but root cause is unclear after one read-pass of the failing code
- Previous fix attempts have been reverted ≥ 2 times (symptoms return)
- Failure is intermittent (flaky test, race condition, timing-dependent)
- Failure occurs in unfamiliar code (agent has no prior context)
- User has explicitly requested
/diagnoseor "deep investigation" - Circuit Breaker (Rule 14) tripped on the specialist agent that normally handles this domain
Do NOT use /diagnose when:
- Cause is obvious (null ref, typo, missing import, incorrect import path)
- Fix is < 10 LOC and has a clear success check
- Bug is in code you just wrote this session (read-pass + local reasoning is faster)
- User wants a quick patch and has accepted the tradeoff
Pipeline overview
Feedback Loop -> Investigation -> Verification -> Solution -> Lead Programmer
(signal) (hypothesis) (devil's adv.) (tradeoffs) (assign + exec)
repro/check command investigation.json verification.json solution.json implementation
(fast deterministic (root_cause, (status: confirmed | (3 options: (delegates to
pass/fail signal) evidence[], refuted | inconclusive, Quick/Strategic/ backend-developer,
confidence) reproduction_steps) Future-Proof) qa-engineer, etc.)Each stage produces a required artifact saved to .investigations/<task_id>/ and a handoff contract (per Rule 16) to the next agent.
Stage 0 — Feedback Loop
Goal: Build the fastest reliable pass/fail signal for the exact symptom before explaining the cause.
The feedback loop is the highest-leverage part of diagnosis. Do not proceed to root-cause analysis until there is a loop that can reproduce the user's symptom or a documented reason why no loop is possible.
Try these in roughly this order:
- Failing test at the seam that reaches the bug.
- CLI or script invocation with fixture input and expected output.
- Curl/HTTP request against a running service.
- Headless browser script with DOM, console, or network assertions.
- Replay of a captured payload, event, HAR, log, or trace.
- Throwaway harness that calls the affected code path in isolation.
- Property/fuzz loop for broad wrong-output symptoms.
- Bisection or differential loop between known-good and known-bad states.
Improve the loop before investigating:
- Faster: remove unrelated setup and narrow the command.
- Sharper: assert the specific symptom, not merely "does not crash".
- More deterministic: pin time, seed randomness, isolate filesystem/network, or raise intermittent reproduction frequency with stress runs.
Do not treat Stage 0 as warm-up. It is the main leverage point. A bad loop produces fake certainty, weak hypotheses, and symptom-only fixes.
If no credible loop can be built, stop and report what was tried. Ask for access to the reproducing environment, a captured artifact, or permission to add temporary instrumentation. Do not proceed on a vibe.
Stage 1 — Investigation
Agent: diagnostics (Investigation role)
Goal: Produce ranked falsifiable root-cause hypotheses backed by empirical evidence.
Inputs
- Symptom description (from user or TODO.md bug ID)
- Reproduction steps (or "cannot reproduce" + environment)
- Relevant log lines, stack traces, error IDs
- Feedback loop command/check from Stage 0, or a documented reason no loop can currently be built
Required output — investigation.json
{
"task_id": "BUG-417",
"symptom": "POST /api/orders returns 500 when cart has ≥10 items",
"reproduction": {
"steps": ["...", "..."],
"frequency": "100% | intermittent (~30%) | once",
"environment": "staging-eu-west-1"
},
"feedback_loop": {
"command": "npm test -- checkout.e2e.test.ts",
"signal": "Fails with timeout before hydration marker appears",
"reliable": true
},
"ranked_hypotheses": [
{
"rank": 1,
"cause": "Test clicks #submit before React hydration completes on slow CI runners",
"prediction": "Waiting for the hydration marker will make the failure disappear without adding a fixed sleep"
},
{
"rank": 2,
"cause": "Submit button selector matches a hidden stale node",
"prediction": "Asserting the visible button count will expose multiple matching nodes"
}
],
"hypothesis": {
"root_cause": "OrderService.calculateTotal() N+1 query exhausts pool when cart.items.length > 9",
"confidence": "high | medium | low",
"falsifiable_by": "Run with pool_size=50; if error disappears, cause confirmed"
},
"evidence": [
{"type": "log", "ref": ".investigations/BUG-417/pg-pool-exhausted.log", "summary": "..."},
{"type": "code", "ref": "src/services/order.service.ts:142", "summary": "Unbounded .map+await"}
],
"unknowns": ["Why only eu-west-1?", "When did this start?"],
"next_agent": "diagnostics",
"next_stage": "verification"
}Quality gate (Lead Programmer rejects if):
feedback_loopis missing and no blocked-loop explanation existsfeedback_loop.signalis vague, broad, or does not isolate the user's symptomranked_hypotheseshas fewer than 3 items unless the evidence makes a single cause unavoidable- Any hypothesis lacks a falsifiable prediction
hypothesis.falsifiable_byis vague ("check if it works")evidencehas fewer than 2 items (unverifiable)unknownsis empty butconfidence: low(contradictory)
Stage 2 — Verification
Agent: diagnostics (Verification role)
Goal: Attempt to refute the hypothesis. Only confirmed if refutation fails.
Inputs
investigation.json(from Stage 1)- Access to staging/test environment
- The Stage 0 feedback loop, rerun before and after each meaningful probe
Verification is invalid if it does not go back through the Stage 0 loop. A fix-looking local observation that bypasses the loop is not confirmation.
Required output — verification.json
{
"task_id": "BUG-417",
"status": "confirmed | refuted | inconclusive",
"triangulation": [
{"method": "reproduce_with_fix_applied", "result": "Error gone with pool_size=50"},
{"method": "reproduce_without_fix", "result": "Error returns at 10 items"},
{"method": "adjacent_test_case", "result": "9 items = OK, 10 items = fail → threshold confirmed"}
],
"counter_hypotheses_ruled_out": [
"DB slowness (ruled out: p99 < 50ms)",
"Network flaps (ruled out: no packet loss in window)"
],
"confidence": "high",
"recommendation": "Proceed to Solution stage — cause confirmed necessary AND sufficient"
}Decision flow
status | Next action |
confirmed | Proceed to Solution stage (same diagnostics agent) |
refuted | Return to Investigation stage with counter-evidence. Max 2 round-trips. |
inconclusive | STOP. Surface to user with all evidence. Do NOT proceed to Solution stage. |
Stage 3 — Solution
Agent: diagnostics (Solution role)
Goal: Generate 3 solution options with explicit tradeoffs; never pick silently.
Required output — solution.json
{
"task_id": "BUG-417",
"options": [
{
"name": "Quick",
"description": "Increase pool_size from 20 → 50 in db.ts",
"scope_loc": 1,
"risk_tier": "Low",
"tradeoff": "Masks root cause; higher RAM; future growth hits same wall"
},
{
"name": "Strategic",
"description": "Rewrite calculateTotal() to batch via IN-clause",
"scope_loc": 40,
"risk_tier": "Medium",
"tradeoff": "Fixes N+1 permanently; requires regression test on discount logic"
},
{
"name": "Future-Proof",
"description": "Introduce DataLoader pattern across service layer",
"scope_loc": 300,
"risk_tier": "High",
"tradeoff": "Eliminates entire class of N+1 bugs; 2-3 day refactor; needs ADR"
}
],
"recommendation": "Strategic — best risk/value ratio. Quick only if release is < 24h."
}Quality gate
- All 3 options must have distinct scope (not three flavors of the same fix)
tradeoffmust state what is sacrificed, not just "takes longer"recommendationmust cite a criterion (time budget, risk tier, blast radius)- The selected option's acceptance criteria must include rerunning the original feedback loop from Stage 0 and a regression test when a correct seam exists
Stage 4 — Finalization
Agent: lead-programmer
Goal: Select option, assign specialist, track execution.
Actions
- Review
solution.jsonwith user (ifrisk_tier: Highorscope_loc > 100) - Select option → write selection to
.investigations/<task_id>/decision.md - Create A2A handoff contract (Rule 16) via
/handoff:lead-programmer → backend-developer(orfrontend-developer,data-engineer)- Acceptance criteria derived from
investigation.hypothesis.falsifiable_by
- Append ledger entry (Rule 15) to
production/traces/decision_ledger.jsonl:
{"ts":"2026-04-17T14:22:00Z","session":"main","agent_id":"lead-programmer","task_id":"BUG-417","request":"/diagnose BUG-417","reasoning":"Verified N+1 as necessary+sufficient; selected Strategic per Solution-stage recommendation","choice":"Strategic refactor of calculateTotal()","outcome":"pass","risk_tier":"Medium","duration_s":1840}Artifact storage
All intermediate reports MUST be saved to .investigations/<task_id>/:
.investigations/
└── BUG-417/
├── investigation.json # Stage 1 output
├── verification.json # Stage 2 output
├── solution.json # Stage 3 output
├── decision.md # Stage 4 — human-readable rationale
├── evidence/ # logs, screenshots, traces referenced in reports
└── handoffs/ # A2A contracts (copied from .tasks/handoffs/)Retention: Keep until bug is closed + 30 days, then archive to .investigations/archive/.
Escalation paths
| Trigger | Escalate to |
diagnostics circuit OPEN in Investigation (Rule 14) | Surface raw symptom to user; skip pipeline, request manual triage |
Verification stage returns inconclusive twice | Surface to user; request manual reproduction |
| Solution stage cannot produce 3 distinct options | Escalate to technical-director — scope unclear |
| User rejects all 3 options | Return to Investigation stage; hypothesis likely wrong |
| Bug reoccurs after fix merges | Restart /diagnose with new task_id; link prior investigation in unknowns[] |
Integration with coordination rules
- Rule 6 (Layered Recovery): If any stage fails once, retry with fresh context before escalating
- Rule 14 (Circuit Breaker): Read
production/session-state/circuit-state.jsonbefore invoking each agent - Rule 15 (Decision Ledger): Every stage transition logs to
decision_ledger.jsonl - Rule 16 (A2A Handoff): Stage 1→2, 2→3, 3→4 each require a handoff contract in
.tasks/handoffs/
Concrete example — "Flaky checkout test"
Symptom: checkout.e2e.test.ts fails ~20% of CI runs; local always passes.
/diagnose flaky-checkout-e2e
↓
Stage 1 → Investigation (diagnostics)
hypothesis: "Test clicks #submit before React hydration completes on slow CI runners"
evidence: [CI traces showing hydration marker missing, local has DevTools overhead masking timing]
confidence: medium (cannot reproduce locally)
↓
Stage 2 → Verification (diagnostics)
triangulation:
- Inject 500ms delay before click → test passes 50/50 runs ✓
- Remove delay → fails 9/50 ✗
- Check for hydration marker instead of fixed delay → passes 50/50 ✓
status: confirmed
↓
Stage 3 → Solution (diagnostics)
Quick: add sleep(500ms) [masks issue]
Strategic: waitFor hydration marker [addresses root cause]
Future-Proof: custom test util that always waits for RSC boundary [reusable]
recommendation: Strategic
↓
Stage 4 → lead-programmer
selects Strategic; assigns to qa-engineer
handoff contract: "qa-engineer updates checkout.e2e.test.ts to use waitFor(hydrationMarker)"
acceptance_criteria: ["10 CI runs in a row pass", "no sleep() in test"]
ledger entry writtenCommon pitfalls
| Pitfall | Fix |
| Hypothesizing before building a loop | Return to Stage 0. A diagnosis without a signal is speculation. |
| Keeping a slow or blurry loop | Rework Stage 0 until the signal is fast, specific, and trustworthy. |
| Skipping Verification ("cause is obvious") | Verifier exists specifically to catch "obvious but wrong" hypotheses |
| Investigator produces only 1 hypothesis | Reject unless evidence makes alternatives impossible; require ranked hypotheses and predictions |
| Solver picks Quick fix without naming tradeoff | Reject — all 3 options required for explicit tradeoff comparison |
No artifact written to .investigations/ | Reject — verbal diagnosis is not auditable |
Running /diagnose in parallel on same bug | Only one active investigation per task_id; concurrent runs create race |
Output to user
After Stage 4 completes, summarize in ≤ 5 lines:
/diagnose BUG-417 complete.
Root cause: Unbounded .map+await in OrderService.calculateTotal() exhausts pg pool.
Selected: Strategic (batch via IN-clause, ~40 LOC, Medium risk).
Assigned: @backend-developer; acceptance = load test with 50 items passes.
Artifacts: .investigations/BUG-417/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
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.

