Skip to content
Back to skills

Diagnose

ASecurity

Evidence-first debugging; one change at a time, then a regression test. Use when a bug, error, regression, failing test, or outage is reported; not for features.

  • 16 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 6, 2026
ai-agentsgobashtestingdebuggingapiperformance

Works with

  • api

Security analysis

A100/100

Scanned December 6, 2026

npx -y skills add Alexander-Tyagunov/magician --skill diagnose --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Diagnose?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Diagnose
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/alexander-tyagunov-diagnose/badge)](https://www.skillsdirectory.com/skills/alexander-tyagunov-diagnose)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: diagnose
description: Evidence-first debugging; one change at a time, then a regression test. Use when a bug, error, regression, failing test, or outage is reported; not for features.
effort: high
allowed-tools: Read, Grep, Glob, Bash(ugrep *), Bash(rg *), Bash(grep *), AskUserQuestion, Bash(kg check), Bash(kg query *), Bash(kg neighbors *), Bash(kg blast *), Bash(evidence check *), Bash(ctx recall *), Bash(ctx learn line)
argument-hint: "<bug or error description>"
---

# /diagnose — Systematic Debugging

> **Bundled command:** if `ctx` is not found, run it as `${CLAUDE_PLUGIN_ROOT}/tools/ctx`; if that is missing too, skip the recall.

> **Bundled command:** if `evidence` is not found, run it as `${CLAUDE_PLUGIN_ROOT}/tools/evidence`; if that is missing too, run the suite.

> **Bundled command:** if `kg` is not found, run it as `${CLAUDE_PLUGIN_ROOT}/tools/kg` and give subagents that full path. If that is missing too (Claude chat ships no plugin tools), skip the `kg` steps and search the code directly.

Debug systematically. No random changes in the hope something helps.

Scale `/effort` to bug complexity — for deep, multi-layer root-cause hunts use `xhigh` (`max` only as an opt-in for a frontier problem; it is session-only). See [lore/models.md](../../lore/models.md).

<HARD-GATE>
Make no code change before you have evidence for the cause. A change without a known cause is the most common debugging failure.
</HARD-GATE>

## When to use

Trigger phrases: "I have a bug / it's broken / not working / crashing", an error, exception, or stack trace, a regression, a test failure, a production issue or outage when the app is deployed. Not for new features (`/spec`, `/tdd`) or performance tuning (`/perf`).

## Autonomy

Gates: the hypothesis question, only on a failed reproduction or a tie. Everything else runs without asking.

## Process

### Phase 1: Evidence
1. **Read the error and stack trace in full**, before opening any file. The trace usually names the failing `file:line` and often the fix itself. The top frame shows where it blew up; the first frame in your own code is usually the real culprit.
2. **Targeted read.** Read only the code the trace or the symptom names. With a knowledge-graph index, `kg query "<symptom/error/symbol>"` jumps to the relevant `file:line`, and `kg neighbors` / `kg blast` show what interacts with it. Read those ranges, not whole files. Before stating a hypothesis, run `ctx recall "<symptom or component>"`: a pitfall page is evidence to test, not a conclusion.
3. **Reproduce.** Run the failing case and capture the exact output. Pin down the steps or inputs that trigger it every time: a bug you cannot reproduce on demand is not understood yet.
   - In a **multi-component system** (CI → build → sign, api → service → db), log what enters and exits each component boundary and run the reproduction **once** to locate where the flow breaks. Fix where it breaks, not the first place you suspect.
   - For an intermittent or async bug, run the reproduction in the background with the Bash tool and read its output when it exits, so the failing event (a 5xx, a crash, a log line) is captured.
   - For an unfamiliar error, library or framework behavior, use `/research` (context7 and web) for external evidence: known issues, version-specific bugs, correct API usage.

### Phase 2: Hypothesis
4. **State the hypothesis with its evidence** in one or two sentences: "I believe X fails because Y. Evidence: `file:line`, the reproduction output." Say what would refute it. Then go on to Phase 3 without waiting.
5. **Ask only in two cases.** Each is one `AskUserQuestion` call whose text cites what you found.
   - **The reproduction fails.** Ask for what only the user has: the exact steps, the input, the environment or the log. Offer the two or three most likely conditions you found as options.
   - **Two hypotheses stay tied after the evidence.** Name both with their evidence, the more likely first, and ask which matches what the user sees.

   A dispatched run does not ask: it returns `NEEDS_CONTEXT` with the question.

### Phase 3: Hypothesis testing
6. **Rank the hypotheses** by the evidence, most likely first.
7. **Test the most likely one.** Make one change and observe the result.
8. If it is refuted, revert the change, mark the hypothesis off and test the next.

### Phase 4: Fix and verify
9. **Write the regression test first** and watch it fail for the reason Phase 1 found. A test that was never seen red proves nothing ([lore/verification.md](../../lore/verification.md)). When the confirming change from step 7 is already in place, revert it for this run.
10. **Implement the fix** for the confirmed root cause. The regression test passes. Then **re-run the original failing symptom**, the exact command or steps from Phase 1, and confirm it no longer reproduces. Code changed is not the same as bug fixed.
11. **Run the full test suite**, unless `evidence check --kind tests` exits 0 for this exact code (a `/tdd` or `/check` run already covered it). No new failures.
12. **Commit only when the request asks for it**, with a message that names the root cause: `fix: <root cause>`. Otherwise leave the fix uncommitted and say so in the report. Do not ask whether to commit.

## Anti-Patterns (Never Do These)
- Making 3 changes at once to "see what helps"
- Reading the entire codebase before forming a hypothesis
- Asking the user to confirm a guess you have not checked
- Fixing the symptom without understanding the cause
- Skipping the regression test

## Obstacles

If this skill runs as a dispatched unit and hits something that blocks or degrades the work, do not wait for a human who is not there and do not silently ship a degraded result — return the Obstacles block from [lore/obstacles.md](../../lore/obstacles.md) (fields: STATUS, OBSTACLE, BLOCKER, SEVERITY, WORKAROUND, RECURRENCE, SCOPE, NEXT) to the caller alongside whatever you completed; interactively, say the same in prose.

## Completion Signal

"Root cause confirmed: <explanation>. Fix applied, regression test added, full suite <result>."

In a top-level interactive run, run `ctx learn line` last and append the line it prints, unchanged. Print nothing under a parent skill or in a dispatched or headless run.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.