Analyze GitHub Issue Command
Purpose
Investigate a GitHub issue reporting a production problem by fetching issue details, extracting error information, searching the codebase for related code, analyzing git history, and generating a root cause analysis report.
Instructions for Claude
When this command is invoked, perform comprehensive root cause analysis for a GitHub issue:
Step 1: Gather Issue Information
If user provided issue number:
- Read settings from
.claude/thufir.local.md to get default repo
- Use github MCP tool to fetch issue details:
- Tool:
github_get_issue
- Parameters:
{issue_number: <number>}
If user provided issue URL:
- Parse URL to extract owner, repo, and issue number
- Use github MCP tool with parsed values
If no argument provided:
- Use AskUserQuestion to ask:
- "What is the GitHub issue number?"
- Or "What repository? (leave blank for default from settings)"
Extract from issue:
- Issue number and title
- Issue body/description
- Labels (look for "production", "incident", "p0", "bug")
- Created/updated timestamps
- Comments (read comments for additional context)
- Assignees
- Related PRs or issues mentioned
Step 2: Parse Error Information
From issue body and comments, extract:
-
Error messages:
- Stack traces
- Error names (e.g., "ConnectionPoolExhausted")
- Error codes (500, 503, timeout, etc.)
-
Reproduction details:
- Steps to reproduce
- Affected features or endpoints
- User actions that trigger error
-
Impact information:
- When error first occurred (timestamp)
- How many users affected
- Frequency (one-time, intermittent, constant)
- Geographic or segment-specific
-
System context:
- Service or component mentioned
- Environment (production, staging)
- Browser or client information
Parse patterns like:
- "Users are getting 500 errors..."
- "Error: ConnectionPoolExhausted at 14:32 UTC"
- "Stack trace: ..."
- "Approximately 15,000 users affected"
Step 3: Search Codebase for Related Code
Based on extracted error information:
- Search for error strings:
# Use Grep to find error in codebase
grep -r "ConnectionPoolExhausted" --include="*.js" --include="*.py"
- Search for affected components:
- If issue mentions "login", search for login-related files
- If mentions specific endpoint, find that endpoint code
- Use Glob to find relevant files by path pattern
- Find error-handling code:
- Where is the error raised?
- What conditions trigger it?
- What code path leads to error?
- Identify relevant files:
- Entry points (API routes, controllers)
- Business logic
- Database access layer
- External integrations
- Configuration files
- Read suspicious files to understand implementation
Step 4: Analyze Git History
Use Bash to run git commands:
-
Determine time window:
- Start: 24-48 hours before error first occurred
- End: When error was first reported
-
List recent commits:
git log --since="<window-start>" --until="<error-time>" --oneline
- Focus on affected files:
git log --since="<window>" -- path/to/affected/file.js
- Use git blame on error location:
- If stack trace includes file/line, blame that line
git blame -L <line>,<line> path/to/file.js
- Review recent commits to config files:
git log --since="<window>" -- config/ "*.config.js" ".env*"
- Show commit details:
git show <commit-sha>
- Check for deployment correlation:
- Were there commits/merges around error time?
- Check deployment tags or main branch history
Step 5: Correlate with Metrics (if available)
If Prometheus integration is configured:
-
Query metrics around error time:
- Error rate metrics
- Latency metrics
- Resource utilization
-
Look for metric anomalies correlating with issue timestamp
-
Add metric evidence to RCA
Step 6: Identify Root Cause
Synthesize all evidence:
-
Timeline reconstruction:
- When did error first occur?
- What commits were made before that?
- Were there deployments?
-
Code analysis:
- What code could cause this error?
- Were there recent changes to that code?
- Do changes align with error symptoms?
-
Apply Five Whys:
- Why are users seeing errors?
- Why is that happening?
- (Continue drilling down)
-
Identify specific root cause:
- File: Exact file path
- Line: Specific line or function
- Commit: SHA, author, timestamp
- Change: What was changed and why it broke
- Mechanism: How the change causes the error
Step 7: Generate RCA Report
Use Write tool to create report:
-
Create report file: rca-reports/github-issue-<number>-<date>.md
-
Use RCA report template
-
Include:
- Summary: Overview of issue and root cause
- Issue Details: Number, title, labels, reporter, timestamp
- Error Information: Error messages, stack traces, reproduction steps
- Impact: Users affected, duration, severity
- Timeline: When error started, commits, detection, resolution
- Root Cause: Specific code/commit with evidence
- Code Evidence: Git diffs, blame output, commit messages
- Metrics Evidence (if available): Error rate graphs, correlations
- Suggested Fix: How to resolve
- Prevention: How to prevent recurrence
-
Link back to GitHub issue: Include issue URL in report
Step 8: Suggest Actions
After generating report, suggest:
-
Immediate fix:
- Revert problematic commit
- Apply hotfix
- Adjust configuration
-
Validation:
- Test fix in staging
- Verify error no longer occurs
- Check metrics return to normal
-
Communication:
- Update GitHub issue with findings
- Notify affected users if needed
-
Prevention:
- Add tests to catch this bug
- Improve code review process
- Add monitoring/alerting
- Update documentation
-
GitHub issue comment (optional):
- Ask if user wants to post RCA summary as issue comment
Example Invocations
With issue number (uses default repo from settings):
/rca:analyze-github 456
With full GitHub URL:
/rca:analyze-github https://github.com/owner/repo/issues/456
Interactive (no arguments):
/rca:analyze-github
→ Prompts for issue number and repo
Key Considerations
- Load skills: Activate platform-integration, root-cause-analysis, and git-investigation skills
- Use MCP tools: Leverage github MCP server for issue data
- Parse carefully: Extract all error details from issue body and comments
- Correlate timestamps: Align git commits with error occurrence time
- Be specific: Root cause must point to exact code change
- Evidence-based: Support with code diffs and git history
- Check settings: Use default_repo from
.claude/thufir.local.md
- Handle missing data: If issue lacks error details, ask user for clarification
Output
- Comprehensive RCA report saved to
rca-reports/ directory
- Console summary of findings
- Clear root cause with code evidence
- Suggested fix and prevention steps
- Option to update GitHub issue with findings
Transform GitHub issue reports into detailed root cause analyses with specific code changes, clear evidence, and actionable remediation steps.