Debug systematically: reproduce the bug, rank hypotheses by evidence, test them with logging, a debugger or git bisect, then fix the root cause with a regression test.
--- name: debug-helper description: Works through a bug systematically — reproduce it, gather the error, stack trace and logs, rank hypotheses with the evidence for each, test them with targeted logging, a debugger or git bisect, then fix the root cause and add a regression test. Use when something crashes, throws, returns the wrong result, fails only in CI or production, or a test started failing. metadata: version: "1.5.0" --- # Debug Helper Every conclusion must point at evidence the user can see: an error line, a log entry, a variable value, a failing test or a bisect result. Rank hypotheses by evidence, not by invented percentages. ## Inputs to collect - Expected vs actual behaviour, in one sentence each. - Exact steps or command to reproduce; how often it happens. - Full error message and stack trace (not a paraphrase), relevant logs, and the environment (runtime/OS/dependency versions, config, data). - What changed recently (deploy, dependency bump, config, data) and the last known good version. ## Workflow 1. **Reproduce.** Turn the report into the smallest command or failing test that shows the bug. If you cannot reproduce it, say so and list the extra information needed instead of guessing a fix. 2. **Locate.** Read the stack trace from the first frame in the project's own code. Open that code and the inputs reaching it. 3. **Hypothesise.** List 2–4 candidate causes. For each, give the supporting evidence, what would rule it out, and the cheapest test. 4. **Test, one hypothesis at a time.** - Add temporary logging of the exact values at the suspect line, or set a breakpoint (`python -m pdb`, `breakpoint()`, `node --inspect-brk`, browser DevTools). - Regression with a known good version: `git bisect start <bad> <good>` then `git bisect run <test-command>`; finish with `git bisect reset`. - Environment-only failures: compare versions, env vars and config between the working and failing environment. 5. **Fix the root cause**, not the symptom (no blanket try/except or retries that hide the error). Keep the diff minimal. 6. **Verify.** The reproduction now passes; add it as a regression test; run the surrounding test suite. Remove temporary logging. 7. **Explain** cause, fix and how to prevent recurrence (a test, a type, a validation, a lint rule). ## Output format ``` BUG: <expected> vs <actual> Reproduction: <command/test> — reproduced: yes/no Evidence: <trace/log/value lines> Hypotheses: 1. <cause> — supports: … — ruled out by: … — test: … — result: confirmed/rejected Root cause: <one sentence with file:line> Fix: <diff> Regression test: <name> Suite: <pass/fail> Prevention: … ``` ## Limitations and safety - Do not attach debuggers to, or add logging in, production systems without the owner's approval; never log secrets or personal data. - Heisenbugs (timing, concurrency) may disappear under a debugger; prefer logging with timestamps and thread/request IDs. - If the evidence does not single out a cause, say which hypotheses remain open. ## Example Report: "`total([1, 2, 3])` returns 5 since last week; it used to return 6." Good result: reproduction `python -c "from calc import total; assert total([1,2,3]) == 6"` fails; `git bisect run` names the first bad commit, which changed `sum(xs)` to `sum(xs[1:])`; the fix restores the full slice, a regression test is added, and the suite passes.
Review a git diff, commit or snippet for bugs, security, performance and maintainability, with file:line evidence and a concrete fix per finding.
Refactor code in small, test-protected steps: pin current behavior first, change one thing at a time, and rerun tests after every step.
Set up transactional email
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
A utility function started returning wrong totals sometime in the last few commits, and nobody knows which change caused it.
total([1, 2, 3]) returns 5 now; it returned 6 last week. calc.py has had several commits since. Find the cause and fix it.
Reproduction: `python -c "from calc import total; assert total([1,2,3]) == 6"` fails. Hypotheses are listed with how to test each. `git bisect start HEAD <last-good>` + `git bisect run ./check.sh` identifies the first bad commit, whose diff changed `sum(xs)` to `sum(xs[1:])`. The root cause is given with file:line, the fix restores `sum(xs)`, a regression test asserting total([1,2,3]) == 6 is added, the suite passes, and `git bisect reset` restores the checkout. No confidence percentages are invented.
AI Agent Skills are reusable workflow packages that extend your AI coding assistant with multi-step capabilities. Install debug-helper by following these steps.
SKILL.md inside, in the location documented by your client. Do not assume every AI application reads the same directory.Requires an Agent Skills-compatible client; supported locations and activation vary by version. Read the SKILL.md setup guide. MCP connects tools and data and does not, by itself, install a skill.
Review a git diff, commit or snippet for bugs, security, performance and maintainability, with file:line evidence and a concrete fix per finding.
Refactor code in small, test-protected steps: pin current behavior first, change one thing at a time, and rerun tests after every step.
Set up transactional email