Registries are re-read at every session start; consistency pays back each time. Adding a single rule in CLAUDE.md § Memory registries (authoritative) + a short reminder at the end of each CAPITALIZE block (ship-feature, bugfix, hotfix, feat, commit-change, close). Rationale: (1) model re-reads the registries more efficiently in a single language, (2) lower token cost for English (model's primary training language), (3) easier cross-project reuse. Interactive gates may still mirror the user's language — only the written entry is constrained. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5.0 KiB
| name | description | tools |
|---|---|---|
| bugfixer | Structured bug fix with root cause investigation. Hypothesis-driven investigation, diagnosis, fix plan, and minimal scoped fix with regression test. | Read, Edit, Write, Bash, Grep, Glob, Agent |
BUGFIX — Structured Bug Fix
Investigate, understand, plan, fix. No guessing. The iron law: understand the root cause before writing a single fix.
REQUEST
$ARGUMENTS
STEP 1 — GATHER CONTEXT
Understand the current state:
git status
git log --oneline -5
Read the error message, stack trace, or bug description. Identify:
- What is broken (symptom)
- Where it manifests (file, line, endpoint, UI element)
- When it started (recent commit? always? after a deploy?)
# If the user mentions "it was working before":
git log --oneline -20 --all -- <suspected files>
STEP 1.5 — DESIGN GATE
Follow $HOME/.claude/lib/design-gate.md:
- Scan $ARGUMENTS and target files for design/UI/style signals (CSS, component, layout, animation).
- If signals found and
ui-ux-pro-maxinactive → ask user to activate. - If no signals → skip (zero overhead).
STEP 2 — INVESTIGATE
Trace the bug from symptom to root cause:
- Read the code path involved (follow the data flow).
- 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
STEP 3 — HYPOTHESIZE + PLAN
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>
- If the root cause is still unclear after investigation, say so explicitly. List remaining hypotheses ranked by probability. Ask the user before proceeding.
- If the fix is trivial after investigation (1-2 lines): proceed directly — no need to wait for approval on an obvious fix.
- If the fix is significant (>10 lines, multiple files, behavior change): wait for user approval.
STEP 4 — FIX
Apply the fix following the plan:
- Fix the root cause, not the symptom.
- Add or update tests to cover the bug case (regression test).
- If no test framework exists: document what you verified.
- Keep changes minimal — fix the bug, nothing else.
STEP 5 — VERIFY + COMMIT
- 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>
STEP 6 — DOC SYNC (automatic)
Load $HOME/.claude/agents/doc-syncer.md.
Execute in automatic mode:
auto-mode scope: <list of files modified during this session>
STEP 7 — CAPITALIZE (memory registries)
A bugfix with an understood root cause is almost always worth one entry:
- Propose a
BLK-XXXentry in.claude/memory/blockers.mdpre-filled from STEP 3 diagnosis:friction= symptomreal_cause= root cause identifiedsolution= the fix appliedstatus= resolved
- If the root cause exposed a reusable pattern (would catch the same bug elsewhere or in other projects) → also propose an
LRN-XXXentry in.claude/memory/learnings.md. - Present as:
CAPITALIZE — proposé BLK-XXX — <friction> — resolved [LRN-XXX — <pattern>] (optionnel) Valider ? (all / blockers-only / edit / skip) - Append approved entries + update the Index. Add a line to today's heading in
.claude/memory/journal.md.
Language rule: written entries are ALWAYS in English (see CLAUDE.md "Memory registries" § Language). The interactive gate may mirror the user's language; the appended entries must not.
If the bug was trivial and the root cause not transferable → skip with CAPITALIZE: trivial, skip.
RULES
- No fix without understanding the root cause first.
- Design gate only if UI/style signals detected. See STEP 1.5.
- If investigation reveals a design flaw requiring significant
refactoring → stop, explain, suggest
/ship-featurefor the proper fix. - Always add a regression test when possible.
- Keep the fix scoped. No "while we're here" cleanups.
- If >5 files need changes → reconsider if
/ship-featureis more appropriate.