From claude-quality
Guides 5-step structured bug fixing: reproduce reliably, isolate code location with git bisect/logging, analyze root cause via 5 Whys, minimal fix, prevent recurrence with tests/types.
npx claudepluginhub bulbulogludemir/claude-code-pluginsThis skill uses the workspace's default tool permissions.
<command-name>bugfix</command-name>
Executes step-by-step bug fix workflow: read issue, diagnose root cause, reproduce (browser for UI bugs), minimal fix, regression test, verify, open PR.
Fixes bugs via root cause diagnosis with debugger/gap-analyzer, requirements.md generation, /execute delegation, 3-retry circuit breaker, and QA.
Suggests manual /compact at logical task boundaries in long Claude Code sessions and multi-phase tasks to avoid arbitrary auto-compaction losses.
Share bugs, ideas, or general feedback.
bugfix
5-step systematic bug fix process to ensure thorough diagnosis, minimal fix, and prevention of recurrence.
bug, error, fix, broken, not working, failing, crash, regression
Goal: Reliably reproduce the bug before attempting any fix.
Checklist:
ā” Can I reproduce the bug?
ā” What are the exact steps?
ā” What is the expected vs actual behavior?
ā” Is it consistent or intermittent?
ā” What environment? (dev/staging/prod)
Questions to answer:
Output: Documented reproduction steps
Goal: Find the exact location of the bug in code.
Checklist:
ā” Which file(s) are involved?
ā” Which function/component?
ā” What line causes the issue?
ā” What are the inputs at that point?
Techniques:
# Find when bug was introduced
git bisect start
git bisect bad HEAD
git bisect good <known-good-commit>
# Test each commit until found
Output: Exact code location (file:line)
Goal: Understand WHY the bug exists using 5 Whys technique.
Example:
1. Why did it crash? ā Undefined property access
2. Why was it undefined? ā API returned null
3. Why did API return null? ā User not found
4. Why wasn't user found? ā ID was wrong type
5. Why was ID wrong type? ā Missing parseInt() on URL param
Root cause: Missing type coercion on route parameter
Questions:
Output: Root cause understanding
Goal: Apply the minimal, targeted fix.
Principles:
ā” Fix ONLY the root cause
ā” Don't refactor unrelated code
ā” Don't add unrelated features
ā” Keep the diff small
ā” Maintain backwards compatibility
Fix Types:
| Bug Type | Fix Pattern |
|---|---|
| Null/undefined | Add defensive check or fix source |
| Type error | Fix type coercion at boundary |
| Logic error | Fix condition or algorithm |
| Race condition | Add proper async handling |
| Missing validation | Add validation at entry point |
Verification:
# Compile check
npx tsc --noEmit
# Manual test the fix
npm run dev
# Test the reproduction steps
# Ensure no regressions
npm test
Output: Working fix with passing tests
Goal: Ensure this bug never happens again.
Checklist:
ā” Add/update test case
ā” Document if complex
ā” Update types if type-related
ā” Add validation if input-related
ā” Consider similar code paths
Test Template:
describe('bugfix: [description]', () => {
it('should handle [edge case]', () => {
// Reproduce the original bug scenario
const result = functionUnderTest(buggyInput)
// Assert correct behavior
expect(result).toBe(expectedOutput)
})
})
Check for Similar Issues:
# Find similar patterns in codebase
rg "similar-pattern" --type ts
Output: Test case + documentation
When reporting/tracking a bug:
## Bug: [Title]
**Reproduction:**
1. Step 1
2. Step 2
3. Step 3
**Expected:** What should happen
**Actual:** What actually happens
**Environment:**
- Browser: Chrome 120
- OS: macOS 14
- Environment: Production
**Root Cause:** [After analysis]
**Fix:** [PR/commit link]
**Prevention:** [Test added]
| Phase | Time | Output |
|---|---|---|
| REPRODUCE | 5-10 min | Reproduction steps |
| ISOLATE | 5-15 min | Code location |
| ANALYZE | 5-10 min | Root cause |
| FIX | 10-30 min | Working code |
| PREVENT | 5-15 min | Test case |
Total: 30-80 minutes for most bugs
ā Fix symptoms, not root cause ā Add workarounds without understanding ā Shotgun debugging (random changes) ā Skip reproduction ("I think I know...") ā Large refactors disguised as bug fixes ā Skip writing tests ā Say "done" without verifying fix