Use when debugging a defect, unexpected behaviour, failing test, or performance regression. Runs a disciplined 6-phase loop — build a feedback loop, reproduce, hypothesise, instrument, fix with regression test, cleanup + post-mortem. Do not use for architectural analysis or planning — use /orchestrator mvp instead.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Diagnose?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/aldianriski-diagnose)
---
name: diagnose
description: Use when debugging a defect, unexpected behaviour, failing test, or performance regression. Runs a disciplined 6-phase loop — build a feedback loop, reproduce, hypothesise, instrument, fix with regression test, cleanup + post-mortem. Do not use for architectural analysis or planning — use /orchestrator mvp instead.
argument-hint: "[bug description | failing test | performance regression]"
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
user-invocable: true
version: "0.2.0"
---
# Diagnose
A discipline for hard bugs. The rate of feedback is your speed limit — build the loop first. Skip a
phase only when you can explicitly justify it.
## Redact before you show
Every phase below **produces an artifact and then shows it** — loop output, a captured trace, a log
dump, a replayed payload, a HITL transcript. Those carry auth headers, tokens, connection strings and
PII *by default*, and a debugging session is exactly where they get pasted into a chat, an issue, or a
commit message. Redact first, and prefer the mechanism over the reminder:
- **Build the loop against environment variables** so the credential stays in the environment rather
than in the command you show. That removes the whole class; redacting afterwards removes instances.
- **Quote only the signal-carrying lines** of a captured artifact — never a whole HAR file or log dump.
- Whatever must still be shown gets `<REDACTED>` in place of the secret, *before* it is shown.
- If the redacted output is no longer enough to diagnose the bug, **say so and ask** — never widen what
you paste to compensate.
## Phase 1 — Build a feedback loop
**This is the skill** — everything else just consumes the signal. Get a fast, deterministic,
agent-runnable pass/fail signal for the bug and you will find the cause. Spend disproportionate
effort here; be aggressive, refuse to give up.
- **A bug item exists?** (`type: bug`, ADR-056) Read its symptom, repro and evidence first; the loop must reproduce *its* repro.
- Prefer an **automated test** at the seam that reaches the bug; then curl/HTTP, CLI snapshot-diff, headless browser, replay a captured trace, a throwaway harness, fuzz, `git bisect run`, or a differential loop. Full menu → `${CLAUDE_SKILL_DIR}/references/feedback-loops.md`.
- **Iterate on the loop** — faster, sharper signal, more deterministic. A 2-second deterministic loop beats a 30-second flaky one.
- **Non-deterministic bug?** Raise the reproduction *rate* (loop 100×, parallelise, stress), don't chase a clean one-shot repro.
- **Genuinely can't build one?** Stop, list what you tried, ask for env access / a captured artifact / instrumentation permission. **Do not hypothesise without a loop.**
## Phase 2 — Reproduce
Run the loop; watch the bug appear. Confirm:
- [ ] It produces the failure mode the **user** described — not a different nearby one (wrong bug = wrong fix).
- [ ] Reproducible across runs (or at a high enough rate to debug against).
- [ ] You've captured the exact symptom (error / wrong output / timing) so later phases can verify the fix.
## Phase 3 — Hypothesise
Generate **3–5 ranked, falsifiable** hypotheses *before* testing any — single-hypothesis generation
anchors on the first plausible idea. Each must state a **prediction**:
```
H1: [cause] — If this is it, then [changing Y] makes the bug disappear / [Z] makes it worse.
H2: …
```
If you can't state the prediction, it's a vibe — sharpen or discard it. **Show the ranked list to the
user before testing** (they re-rank instantly: "we just deployed #3"). Don't block if they're AFK.
## Phase 4 — Instrument
- Each probe maps to a specific Phase-3 prediction. **Change one variable at a time.**
- **Debugger / REPL > targeted logs at the distinguishing boundary > never "log everything and grep".**
- **Tag every debug log** with a unique prefix (`[DEBUG-a4f2]`) so cleanup is a single grep.
- **Perf regression?** Logs are usually wrong — establish a baseline measurement, then bisect. Measure first.
## Phase 5 — Fix + regression test
Write the regression test **before** the fix — but only if a **correct seam** exists (one that
exercises the real bug pattern at the call site). A too-shallow seam gives false confidence.
**If no correct seam exists, that itself is the finding** — the architecture is preventing lockdown;
flag it for Phase 6. When a seam exists: failing test (RED) → minimal fix (GREEN) → re-run the Phase 1
loop against the original, un-minimised scenario → full suite still passes.
A red you **force** — a mutation, a fixture edit, or the fix reverted to watch the test fail — counts
only once a `diff`/`cmp` against a pristine copy shows the change landed; a landed change that
reddens nothing has tested nothing. Prove the restore the same way.
## Phase 6 — Cleanup + post-mortem
- [ ] Original repro no longer reproduces (re-run the Phase 1 loop)
- [ ] Regression test passes (or the absence of a seam is documented)
- [ ] All `[DEBUG-…]` instrumentation removed (grep the prefix); throwaway harnesses deleted
- [ ] The bug item, when one exists, carries `## Root cause` · `## Fix` · `## Regression test` · `## Prevention`, and a `Negative:` box in `## Done when` naming what the regression test pins if it has none; new evidence goes redacted into `docs/work/evidence/TASK-NNN/`
- [ ] The winning hypothesis is stated in the commit / PR message (passed through `/humanizer` embedded mode: commit `plain`, PR body `markdown` → the humanizer skill's `references/embedded.md` § Commit messages and PR bodies) — so the next debugger learns
**Then ask: what would have prevented this?** If the answer is architectural (no good seam, tangled
callers, hidden coupling), file it as a `TD-NNN` tech-debt entry (groomed by `/triage`, aged at
promote) and hand the specifics to `/refactor-advisor` to design the deepening — make the call
*after* the fix lands, when you know the most.
## Red flags
❌ **Showing a captured artifact unredacted** — traces, HAR files, log dumps and replayed payloads carry auth headers by default, and this skill's whole method is to capture then show. Build the loop against env vars, quote only the signal-carrying lines, `<REDACTED>` whatever remains. `/handoff` already carries this rule; the two must not disagree about a safety default.
❌ **Hypothesising without a feedback loop** — guessing compounds bugs; Phase 1 is non-negotiable.
❌ **Fixing the wrong bug** — the loop must reproduce the *user's* symptom, not a nearby one.
❌ **Multiple simultaneous changes** — violates one-variable-per-test; invalidates the diagnosis.
❌ **Untagged debug logs** — they survive cleanup; tag with `[DEBUG-…]` and grep them out.
❌ **Regression test at a false seam** — a shallow test that can't replicate the bug gives false confidence; no seam is a finding, not a skip.
❌ **Believing the mechanism a report arrives with** — a symptom is *observed*, the explanation welded to it is *inferred*, and they look equally factual on the page. Wrong three times running here (TD-024 blamed `git -C` on MSYS paths, then transient worktree state, before an inherited `MSYS_NO_PATHCONV`; TD-027 claimed a degrading permission surface, falsified by a 26-turn probe). Treat the symptom as data and the mechanism as the **first thing to test**, and prefer a recorded "not established" over a plausible story — a plausible story ends inquiry, an honest gap invites it (L-087).