/mithunyc-skills:diagnosing-bugsfrom mithunyc-skills
Investigate hard-to-reproduce bugs, intermittent failures, unclear root causes, and specific performance regressions using a causal feedback loop. Reproduce → minimise → hypothesise → instrument → fix → regression-test. Use when the user says "diagnose this" or "debug this", reports a bug, says something is broken/throwing/failing/flaky, or describes a performance regression. Not for simple error explanations or broad performance audits.
Ships in mithunyc-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
A discipline for hard bugs. Skip phases only when explicitly justified.
Diagnose/explain requests authorize investigation, not implementation. Prefer existing tests and read-only observations; create repro files, instrumentation, or fixes only within the user's authorized scope. Phases 5-6 apply to a requested fix; for diagnosis-only work, report the supported cause, evidence, uncertainty, and proposed next step. Do not widen access, stress production, switch a dirty checkout, or delete artifacts to force progress. Skill invocation does not grant commit, push, deployment, or production-instrumentation permission.
When exploring the codebase, build a clear mental model of the relevant modules first: read the project's domain glossary or CONTEXT.md if either exists, and check any ADRs covering the area you're touching. A bug that looks impossible is often a term you're reading wrong.
This skill has you show commands, outputs and captured artifacts. Redact every secret first: write <REDACTED> in its place. Build loops against env vars, so the credential stays in the environment rather than in what you show. Captured artifacts carry auth headers: quote only the lines that carry the signal.
If the redacted output is not enough to diagnose the bug, say so and ask the user.
Build a tight pass/fail signal for the bug, one that goes red on the user's exact symptom. Bisection, hypothesis testing, and instrumentation all consume this signal, and are far weaker without it. It improves causal evidence; it does not by itself guarantee a diagnosis. Read code as needed to construct the loop, and label untested explanations as hypotheses.
This phase is the skill. Most of what follows is mechanical once the loop exists, and no amount of staring at code substitutes for one. Spend disproportionate effort here — be aggressive and creative before concluding it can't be done.
Two limits on that persistence: keep effort proportionate to the bug and to the authorized environment, and stop or ask when further attempts would require new authority or yield no new evidence. Refusing to give up is a stance about creativity, not a licence to widen access.
git bisect run it.scripts/hitl-loop.template.sh when Bash and an interactive user terminal are available; otherwise provide short numbered actions and a structured observation request. Never pretend to observe the user's actions. Capture only sanitized observations, not credentials or raw private logs.The loop is a verification instrument, not proof that the bug is fixed.
Treat the loop as a product. Once you have a loop, tighten it:
A 30-second flaky loop is barely better than no loop; a 2-second deterministic one is tight, a debugging superpower.
Seek a measurable reproduction rate. In an isolated authorized environment, vary stress or timing deliberately; record seed, trial count, failure count, and workload. Preserve a realistic trigger and do not treat zero failures in a few trials as proof of absence. Bound resource use; a rare failure can still supply valuable evidence.
Say so explicitly and list what you tried. Continue safe static analysis or available read-only evidence if useful, with hypotheses clearly labeled unverified. Ask for the smallest missing input, such as a sanitized artifact or a user-run observation. Do not claim a verified cause or fix without adequate evidence, and do not require production access when a safer alternative exists.
Phase 1 is done when the loop is tight and red-capable: you can name one command (a script path, a test invocation, a curl) that you have already run at least once (show the invocation and its output, redacted), and that is:
If no red-capable command is possible within scope, disclose the evidence gap. Reading code may guide investigation, but does not replace reproducing the symptom for a verified regression fix.
Run the loop. Watch it go red as the bug appears.
Confirm:
Once it's red, shrink the repro to the smallest scenario that still goes red. Cut inputs, callers, config, data, and steps one at a time, re-running the loop after each cut, and keep only what's load-bearing for the failure.
Why bother: a minimal repro shrinks the hypothesis space in Phase 3 (fewer moving parts left to suspect) and becomes the clean regression test in Phase 5.
Minimize enough to distinguish causes without losing the relevant integration, timing, or concurrency behavior.
Record whether reproduction and minimization actually succeeded before moving on.
Rank plausible competing hypotheses when the cause is unclear (often 3–5). Do not invent alternatives when direct evidence already distinguishes the cause; record what would falsify the leading explanation.
Each hypothesis must be falsifiable: state the prediction it makes.
Format: "If is the cause, then will make the bug disappear / will make it worse."
If you cannot state the prediction, the hypothesis is a vibe: discard or sharpen it.
Show the ranked list to the user before testing. They often have domain knowledge that re-ranks instantly ("we just deployed a change to #3"), or know hypotheses they've already ruled out. Cheap checkpoint, big time saver. Don't block on it; proceed with your ranking if the user is AFK.
Each probe must map to a specific prediction from Phase 3. Change one variable at a time.
Tool preference:
Tag every debug log with a unique prefix, e.g. [DEBUG-a4f2]. Cleanup at the end becomes a single grep. Untagged logs survive; tagged logs die.
Perf branch. For performance regressions, logs are usually wrong. Instead: establish a baseline measurement (timing harness, performance.now(), profiler, query plan), then bisect. Measure first, fix second.
Write the regression test before the fix, but only if there is a correct seam for it.
A correct seam is one where the test exercises the real bug pattern as it occurs at the call site. If the only available seam is too shallow (single-caller test when the bug needs multiple callers, unit test that can't replicate the chain that triggered the bug), a regression test there gives false confidence.
If no correct seam exists, that itself is the finding. Note it. The codebase architecture is preventing the bug from being locked down. Flag this for the next phase.
If a correct seam exists:
Required before declaring done:
[DEBUG-...] instrumentation removed (grep the prefix)Answer it after the fix is in, never before — you know far more now than when you started.
If the answer is architectural — there was no correct test seam, callers are tangled, coupling was hidden — that is a finding worth handing off rather than fixing inline:
codebase-design for the vocabulary to describe the problem precisely (seam, depth, interface) and to shape a specific module.improve-codebase-architecture to sweep for the same pattern elsewhere and write it up.Recommend; do not start a refactor on the strength of a bug fix unless the user asks.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub mithunyc/skills --plugin mithunyc-skills30 skills in this plugin
/api-designerDesign or review API contracts, schemas, errors, pagination, idempotency, and compatibility. Use for API specification work rather than general server implementation./asd-ste100Write or clarify English technical instructions, tool descriptions, error messages, prompts, agent handoffs, and explanations with ASD-STE100-inspired rules. Use for disambiguate, STE100, Simplified Technical English, controlled-language rewrite, or dense technical text whose misreading has a cost. Preserve meaning and authority. Do not apply automatically to creative writing, marketing, verbatim quotations, or executable code./auth-integration-engineerDesign, implement, or diagnose authentication, identity-provider integration, sessions, tenant authorization, SSO, MFA, and account recovery.Other plugins' skills for the same job