--- name: fix-bug description: Fix a bug following the Reproduce > Diagnose > Fix > Verify workflow. Use when something is broken, there's an error, or the user reports unexpected behavior. disable-model-invocation: true --- # Fix Bug: $ARGUMENTS Follow this structured workflow. Do not skip phases. ## Phase 1: Reproduce - Read the bug description: **$ARGUMENTS** - Find the relevant code by searching for related functions, error messages, or file paths - Understand the expected behavior vs. actual behavior - Identify a way to reproduce the issue (test case or manual steps) - Write a failing test that demonstrates the bug ## Phase 2: Diagnose - Trace the code path that leads to the bug - Identify the root cause — not just the symptom - Check if this bug exists in other similar code paths - Understand why the original code was written this way before changing it ## Phase 3: Fix - Make the minimal change that fixes the root cause - Do NOT refactor surrounding code unless it's directly related to the bug - Ensure the failing test from Phase 1 now passes - Add additional edge case tests if the bug reveals gaps in test coverage ## Phase 4: Verify - [ ] The originally failing test now passes - [ ] All existing tests still pass: `{{TEST_COMMAND}}` - [ ] Linting passes: `{{LINT_COMMAND}}` - [ ] Build succeeds: `{{BUILD_COMMAND}}` - [ ] No regressions in related functionality - [ ] The fix addresses the root cause, not just the symptom ## Phase 5: Document - Add a brief comment explaining the fix if the logic isn't self-evident - If the bug came from a common pattern, note what to watch for in similar code