Diagnosing Bugs skill
A six-phase debugging loop: build a test that fails on the bug, shrink it, rank hypotheses, probe one at a time, then fix and lock it with a test.
Community · Matt Pocock| Author | Matt Pocock |
|---|---|
| Licence | MIT |
| Source | mattpocock/skills · SKILL.md on GitHub |
| Project website | www.aihero.dev/skills-diagnosing-bugs |
| Works in | Claude Code · Codex, Gemini CLI, Cursor, Copilot |
| Read from the source on |
The diagnosing-bugs skill gives a coding agent a strict order for hard bugs and performance regressions: first a command that goes red on this exact bug, then a theory, never the other way round.
It walks six gated phases, from the feedback loop to cleanup, and says to stop and ask when no loop can be built. It is part of Matt Pocock's engineering skills and works on any codebase the agent can run.
From the skill's SKILL.md: Build the right feedback loop, and the bug is 90% fixed.
What it does
- Build a fast, repeatable command that fails on the reported symptom, choosing from ten kinds of loop such as a failing test, a curl script or a bisection harness.
- Reproduce the failure and cut the scenario down until every remaining part is needed.
- Write three to five ranked hypotheses, each with a prediction that could prove it wrong, and show them to you.
- Probe one variable at a time with a debugger or tagged logs, or measure first for performance bugs.
- Fix the bug with a regression test at a seam that really exercises it, then remove every debug log and prototype.
What you get
- A named command that reproduces the bug, with its output shown and secrets redacted.
- A ranked list of falsifiable hypotheses.
- The fix, a regression test (or a note that no correct seam exists) and the confirmed cause for the commit or PR message.
When to use it
- A bug is intermittent, slow or keeps coming back after quick fixes.
- You want the agent to prove the cause before it edits code.
When not to use it
- Typos and other obvious one-line fixes, where six phases cost more than they save.
What it needs
- A coding agent that can run commands in your project (tests, scripts, a dev server).
- Whatever the loop needs to reproduce the bug: a test runner, a local server or a captured log. No account or API key.
Files in the skill
| File or folder | What it is for |
|---|---|
SKILL.md | The six phases, completion checklists and the redaction rule. |
scripts/hitl-loop.template.sh | Template for a loop in which a person clicks through steps and answers prompts, when nothing else can drive the bug. |
Licence as found in the repository on 2026-11-22: MIT.
Example prompts
Type one of these after installing; naming the skill makes sure it is used.
- Diagnose why the checkout total is sometimes off by one cent.
- The search page got slow after last week's release. Debug this and find the commit that caused it.
- This test fails about one run in twenty. Raise the failure rate until you can debug it.
How to install diagnosing-bugs
Plugin or single folder
The Claude Code plugin installs all 27 of the author's skills together. To get only this one, copy its folder instead. The author says to pick one route per agent: installing both gives every skill twice.
The skill itself needs no setup step. Some of the author's other skills, such as code-review, expect setup-matt-pocock-skills to run first.
A skill is a folder with a SKILL.md file. You install it once; the agent reads its short description at the start of each session and loads the full instructions only when a request matches. Pick the place you use:
Claude Code: from the plugin marketplace
- Start Claude Code in a terminal with
claude. - This plugin is in Anthropic's official marketplace, which Claude Code adds for you the first time you start it.
- Install the plugin. Claude Code opens its details first: check what it will add (skills, hooks, MCP servers), then choose whether it is for you, for everyone on this repository, or for you in this repository only.
/plugin install mattpocock-skills@claude-plugins-official - Type / and look for
/mattpocock-skills:diagnosing-bugs, or simply ask for the task.
From your shell instead of a session:
claude plugin install mattpocock-skills@claude-plugins-officialThe plugin installs as a whole, so other skills come with it, including ask-matt, grill-with-docs, triage, improve-codebase-architecture, setup-matt-pocock-skills, tdd, to-spec, to-tickets, wayfinder, implement, implement-spec, prototype, research, domain-modeling, codebase-design, code-review, pr, retro, wizard, grill-me, grilling, handoff, teach, to-questionnaire, wait-what, writing-for-agents.
Claude Code: copy the folder into your skills folder
Put the skill's folder in ~/.claude/skills/ to use it in every project on this computer, or in .claude/skills/ inside a repository to share it with everyone who works there (commit it).
git clone --depth 1 https://github.com/mattpocock/skills.git
mkdir -p ~/.claude/skills
cp -R skills/skills/engineering/diagnosing-bugs ~/.claude/skills/Claude Code notices new or changed skills in these folders during the session. If the skills folder did not exist when the session started, run /reload-skills once. Then type /diagnosing-bugs or just describe the task.
On Windows, run the commands in Git Bash or WSL, or copy the folder into the same place with File Explorer.
Codex, Gemini CLI, Cursor and GitHub Copilot
These agents read the same SKILL.md folders. The one folder all four accept inside a project is .agents/skills/, so this copies the skill there:
git clone --depth 1 https://github.com/mattpocock/skills.git
mkdir -p .agents/skills
cp -R skills/skills/engineering/diagnosing-bugs .agents/skills/| Agent | Project folder | Your user folder | Notes |
|---|---|---|---|
| OpenAI Codex | .agents/skills/ | ~/.agents/skills/ | Type $ or run /skills to pick a skill; Codex also chooses one when your task matches. |
| Gemini CLI | .agents/skills/.gemini/skills/ | ~/.agents/skills/~/.gemini/skills/ | Or install from Git with gemini skills install <git URL> --path <folder> --consent. Google replaced Gemini CLI with Antigravity CLI for free-tier and Google One users on 18 June 2026; Antigravity uses .agents/skills/ in a project and ~/.gemini/config/skills/ for you. |
| Cursor | .agents/skills/.cursor/skills/ | ~/.agents/skills/~/.cursor/skills/ | Type / in Agent chat to pick a skill. Cursor also reads Claude Code's .claude/skills/ folders. |
| GitHub Copilot | .github/skills/.agents/skills/.claude/skills/ | ~/.copilot/skills/~/.agents/skills/ | Works in Copilot CLI, the cloud agent, and agent mode in VS Code, Visual Studio and JetBrains (IDE support depends on the version). Or run gh skill install OWNER/REPOSITORY SKILL (public preview, GitHub CLI 2.90.0 or later). |
Sources for these steps
Checked against each vendor's documentation on 2026-11-14:
Why the loop comes first
The skill treats the feedback loop as the real work: with a fast pass-or-fail signal for this bug, bisection, hypotheses and logging all have something to check against. Phase 1 is done only when one command has been run, catches the user's exact symptom, gives the same answer every run and takes seconds.
If the agent starts reading code to build a theory before that command exists, the skill tells it to stop. That is the failure the skill is written to prevent.
Hypotheses, probes and cleanup
Hypotheses are written in the form "if X is the cause, changing Y makes the bug disappear", ranked, and shown to you before testing, because you may already know one is ruled out. The agent does not wait if you are away.
Every debug log carries a unique tag, so one search removes them all at the end. The cleanup checklist also asks for the original scenario to be re-run and the confirmed cause to be written into the commit or PR.
Questions about diagnosing-bugs
What if the agent cannot reproduce the bug?
The skill tells it to stop, list what it tried and ask you for access to an environment that reproduces it, a redacted log or recording, or permission to add temporary instrumentation. It must not move on to guessing without a loop.
Does it handle flaky bugs?
Yes. For non-deterministic bugs the goal is a higher reproduction rate: run the trigger many times, add stress or narrow the timing until the failure shows up often enough to debug.
Will it print my API keys or tokens?
It is told to replace every secret with <REDACTED> before showing commands, output or captured requests, and to keep credentials in environment variables. Still review what it shows before sharing it.
Does it always add a regression test?
Only at a seam that exercises the real bug pattern. If no such seam exists, the skill reports that as a finding about the code's structure instead of writing a test that would give false confidence.
More AI skills
Related skills
Code Review skill (Matt Pocock)
Community · Matt PocockReview a branch on two separate axes, your repo's coding standards and the original spec, with one sub-agent each, reported side by side.To-Spec skill
Community · Matt PocockRecord agreed decisions as a project specification and publish it to the configured tracker.Subagent-Driven Development skill
Community · Jesse Vincent / Prime RadiantExecute an approved plan with fresh implementers, scoped reviews and a recorded task ledger.Antfu skill
Community · Anthony FuApply Anthony Fu's JavaScript and TypeScript tooling preferences to a compatible project.Antfu Create PR skill
Community · Anthony FuPrepare an evidence-backed GitHub pull request with the correct diff range and review context.Daymade Skill Creator
Community · daymadeCreate and improve skills while preserving source ownership, capabilities and evidence boundaries.