debugging
Comprehensive debugging specialist for errors, test failures, log analysis, and system problems. Use when encountering issues, analyzing error logs, investigating system anomalies, debugging production issues, analyzing stack traces, or identifying root causes. Combines general debugging workflows with error pattern detection and log analysis.
What this skill does
# Debugging
This skill provides comprehensive debugging capabilities for identifying and fixing errors, test failures, unexpected behavior, and production issues. It combines general debugging workflows with specialized error analysis, log parsing, and pattern recognition.
## When to Use This Skill
- When encountering errors or exceptions in code
- When tests are failing and you need to understand why
- When investigating unexpected behavior or bugs
- When analyzing stack traces and error messages
- When debugging production issues
- When fixing issues reported by users or QA
- When analyzing error logs and stack traces
- When investigating performance issues or anomalies
- When correlating errors across multiple services
- When identifying recurring error patterns
- When setting up error monitoring and alerting
- When conducting post-mortem analysis of incidents
## What This Skill Does
1. **Error Analysis**: Captures and analyzes error messages and stack traces
2. **Log Parsing**: Extracts errors from logs using regex patterns and structured parsing
3. **Stack Trace Analysis**: Analyzes stack traces across multiple programming languages
4. **Error Correlation**: Identifies relationships between errors across distributed systems
5. **Pattern Recognition**: Detects common error patterns and anti-patterns
6. **Reproduction**: Identifies steps to reproduce the issue
7. **Isolation**: Locates the exact failure point in code
8. **Root Cause Analysis**: Works backward from symptoms to identify underlying causes
9. **Minimal Fix**: Implements the smallest change that resolves the issue
10. **Verification**: Confirms the solution works and doesn't introduce new issues
11. **Monitoring Setup**: Creates queries and alerts for error detection
## Helper Scripts
This skill includes Python helper scripts in `scripts/`:
- **`parse_logs.py`**: Parses log files and extracts errors, exceptions, and stack traces. Outputs JSON with error analysis and pattern detection.
```bash
python scripts/parse_logs.py /var/log/app.log
```
## How to Use
### Debug an Error
```
Debug this error: TypeError: Cannot read property 'x' of undefined
```
```
Investigate why the test is failing in test_user_service.js
```
### Analyze Error Logs
```
Analyze the error logs in /var/log/app.log and identify the root cause
```
```
Investigate why the API is returning 500 errors
```
### Pattern Detection
```
Find patterns in these error logs from the past 24 hours
```
```
Correlate errors between the API service and database
```
## Debugging Process
### 1. Capture Error Information
**Error Message:**
- Read the full error message
- Note the error type (TypeError, ReferenceError, etc.)
- Identify the error location (file and line number)
**Stack Trace:**
- Analyze the call stack
- Identify the sequence of function calls
- Find where the error originated
**Context:**
- Check recent code changes
- Review related code files
- Understand the execution flow
### 2. Error Extraction (Log Analysis)
**Using Helper Script:**
The skill includes a Python helper script for parsing logs:
```bash
# Parse log file and extract errors
python scripts/parse_logs.py /var/log/app.log
```
**Manual Log Parsing Patterns:**
```bash
# Extract errors from logs
grep -i "error\|exception\|fatal\|critical" /var/log/app.log
# Extract stack traces
grep -A 20 "Exception\|Error\|Traceback" /var/log/app.log
# Extract specific error types
grep "TypeError\|ReferenceError\|SyntaxError" /var/log/app.log
```
**Structured Log Parsing:**
```javascript
// Parse JSON logs
const errors = logs
.filter(log => log.level === 'error' || log.level === 'critical')
.map(log => ({
timestamp: log.timestamp,
message: log.message,
stack: log.stack,
context: log.context
}));
```
### 3. Stack Trace Analysis
**Common Patterns:**
**JavaScript/Node.js:**
```
Error: Cannot read property 'x' of undefined
at FunctionName (file.js:123:45)
at AnotherFunction (file.js:456:78)
```
**Python:**
```
Traceback (most recent call last):
File "app.py", line 123, in function_name
result = process(data)
File "utils.py", line 45, in process
return data['key']
KeyError: 'key'
```
**Java:**
```
java.lang.NullPointerException
at com.example.Class.method(Class.java:123)
at com.example.AnotherClass.call(AnotherClass.java:456)
```
### 4. Error Correlation
**Timeline Analysis:**
- Group errors by timestamp
- Identify error spikes and patterns
- Correlate with deployments or changes
- Check for cascading failures
**Service Correlation:**
- Map errors across service boundaries
- Identify upstream/downstream relationships
- Track error propagation paths
- Find common failure points
### 5. Pattern Recognition
**Common Error Patterns:**
**N+1 Query Problem:**
```
Multiple database queries in loop
Pattern: SELECT * FROM users; SELECT * FROM posts WHERE user_id = ?
```
**Memory Leaks:**
```
Gradually increasing memory usage
Pattern: Memory growth over time without release
```
**Race Conditions:**
```
Intermittent failures under load
Pattern: Errors only occur with concurrent requests
```
**Timeout Issues:**
```
Requests timing out
Pattern: Errors after specific duration (e.g., 30s)
```
### 6. Reproduce the Issue
**Reproduction Steps:**
1. Identify the exact conditions that trigger the error
2. Create a minimal test case that reproduces the issue
3. Verify the issue is consistent and reproducible
4. Document the steps clearly
**Example:**
```markdown
## Reproduction Steps
1. Navigate to `/users/123`
2. Click "Edit Profile"
3. Submit form without filling required fields
4. Error occurs: "Cannot read property 'validate' of undefined"
```
### 7. Isolate the Failure Location
**Code Analysis:**
- Read the code around the error location
- Trace the execution path
- Identify where the assumption breaks
- Check variable states and values
**Debugging Techniques:**
- Add strategic logging to track execution
- Use debugger breakpoints
- Inspect variable states
- Check function return values
- Verify data structures
### 8. Form and Test Hypotheses
**Hypothesis Formation:**
- What could cause this error?
- What assumptions might be wrong?
- What edge cases weren't considered?
- What dependencies might be missing?
**Testing Hypotheses:**
- Add logging to verify assumptions
- Test edge cases
- Check input validation
- Verify dependencies are available
- Test with different data
### 9. Root Cause Analysis
**Investigation Steps:**
1. **Start with Symptoms**: What error is occurring?
2. **Work Backward**: What changed before the error?
3. **Check Patterns**: Is this recurring or isolated?
4. **Correlate Events**: What else happened at the same time?
5. **Identify Cause**: What is the underlying issue?
**Analysis Framework:**
```markdown
## Error Analysis
**Error**: [Description]
**Frequency**: [How often]
**Timeline**: [When it started]
**Affected Services**: [Which services]
**User Impact**: [How many users affected]
**Root Cause Hypothesis**:
- [Primary hypothesis with evidence]
- [Alternative hypotheses]
**Evidence**:
- [Log entries supporting hypothesis]
- [Error patterns observed]
- [Correlation with other events]
**Recommended Actions**:
- [Immediate fix]
- [Long-term prevention]
```
### 10. Implement Minimal Fix
**Fix Principles:**
- Fix the root cause, not just symptoms
- Make the smallest change possible
- Preserve existing functionality
- Don't introduce new complexity
- Add appropriate error handling
**Fix Verification:**
- Test the fix with the reproduction case
- Verify no regressions
- Check edge cases
- Ensure error handling is appropriate
- Confirm the fix is complete
### 11. Document the Solution
**Documentation Should Include:**
- Root cause explanation
- Evidence supporting the diagnosis
- Specific code fix
- Testing approach
- Prevention recommendations
## Examples
### Example 1: Null Reference Error
**Input**: Error: `TypeError: Cannot reRelated in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.