name: bugfix description: | Structured bug fix with root cause investigation. For bugs where the cause isn't immediately obvious, spans multiple files, or requires careful analysis before fixing. Includes hypothesis-driven investigation and a fix plan. Trigger: "bugfix", "debug this", "fix this bug", "pourquoi ca marche pas", "investigate and fix", "find and fix", "root cause + fix". For obvious 1-2 file fixes → use /hotfix instead. For bugs that need investigation only (no fix) → use /analyze. argument-hint: disable-model-invocation: false allowed-tools:
Investigate, understand, plan, fix. No guessing. The iron law: understand the root cause before writing a single fix.
$ARGUMENTS
Understand the current state:
git status
git log --oneline -5
Read the error message, stack trace, or bug description. Identify:
When it started (recent commit? always? after a deploy?)
# If the user mentions "it was working before":
git log --oneline -20 --all -- <suspected files>
Trace the bug from symptom to root cause:
Check recent changes to the affected files:
git log --oneline -10 -- <file>
git diff HEAD~5 -- <file> # if recent regression suspected
Look for related tests — do they pass? Do they cover the broken case?
Search for similar patterns elsewhere that might have the same bug:
# grep for the same pattern to assess blast radius
Present findings before fixing:
BUGFIX — DIAGNOSIS
BUG : <one-line symptom>
ROOT CAUSE: <what is actually wrong and why>
EVIDENCE: <what confirmed it — test, trace, diff>
BLAST RADIUS: <other places affected, or "isolated">
FIX PLAN:
1. <file:line> — <what to change>
2. <file:line> — <what to change>
[3. <test file> — add/update test for this case]
RISK: <low/medium — what could go wrong>
Apply the fix following the plan:
Run the full relevant test suite:
# detect and run tests
If a build step exists, verify it passes.
Check for regressions in related functionality.
Commit using conventional format:
fix(<scope>): <root cause description>
<what was wrong and why>
<what the fix does>
Co-Authored-By: Claude <noreply@anthropic.com>
Print summary:
BUGFIX COMPLETE
BUG : <symptom>
ROOT CAUSE : <one-line>
FILE(S) : <changed files>
TEST(S) : <added/updated tests, or "none — verified manually">
REGRESSION : <checked areas>
/ship-feature for the
proper fix./ship-feature
is more appropriate.