Bug Analysis
Overview
This skill provides systematic bug analysis to identify root causes, assess impact, classify severity, and generate actionable fix recommendations. It helps triage bugs efficiently and provides structured analysis for development teams.
Core Analysis Workflow
Step 1: Initial Triage & Information Gathering
Collect Essential Information:
- Bug description and symptoms
- Reproduction steps (verify they work)
- Expected vs actual behavior
- Environment details (OS, browser, version, config)
- Error messages, stack traces, logs
- Screenshots or videos
- User impact and frequency
Quick Assessment:
- Severity: Critical/High/Medium/Low
- Type: Functional/Performance/Security/UI/Data/Integration/Configuration/Regression
- Priority: Based on severity + business impact
- Potential duplicates: Search existing issues
Step 2: Bug Categorization
Severity Classification (see severity-guidelines.md for detailed criteria):
Critical (P0) - Response: Immediate (<1 hour)
- System outage, data loss, security breach, no workaround
High (P1) - Response: Same day
- Major feature broken, significant user impact (>25%), difficult workaround
Medium (P2) - Response: Within 1 week
- Feature partially broken, moderate impact, workaround available
Low (P3) - Response: Backlog
- Minor issue, cosmetic problem, minimal impact
Bug Type Categories:
- Functional: Feature not working as specified
- Performance: Slow response, timeouts, resource issues
- Security: Vulnerabilities, unauthorized access
- UI/UX: Visual glitches, usability problems
- Data: Corruption, loss, incorrect processing
- Integration: API failures, third-party issues
- Configuration: Environment or deployment issues
- Regression: Previously working feature broken
Step 3: Root Cause Analysis
Investigation Process:
Review Error Evidence
- Parse stack traces to identify failure point
- Map error codes to known issues
- Check recent code changes (git blame, commit history)
Reproduce the Issue
- Validate reproduction steps
- Test in different environments
- Vary inputs to identify boundaries
- Document consistent reproduction method
Trace Execution Flow
- Follow code path from entry to failure
- Identify where actual diverges from expected
- Check data transformations and control flow
- Review relevant code sections
Analyze Dependencies
- Verify library and framework versions
- Check for known issues in dependencies
- Review integration points
- Test with different dependency versions
Common Root Cause Patterns:
- Logic errors (incorrect conditions, calculations)
- Null/undefined reference errors
- Race conditions and timing issues
- Memory leaks
- Boundary conditions (off-by-one, overflow)
- Configuration issues
- Dependency problems
- Integration failures
For detailed analysis techniques, see analysis-techniques.md for:
- Five Whys technique
- Stack trace analysis
- Differential analysis
- Data flow tracing
- Hypothesis testing
- Evidence collection methods
Step 4: Impact Assessment
Evaluate Impact Across Dimensions:
User Impact:
- Number/percentage of affected users
- User workflows disrupted
- User segments affected
Business Impact:
- Revenue loss or risk
- SLA violations
- Customer satisfaction impact
- Reputation risk
System Impact:
- Performance degradation
- Resource consumption
- Cascading failures
- Data integrity risks
Security Impact (if applicable):
- Confidentiality: Data exposure level
- Integrity: Unauthorized modifications
- Availability: Service disruptions
- Exploit potential
Scope Definition:
- Affected versions/releases
- Affected platforms/browsers
- Affected features/workflows
- Regression scope
Step 5: Fix Recommendation
Generate Structured Fix Strategy:
1. Immediate Mitigation (if not already done):
- Workarounds for users
- Configuration changes to reduce impact
- Feature flags to disable problematic code
- Rollback options if recent regression
2. Permanent Solution:
- Specific code changes needed
- Files to modify with line numbers
- Design changes required
- Database migrations or cleanup needed
- Configuration updates required
3. Testing Requirements:
- Unit tests to add
- Integration tests needed
- Regression tests to prevent recurrence
- Performance/security tests if applicable
4. Prevention Measures:
- Code review focus areas
- Additional validation needed
- Monitoring/alerting to add
- Documentation updates
- Process improvements
Output Format
Provide structured analysis using these templates:
Standard Bug Analysis: Use template from output-templates.md including:
- Bug summary with severity and priority
- Environment and reproduction steps
- Root cause analysis with evidence
- Impact assessment
- Recommended fix with testing plan
Specialized Reports (see output-templates.md):
- Security Vulnerability Report: CVSS scoring, attack vectors, disclosure plan
- Performance Bug Report: Metrics, profiling results, optimization strategy
- Crash Analysis Report: Stack traces, memory state, crash triggers
Special Analysis Scenarios
Security Vulnerabilities
For security issues:
- Assess using CVSS: Attack vector, complexity, privileges, impact
- Identify exploit potential: Remote exploitation, authentication required
- Plan containment: Immediate patches, access restrictions, monitoring
- Disclosure strategy: Timeline, notifications, compliance (CVE, GDPR, PCI-DSS)
See severity-guidelines.md for security-specific triage.
Performance Issues
For performance bugs:
- Establish baseline: Expected metrics, SLA thresholds
- Identify bottlenecks: CPU profiling, memory patterns, I/O, database queries
- Quantify degradation: Response time increase, throughput reduction
- Optimization strategy: Code optimization, caching, indexing, architecture changes
Crash Analysis
For application crashes:
- Analyze crash dump: Exception type, stack trace, thread states
- Identify trigger: User action, system condition, data input, timing
- Assess stability impact: Frequency, affected scenarios, data loss risk
- Recovery strategy: Crash handling, graceful degradation, monitoring
Investigation Tools & Commands
For detailed command references, see investigation-commands.md:
Version Control:
git bisect - Find commit that introduced bug
git blame - See who last modified code
git log -S "text" - Find when code changed
Log Analysis:
grep -A 5 -B 5 "error" app.log - Find errors with context
tail -f app.log | grep ERROR - Monitor errors real-time
- Log parsing with awk and analysis scripts
Database Investigation:
- PostgreSQL: Slow query analysis, index usage
- MySQL: Process list, deadlock detection
- MongoDB: Operation profiling, collection stats
System Monitoring:
- Process monitoring:
top, ps, htop
- Memory analysis:
free, pmap, valgrind
- Network analysis:
netstat, tcpdump, curl -v
Application Debugging:
- Node.js:
node --inspect, profiling, heap snapshots
- Python:
pdb, cProfile, memory profiling
- Java:
jmap, jstack, flight recorder
- Docker/Kubernetes: Container logs, exec, debugging
Best Practices
Investigation Principles
- Evidence-based: Base conclusions on concrete data, not assumptions
- Systematic: Follow logical investigation process
- Hypothesis-driven: Form hypotheses, test them, verify results
- Document everything: Record findings, reasoning, and decisions
- Consider multiple causes: Don't fixate on first theory
Effective Communication
- Use clear language: Avoid jargon with non-technical stakeholders
- Provide context: Explain why the bug matters
- Set expectations: Realistic timelines and complexity
- Offer workarounds: Help users immediately when possible
- Follow up: Update stakeholders on progress
Prevention Focus
After fixing bugs:
- Identify patterns: Common causes across multiple bugs
- Improve testing: Add coverage for bug scenarios
- Enhance monitoring: Add alerts for similar issues
- Update processes: Code review checklists, deployment procedures
- Document lessons: Update knowledge base
Quick Reference
Common Root Causes Checklist
Quick Diagnosis Commands
# Service status
systemctl status service_name
# Resource usage
top -bn1 | head -20 # CPU
ps aux --sort=-%mem | head -10 # Memory
du -sh /* | sort -rh | head -10 # Disk
# Recent changes
git log --since="1 day ago" --oneline
# Error analysis
tail -100 /var/log/app.log | grep -i error
grep ERROR /var/log/app.log | wc -l
Integration with Development Workflow
Bug Lifecycle:
- New → Report received
- Triage → Analysis and prioritization (use this skill)
- Confirmed → Reproduced, root cause identified
- Assigned → Developer assigned
- In Progress → Fix being implemented
- Code Review → Fix under review
- Testing → QA validation
- Fixed → Deployed
- Closed → Verified resolved
Documentation Requirements:
- Link to code: Files and line numbers
- Link to tests: Verify fix test cases
- Link to monitoring: Dashboards or alerts
- Link to related issues: Duplicates, related bugs
- Update documentation: If user-facing changes
Reference Files
Load reference files based on analysis needs:
Severity Guidelines: See severity-guidelines.md when:
- Determining bug severity and priority
- Understanding triage criteria
- Need severity/priority matrix
- Security vulnerability classification
Analysis Techniques: See analysis-techniques.md when:
- Need detailed RCA methodologies
- Applying Five Whys or other techniques
- Conducting hypothesis testing
- Performing evidence collection
- Using specific debugging strategies
Output Templates: See output-templates.md when:
- Creating bug reports
- Writing RCA documents
- Documenting security vulnerabilities
- Reporting performance issues
- Analyzing crashes
- Marking duplicates
Investigation Commands: See investigation-commands.md when:
- Need specific command syntax
- Working with version control (git)
- Analyzing logs and databases
- Monitoring system resources
- Debugging applications
- Using container tools (Docker, Kubernetes)
1---2name: bug-analysis3description: Analyzes software bugs including root cause identification, severity assessment, impact analysis, reproduction steps validation, and fix recommendations. Performs bug triage, categorization, duplicate detection, and regression analysis. Use when investigating bugs, analyzing crash reports, triaging issues, debugging problems, reviewing error logs, or when users mention "analyze bug", "investigate issue", "debug problem", "bug report", "crash analysis", "root cause analysis", or "fix recommendation".4---5
6# Bug Analysis
7
8## Overview
9
10This skill provides systematic bug analysis to identify root causes, assess impact, classify severity, and generate actionable fix recommendations. It helps triage bugs efficiently and provides structured analysis for development teams.
11
12## Core Analysis Workflow
13
14## Step 1: Initial Triage & Information Gathering
15
16**Collect Essential Information:**
17
18- Bug description and symptoms
19- Reproduction steps (verify they work)
20- Expected vs actual behavior
21- Environment details (OS, browser, version, config)
22- Error messages, stack traces, logs
23- Screenshots or videos
24- User impact and frequency
25
26**Quick Assessment:**
27
28- Severity: Critical/High/Medium/Low
29- Type: Functional/Performance/Security/UI/Data/Integration/Configuration/Regression
30- Priority: Based on severity + business impact
31- Potential duplicates: Search existing issues
32
33### Step 2: Bug Categorization
34
35**Severity Classification** (see [severity-guidelines.md](references/severity-guidelines.md) for detailed criteria):
36
37**Critical (P0)** - Response: Immediate (<1 hour)
38
39- System outage, data loss, security breach, no workaround
40
41**High (P1)** - Response: Same day
42
43- Major feature broken, significant user impact (>25%), difficult workaround
44
45**Medium (P2)** - Response: Within 1 week
46
47- Feature partially broken, moderate impact, workaround available
48
49**Low (P3)** - Response: Backlog
50
51- Minor issue, cosmetic problem, minimal impact
52
53**Bug Type Categories:**
54
55- **Functional**: Feature not working as specified
56- **Performance**: Slow response, timeouts, resource issues
57- **Security**: Vulnerabilities, unauthorized access
58- **UI/UX**: Visual glitches, usability problems
59- **Data**: Corruption, loss, incorrect processing
60- **Integration**: API failures, third-party issues
61- **Configuration**: Environment or deployment issues
62- **Regression**: Previously working feature broken
63
64### Step 3: Root Cause Analysis
65
66**Investigation Process:**
67
681. **Review Error Evidence**
69 - Parse stack traces to identify failure point
70 - Map error codes to known issues
71 - Check recent code changes (git blame, commit history)
72
732. **Reproduce the Issue**
74 - Validate reproduction steps
75 - Test in different environments
76 - Vary inputs to identify boundaries
77 - Document consistent reproduction method
78
793. **Trace Execution Flow**
80 - Follow code path from entry to failure
81 - Identify where actual diverges from expected
82 - Check data transformations and control flow
83 - Review relevant code sections
84
854. **Analyze Dependencies**
86 - Verify library and framework versions
87 - Check for known issues in dependencies
88 - Review integration points
89 - Test with different dependency versions
90
91**Common Root Cause Patterns:**
92
93- Logic errors (incorrect conditions, calculations)
94- Null/undefined reference errors
95- Race conditions and timing issues
96- Memory leaks
97- Boundary conditions (off-by-one, overflow)
98- Configuration issues
99- Dependency problems
100- Integration failures
101
102**For detailed analysis techniques**, see [analysis-techniques.md](references/analysis-techniques.md) for:
103
104- Five Whys technique
105- Stack trace analysis
106- Differential analysis
107- Data flow tracing
108- Hypothesis testing
109- Evidence collection methods
110
111### Step 4: Impact Assessment
112
113**Evaluate Impact Across Dimensions:**
114
115**User Impact:**
116
117- Number/percentage of affected users
118- User workflows disrupted
119- User segments affected
120
121**Business Impact:**
122
123- Revenue loss or risk
124- SLA violations
125- Customer satisfaction impact
126- Reputation risk
127
128**System Impact:**
129
130- Performance degradation
131- Resource consumption
132- Cascading failures
133- Data integrity risks
134
135**Security Impact** (if applicable):
136
137- Confidentiality: Data exposure level
138- Integrity: Unauthorized modifications
139- Availability: Service disruptions
140- Exploit potential
141
142**Scope Definition:**
143
144- Affected versions/releases
145- Affected platforms/browsers
146- Affected features/workflows
147- Regression scope
148
149### Step 5: Fix Recommendation
150
151**Generate Structured Fix Strategy:**
152
153**1. Immediate Mitigation** (if not already done):
154
155- Workarounds for users
156- Configuration changes to reduce impact
157- Feature flags to disable problematic code
158- Rollback options if recent regression
159
160**2. Permanent Solution:**
161
162- Specific code changes needed
163- Files to modify with line numbers
164- Design changes required
165- Database migrations or cleanup needed
166- Configuration updates required
167
168**3. Testing Requirements:**
169
170- Unit tests to add
171- Integration tests needed
172- Regression tests to prevent recurrence
173- Performance/security tests if applicable
174
175**4. Prevention Measures:**
176
177- Code review focus areas
178- Additional validation needed
179- Monitoring/alerting to add
180- Documentation updates
181- Process improvements
182
183## Output Format
184
185Provide structured analysis using these templates:
186
187**Standard Bug Analysis**: Use template from [output-templates.md](references/output-templates.md) including:
188
189- Bug summary with severity and priority
190- Environment and reproduction steps
191- Root cause analysis with evidence
192- Impact assessment
193- Recommended fix with testing plan
194
195**Specialized Reports** (see [output-templates.md](references/output-templates.md)):
196
197- **Security Vulnerability Report**: CVSS scoring, attack vectors, disclosure plan
198- **Performance Bug Report**: Metrics, profiling results, optimization strategy
199- **Crash Analysis Report**: Stack traces, memory state, crash triggers
200
201## Special Analysis Scenarios
202
203### Security Vulnerabilities
204
205For security issues:
206
2071. **Assess using CVSS**: Attack vector, complexity, privileges, impact
2082. **Identify exploit potential**: Remote exploitation, authentication required
2093. **Plan containment**: Immediate patches, access restrictions, monitoring
2104. **Disclosure strategy**: Timeline, notifications, compliance (CVE, GDPR, PCI-DSS)
211
212See [severity-guidelines.md](references/severity-guidelines.md) for security-specific triage.
213
214### Performance Issues
215
216For performance bugs:
217
2181. **Establish baseline**: Expected metrics, SLA thresholds
2192. **Identify bottlenecks**: CPU profiling, memory patterns, I/O, database queries
2203. **Quantify degradation**: Response time increase, throughput reduction
2214. **Optimization strategy**: Code optimization, caching, indexing, architecture changes
222
223### Crash Analysis
224
225For application crashes:
226
2271. **Analyze crash dump**: Exception type, stack trace, thread states
2282. **Identify trigger**: User action, system condition, data input, timing
2293. **Assess stability impact**: Frequency, affected scenarios, data loss risk
2304. **Recovery strategy**: Crash handling, graceful degradation, monitoring
231
232## Investigation Tools & Commands
233
234For detailed command references, see [investigation-commands.md](references/investigation-commands.md):
235
236**Version Control:**
237
238- `git bisect` - Find commit that introduced bug
239- `git blame` - See who last modified code
240- `git log -S "text"` - Find when code changed
241
242**Log Analysis:**
243
244- `grep -A 5 -B 5 "error" app.log` - Find errors with context
245- `tail -f app.log | grep ERROR` - Monitor errors real-time
246- Log parsing with awk and analysis scripts
247
248**Database Investigation:**
249
250- PostgreSQL: Slow query analysis, index usage
251- MySQL: Process list, deadlock detection
252- MongoDB: Operation profiling, collection stats
253
254**System Monitoring:**
255
256- Process monitoring: `top`, `ps`, `htop`
257- Memory analysis: `free`, `pmap`, `valgrind`
258- Network analysis: `netstat`, `tcpdump`, `curl -v`
259
260**Application Debugging:**
261
262- Node.js: `node --inspect`, profiling, heap snapshots
263- Python: `pdb`, `cProfile`, memory profiling
264- Java: `jmap`, `jstack`, flight recorder
265- Docker/Kubernetes: Container logs, exec, debugging
266
267## Best Practices
268
269### Investigation Principles
270
271- **Evidence-based**: Base conclusions on concrete data, not assumptions
272- **Systematic**: Follow logical investigation process
273- **Hypothesis-driven**: Form hypotheses, test them, verify results
274- **Document everything**: Record findings, reasoning, and decisions
275- **Consider multiple causes**: Don't fixate on first theory
276
277### Effective Communication
278
279- **Use clear language**: Avoid jargon with non-technical stakeholders
280- **Provide context**: Explain why the bug matters
281- **Set expectations**: Realistic timelines and complexity
282- **Offer workarounds**: Help users immediately when possible
283- **Follow up**: Update stakeholders on progress
284
285### Prevention Focus
286
287After fixing bugs:
288
289- **Identify patterns**: Common causes across multiple bugs
290- **Improve testing**: Add coverage for bug scenarios
291- **Enhance monitoring**: Add alerts for similar issues
292- **Update processes**: Code review checklists, deployment procedures
293- **Document lessons**: Update knowledge base
294
295## Quick Reference
296
297### Common Root Causes Checklist
298
299- [ ] Null/undefined reference
300- [ ] Off-by-one error or boundary condition
301- [ ] Race condition or timing issue
302- [ ] Memory leak
303- [ ] Missing validation or error handling
304- [ ] Configuration issue
305- [ ] Dependency version mismatch
306- [ ] API contract change
307- [ ] Database schema mismatch
308- [ ] Incorrect permissions
309- [ ] Resource exhaustion
310- [ ] Caching issue
311- [ ] Timezone/date handling
312- [ ] Character encoding problem
313
314### Quick Diagnosis Commands
315
316```bash
317# Service status
318systemctl status service_name
319
320# Resource usage
321top -bn1 | head -20 # CPU
322ps aux --sort=-%mem | head -10 # Memory
323du -sh /* | sort -rh | head -10 # Disk
324
325# Recent changes
326git log --since="1 day ago" --oneline
327
328# Error analysis
329tail -100 /var/log/app.log | grep -i error
330grep ERROR /var/log/app.log | wc -l
331```
332
333## Integration with Development Workflow
334
335**Bug Lifecycle:**
336
3371. **New** → Report received
3382. **Triage** → Analysis and prioritization (use this skill)
3393. **Confirmed** → Reproduced, root cause identified
3404. **Assigned** → Developer assigned
3415. **In Progress** → Fix being implemented
3426. **Code Review** → Fix under review
3437. **Testing** → QA validation
3448. **Fixed** → Deployed
3459. **Closed** → Verified resolved
346
347**Documentation Requirements:**
348
349- Link to code: Files and line numbers
350- Link to tests: Verify fix test cases
351- Link to monitoring: Dashboards or alerts
352- Link to related issues: Duplicates, related bugs
353- Update documentation: If user-facing changes
354
355## Reference Files
356
357Load reference files based on analysis needs:
358
359- **Severity Guidelines**: See [severity-guidelines.md](references/severity-guidelines.md) when:
360 - Determining bug severity and priority
361 - Understanding triage criteria
362 - Need severity/priority matrix
363 - Security vulnerability classification
364
365- **Analysis Techniques**: See [analysis-techniques.md](references/analysis-techniques.md) when:
366 - Need detailed RCA methodologies
367 - Applying Five Whys or other techniques
368 - Conducting hypothesis testing
369 - Performing evidence collection
370 - Using specific debugging strategies
371
372- **Output Templates**: See [output-templates.md](references/output-templates.md) when:
373 - Creating bug reports
374 - Writing RCA documents
375 - Documenting security vulnerabilities
376 - Reporting performance issues
377 - Analyzing crashes
378 - Marking duplicates
379
380- **Investigation Commands**: See [investigation-commands.md](references/investigation-commands.md) when:
381 - Need specific command syntax
382 - Working with version control (git)
383 - Analyzing logs and databases
384 - Monitoring system resources
385 - Debugging applications
386 - Using container tools (Docker, Kubernetes)