| name | fix-issue |
| description | Systematically investigate and fix a GitHub Issue with root cause analysis. Use when user says "fix issue", "fix |
| user-invocable | true |
| allowed-tools | Read, Edit, Write, Grep, Glob, Bash |
| argument-hint | [issue-number] |
| hooks | {"SessionStart":[{"hooks":[{"type":"command","command":"node -e \"\n const { execSync } = require('child_process');\n try { execSync('gh auth status', { stdio: 'pipe' }); }\n catch { console.log(JSON.stringify({additionalContext:'WARNING: gh CLI is not authenticated. Run gh auth login before using /fix-issue.'})); }\n\"\n"}]}]} |
Fix Issue: #$ARGUMENTS
Dynamic Context
- Issue details: !
gh issue view $ARGUMENTS 2>/dev/null || echo "Issue not found. Please verify the issue number."
- Issue comments: !
gh issue view $ARGUMENTS --comments 2>/dev/null | tail -30 || echo ""
- Recent commits: !
git log --oneline -10 2>/dev/null || echo "N/A"
- Current branch: !
git branch --show-current 2>/dev/null
Phase 1: Issue Analysis
- Read the issue title, description, and all comments
- Identify:
- Expected behavior vs actual behavior
- Reproduction steps (if provided)
- Environment constraints (OS, version, configuration)
- Severity and priority indicators
- If information is insufficient, list what's missing before proceeding
Phase 2: Root Cause Investigation
- Search codebase for relevant code using issue keywords
- Trace the execution path related to the bug
- Form ranked hypotheses:
- H1: Most likely cause (based on symptoms)
- H2: Second most likely
- H3: Less likely but possible
- For each hypothesis, gather evidence to confirm or refute
- Apply 5-Why analysis on the confirmed cause:
Problem: [symptom from issue]
Why 1: [immediate cause]
Why 2: [cause of Why 1]
Why 3: [deeper cause]
Root cause: [fundamental issue]
Phase 3: Fix Implementation
- Implement the minimal change that addresses the root cause
- Preserve existing behavior for unaffected code paths
- Follow existing code patterns and conventions
- Do not refactor surrounding code — fix the bug only
Phase 4: Regression Test
- Write a test that reproduces the original bug (fails without fix)
- Verify the test passes with the fix applied
- Add edge case tests for related scenarios
- Run the full test suite to confirm no regressions
Phase 5: Prepare Commit
- Stage only the relevant files (fix + test)
- Craft commit message referencing the issue:
fix: [concise description of the fix]
Root cause: [brief explanation]
Closes #$ARGUMENTS
Output
Issue: #$ARGUMENTS — [title]
Root Cause: [explanation]
Fix: [file:line] — [description of change]
Test: [test file:line] — [what the test verifies]
Regression suite: PASS / FAIL