diagnosing-bugs
Skill1 starsChanged 2 months agoMITView on GitHub
Diagnose a hard bug or performance regression with a loop that can go red, ranked against the repo's invariants and untested dependents. Triggers — "diagnose", "debug this", or something broken, failing, flaky or slow.
123 other projects use a version of this, 97 of them edited.
Adopted by
Most recently taken up by
- mattpocock/skillsedited, first seen Oct 8, 2026
- saintdle/agentflowtheir own version, first seen Oct 6, 2026
- rafaelob/pragmatic-agent-skillstheir own version, first seen Oct 5, 2026
- AlexisBalayre/claude-code-configedited, first seen Oct 5, 2026
- KroxiDev/engineering-skillstheir own version, first seen Oct 5, 2026
- michielvandermeer/skillsedited, first seen Oct 4, 2026
Used with
Projects with it also use writing-beats, setup-ts-deep-modules and 8 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.
RoentekSkillwriting-beats
Writing, exploit — assemble raw material into a journey of beats, grounding each term before a beat leans on it.
Also in 23 projects that use this
loulanyueSkillsetup-ts-deep-modules
Wire dependency-cruiser into a TypeScript repo so each package is a deep module — implementation hidden in subfolders, reachable only through its entry-point files. User-invoked.
Also in 16 projects that use this
AWSSkillask-matt
Ask which skill or flow fits your situation. A router over the skills in this repo.
Also in 35 projects that use this
AWSSkillwait-what
Stop. That last message did not land: re-pitch it.
Also in 51 projects that use this
RoentekSkillwriting-shape
Writing, exploit — shape raw material into an article, paragraph by paragraph.
Also in 21 projects that use this
- +3 more from aws
- +2 more from Roentek
Other versions123 projects use a version of this.
Word for word · 0
None found.
Edited · 97
- mattpocock/skills★ 335k28% same
- getsentry/sentry-react-native★ 1.8k13% same
- getsentry/sentry-dart★ 87322% same
- chrisdoc/hevy-mcp★ 49828% same
- mxyhi/ok-skills★ 49228% same
- aws/graph-explorer★ 48428% same
- bighadj22/codflow★ 33828% same
- ninehills/skills★ 28025% same
- loulanyue/skills★ 23125% same
- tt-a1i/matt-skills-with-to-goal★ 18228% same
87 more not listed
Wrote their own version · 26
- vinvcn/mattpocock-skills-zh-CN★ 4.6ksame name
- stevesolun/ctx★ 588same name
- nodetool-ai/nodetool★ 551same name
- devcxl/mattpocock-skills-zh★ 426same name
- leandrocfe/skills★ 38same name
- rafaelob/pragmatic-agent-skills★ 23same name
- aethrox/doctrine★ 18same name
- mxrsv/agents-skills★ 8same name
- dekoza/oh-my-slop★ 4same name
- icetomoyo/CodingSkills★ 4same name
16 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 repository50 other files it gives its agents.
- AGENTS.mdAGENTS.md
- core/AGENTS.mdAGENTS.md
- index/AGENTS.mdAGENTS.md
- mcp/AGENTS.mdAGENTS.md
- tools/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- analyze-specSkill
- auditSkill
- captureSkill
- catch-me-upSkill
- connect-brainSkill
- cortex-auditSkill
- cortex-briefSkill
- cortex-enrichSkill
- cortex-impactSkill
- cortex-installSkill
- cortex-nextSkill
- cortex-profileSkill
- cortex-reviewSkill
- cortex-scaffoldSkill
- cortexSkill
- cortex-skillsSkill
- cortex-viewSkill
- dailySkill
- domain-modelingSkill
- dreamSkill
- grillingSkill
- handoffSkill
- improve-codebase-architectureSkill
- install-projectSkill
- level-upSkill
- migrate-engineSkill
- onboardSkill
- optimize-contextSkill
- optimize-promptSkill
- plugin-syncSkill
- reindexSkill
- resolving-merge-conflictsSkill
- resumeSkill
- scan-projectsSkill
- setup-pluginsSkill
- shipSkill
- site-syncSkill
- skill-auditSkill
- skill-creatorSkill
- team-addSkill
- team-initSkill
- weekly-reviewSkill
- wizardSkill
- writing-for-agentsSkill
The file
We split this skill into the rules it gives an agent
10 rules. 0 are common, 10 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 115 edited versions we read keep these.
10
Distinctive
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
- Distinctive: line 23
If the redacted output is not enough to diagnose the bug, say so and ask.
- Distinctive: line 35
Read four things off that:
- Distinctive: line 43
Drift: If the code and the document describing it disagree, one of them is the bug.
- Distinctive: line 76
Treat the loop as the product.
- Distinctive: line 90
Stop and say so. List what you tried, and ask for one of: access to an environment that reproduces it, a redacted captured artifact, or …
- Distinctive: line 105
If you catch yourself reading code to build a theory before that command exists, stop.
- Distinctive: line 110
Run the loop. Watch it go red.
- Distinctive: line 137
Every probe maps to a specific prediction from Phase 3.
- Distinctive: line 139
Prefer a debugger or REPL if the environment supports it — one breakpoint beats ten logs.
- Distinctive: line 150
Write the regression test before the fix, but only where a correct seam exists — one that exercises the real bug pattern as it occurs at …
“Common” is measured: kept by at least 6 in 10 of the 115 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
/diagnosing-bugs — build the loop first
A discipline for bugs that did not fall to the first reading. Skip a phase only when you can say why.
Cortex's version differs from a generic debugging loop in one way: this repo has a map, so use it before guessing. Phase 0 exists for that. Everything after it is the upstream discipline, which is sound and has not been improved by rewording.
Redact
This skill has you show commands, outputs and captured artifacts. Redact every secret first —
write <REDACTED> in its place. Build loops against environment variables so the credential stays in
the environment rather than in what you print. Captured traces carry auth headers; quote only the
lines that carry signal.
If the redacted output is not enough to diagnose the bug, say so and ask.
Phase 0: Orient with what the repo already knows
Cheap, deterministic, and it routinely re-ranks the hypotheses before any exist. Skip it only when
the repo has no .cortex/ index.
node "${CLAUDE_PLUGIN_ROOT}/index/cortex-impact.mjs" <suspect files> # who depends on this, and what no test covers
node "${CLAUDE_PLUGIN_ROOT}/index/cortex-review.mjs" <suspect files> # which documents govern it, and which name itRead four things off that:
- The unverified list. A bug lives disproportionately in code nothing exercises. If the suspect's dependents are uncovered, that is where to look and the regression test in Phase 5 already has its home.
- The documented invariants.
AGENTS.md,CONTEXT.mdand the ADRs that govern these files often state the bug: "the raw body is required for signature verification", "this must never reach memory". A violated invariant is a hypothesis with evidence behind it. - Drift. If the code and the document describing it disagree, one of them is the bug. Do not assume it is the document.
- Depth.
index.layersplaces the file: a depth-0 foundation file failing means everything above it is suspect, and an entry-point file failing usually does not implicate the kernel.
Bring what you find into Phase 3 as ranked hypotheses. Do not let it substitute for Phase 1 — a plausible cause read off a document is still a guess until a loop goes red on it.
Phase 1: Build a feedback loop
This is the skill. Everything else is mechanical. With a tight pass/fail signal — one that goes red on this bug — you will find the cause; bisection, hypothesis-testing and instrumentation all just consume it. Without one, no amount of staring at code will save you.
Spend disproportionate effort here. Be aggressive, be creative, refuse to give up.
Ways to construct one, roughly in order of preference:
- A failing test at whatever seam reaches the bug — unit, integration, e2e.
- A curl or HTTP script against a running dev server.
- A CLI invocation with a fixture input, diffing stdout against a known-good snapshot.
- A headless browser script driving the UI and asserting on DOM, console or network.
- Replay a captured trace — save a real request, payload or event log and replay it in isolation.
- A throwaway harness — the smallest subset of the system that reaches the code path.
- A property or fuzz loop, when the symptom is "sometimes wrong output".
- A bisection harness, when the bug appeared between two known states, so
git bisect runcan consume it. - A differential loop — the same input through two versions or configs, diffed.
- A human-in-the-loop script, last resort. If a person must click, drive them from a script so the loop still has structure and its output still feeds back to you.
Tighten it
Treat the loop as the product. Once you have a loop: make it faster (cache setup, narrow scope), make the signal sharper (assert the exact symptom, not "did not crash"), make it deterministic (pin the clock, seed the RNG, isolate the filesystem, freeze the network).
A 30-second flaky loop is barely better than none. A 2-second deterministic one is a superpower.
Non-deterministic bugs
The goal is not a clean repro but a higher reproduction rate. Loop the trigger 100×, parallelise, add stress, narrow timing windows, inject sleeps. A 50% flake is debuggable; 1% is not. Keep raising the rate until it is.
When you genuinely cannot build one
Stop and say so. List what you tried, and ask for one of: access to an environment that reproduces it, a redacted captured artifact, or permission to add temporary instrumentation. Do not hypothesise without a loop.
Done when
You can name one command you have already run at least once — show the invocation and its output, redacted — that is:
- Red-capable. It drives the actual bug path and asserts the user's exact symptom, so it goes red now and green once fixed. Not "runs without erroring".
- Deterministic. Same verdict every run, or a pinned high reproduction rate.
- Fast. Seconds, not minutes.
- Agent-runnable. You can run it unattended.
If you catch yourself reading code to build a theory before that command exists, stop. Jumping to a hypothesis is the exact failure this skill prevents. No red-capable command, no Phase 2.
Phase 2: Reproduce and minimise
Run the loop. Watch it go red. Confirm it produces the failure the user described rather than a different one nearby — wrong bug, wrong fix — and that it reproduces across runs. Capture the exact symptom so later phases can prove the fix addressed it.
Then shrink to the smallest scenario that still goes red. Cut inputs, callers, config, data and steps one at a time, re-running after each cut. Done when every remaining element is load-bearing: removing any one turns it green.
A minimal repro shrinks the hypothesis space in Phase 3 and becomes the regression test in Phase 5.
Phase 3: Hypothesise
Generate 3–5 ranked hypotheses before testing any of them. Single-hypothesis generation anchors on the first plausible idea.
Each must be falsifiable — state the prediction: "If X is the cause, then changing Y makes the bug disappear." If you cannot state the prediction, it is a vibe: sharpen it or discard it.
Rank anything Phase 0 turned up as a violated invariant near the top. It is the only class of hypothesis that arrives with written evidence.
Show the ranked list to the user before testing. They re-rank it instantly ("we deployed a change to #3 yesterday") or know what is already ruled out. Cheap checkpoint, big saving. Do not block on it — proceed with your ranking if they are away.
Phase 4: Instrument
Every probe maps to a specific prediction from Phase 3. Change one variable at a time.
Prefer a debugger or REPL if the environment supports it — one breakpoint beats ten logs. Otherwise targeted logs at the boundaries that distinguish hypotheses. Never "log everything and grep".
Tag every debug log with a unique prefix like [DEBUG-a4f2], so cleanup is one grep. Untagged
logs survive; tagged ones die.
For performance regressions, logs are usually the wrong tool: establish a baseline measurement, then bisect. Measure first, fix second.
Phase 5: Fix, and prove the test would have caught it
Write the regression test before the fix, but only where a correct seam exists — one that exercises the real bug pattern as it occurs at the call site. A unit test that cannot replicate the chain which triggered the bug gives false confidence.
If no correct seam exists, that is itself the finding. Say so. The architecture is preventing the bug from being locked down, and that outlives this bug.
Where a seam exists:
- Turn the minimised repro into a failing test there.
- Watch it fail, and check it fails for the right reason. A test that passes before the fix is not a regression test, and one that fails for an unrelated reason is worse — it will go green on the fix and prove nothing. This repo has shipped four assertions that passed for the wrong reason; they are only ever found by making the code wrong on purpose and watching.
- Apply the fix.
- Watch it pass.
- Re-run the Phase 1 loop against the original, un-minimised scenario.
Phase 6: Cleanup
Before declaring done:
- The original repro no longer reproduces — re-run the Phase 1 loop, do not reason about it.
- The regression test passes, and failed before the fix for the right reason.
- All
[DEBUG-...]instrumentation is gone. Grep the prefix. - Throwaway harnesses are deleted or clearly marked.
- The hypothesis that turned out correct is written in the commit or PR message, so the next
person to touch this learns what you learned. If it contradicts something in
AGENTS.md,CONTEXT.mdor an ADR, fix that sentence too — a bug caused by a stale document recurs.
Adapted from mattpocock/skills (MIT). Phases 1–6 are upstream, lightly reworded. Phase 0, the invariant-ranking note in Phase 3, and the fails-for-the-right-reason step in Phase 5 are Cortex additions — they are what the index and the context layer make possible.
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.

