[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6EJ769FJGYRYAVSAXAH5Z36":3,"skill-same:01M6EJ769FJGYRYAVSAXAH5Z36":119},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":42,"linkOnly":43,"markdownContent":44,"markdownBody":45,"frontMatter":46,"refName":52,"commitSha":53,"skillDirectory":54,"forksCount":55,"repositoryHtmlUrl":56,"repositoryHomepageUrl":57,"ownerHtmlUrl":58,"ownerBlogUrl":6,"ownerDescription":59,"updatedAt":60,"install":61,"resources":74},"01M6EJ769FJGYRYAVSAXAH5Z36","debugging",null,"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.","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002F89jobrien\u002Fdebugging\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[5,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41],"detection","error","pattern","general","log","log analysis","use","system","stack","analysis","test","Production","analyzing","debugging workflows","logs","issues","pattern detection","workflows","2026-11-10 10:12:30",false,"---\nname: debugging\ndescription: Comprehensive debugging specialist for errors, test failures, log analysis,\n  and system problems. Use when encountering issues, analyzing error logs, investigating\n  system anomalies, debugging production issues, analyzing stack traces, or identifying\n  root causes. Combines general debugging workflows with error pattern detection and\n  log analysis.\nauthor: Joseph OBrien\nstatus: unpublished\nupdated: '2025-12-23'\nversion: 1.0.1\ntag: skill\ntype: skill\n---\n\n# Debugging\n\nThis 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.\n\n## When to Use This Skill\n\n- When encountering errors or exceptions in code\n- When tests are failing and you need to understand why\n- When investigating unexpected behavior or bugs\n- When analyzing stack traces and error messages\n- When debugging production issues\n- When fixing issues reported by users or QA\n- When analyzing error logs and stack traces\n- When investigating performance issues or anomalies\n- When correlating errors across multiple services\n- When identifying recurring error patterns\n- When setting up error monitoring and alerting\n- When conducting post-mortem analysis of incidents\n\n## What This Skill Does\n\n1. **Error Analysis**: Captures and analyzes error messages and stack traces\n2. **Log Parsing**: Extracts errors from logs using regex patterns and structured parsing\n3. **Stack Trace Analysis**: Analyzes stack traces across multiple programming languages\n4. **Error Correlation**: Identifies relationships between errors across distributed systems\n5. **Pattern Recognition**: Detects common error patterns and anti-patterns\n6. **Reproduction**: Identifies steps to reproduce the issue\n7. **Isolation**: Locates the exact failure point in code\n8. **Root Cause Analysis**: Works backward from symptoms to identify underlying causes\n9. **Minimal Fix**: Implements the smallest change that resolves the issue\n10. **Verification**: Confirms the solution works and doesn't introduce new issues\n11. **Monitoring Setup**: Creates queries and alerts for error detection\n\n## Helper Scripts\n\nThis skill includes Python helper scripts in `scripts\u002F`:\n\n- **`parse_logs.py`**: Parses log files and extracts errors, exceptions, and stack traces. Outputs JSON with error analysis and pattern detection.\n\n  ```bash\n  python scripts\u002Fparse_logs.py \u002Fvar\u002Flog\u002Fapp.log\n  ```\n\n## How to Use\n\n### Debug an Error\n\n```\nDebug this error: TypeError: Cannot read property 'x' of undefined\n```\n\n```\nInvestigate why the test is failing in test_user_service.js\n```\n\n### Analyze Error Logs\n\n```\nAnalyze the error logs in \u002Fvar\u002Flog\u002Fapp.log and identify the root cause\n```\n\n```\nInvestigate why the API is returning 500 errors\n```\n\n### Pattern Detection\n\n```\nFind patterns in these error logs from the past 24 hours\n```\n\n```\nCorrelate errors between the API service and database\n```\n\n## Debugging Process\n\n### 1. Capture Error Information\n\n**Error Message:**\n\n- Read the full error message\n- Note the error type (TypeError, ReferenceError, etc.)\n- Identify the error location (file and line number)\n\n**Stack Trace:**\n\n- Analyze the call stack\n- Identify the sequence of function calls\n- Find where the error originated\n\n**Context:**\n\n- Check recent code changes\n- Review related code files\n- Understand the execution flow\n\n### 2. Error Extraction (Log Analysis)\n\n**Using Helper Script:**\n\nThe skill includes a Python helper script for parsing logs:\n\n```bash\n# Parse log file and extract errors\npython scripts\u002Fparse_logs.py \u002Fvar\u002Flog\u002Fapp.log\n```\n\n**Manual Log Parsing Patterns:**\n\n```bash\n# Extract errors from logs\ngrep -i \"error\\|exception\\|fatal\\|critical\" \u002Fvar\u002Flog\u002Fapp.log\n\n# Extract stack traces\ngrep -A 20 \"Exception\\|Error\\|Traceback\" \u002Fvar\u002Flog\u002Fapp.log\n\n# Extract specific error types\ngrep \"TypeError\\|ReferenceError\\|SyntaxError\" \u002Fvar\u002Flog\u002Fapp.log\n```\n\n**Structured Log Parsing:**\n\n```javascript\n\u002F\u002F Parse JSON logs\nconst errors = logs\n  .filter(log => log.level === 'error' || log.level === 'critical')\n  .map(log => ({\n    timestamp: log.timestamp,\n    message: log.message,\n    stack: log.stack,\n    context: log.context\n  }));\n```\n\n### 3. Stack Trace Analysis\n\n**Common Patterns:**\n\n**JavaScript\u002FNode.js:**\n\n```\nError: Cannot read property 'x' of undefined\n    at FunctionName (file.js:123:45)\n    at AnotherFunction (file.js:456:78)\n```\n\n**Python:**\n\n```\nTraceback (most recent call last):\n  File \"app.py\", line 123, in function_name\n    result = process(data)\n  File \"utils.py\", line 45, in process\n    return data['key']\nKeyError: 'key'\n```\n\n**Java:**\n\n```\njava.lang.NullPointerException\n    at com.example.Class.method(Class.java:123)\n    at com.example.AnotherClass.call(AnotherClass.java:456)\n```\n\n### 4. Error Correlation\n\n**Timeline Analysis:**\n\n- Group errors by timestamp\n- Identify error spikes and patterns\n- Correlate with deployments or changes\n- Check for cascading failures\n\n**Service Correlation:**\n\n- Map errors across service boundaries\n- Identify upstream\u002Fdownstream relationships\n- Track error propagation paths\n- Find common failure points\n\n### 5. Pattern Recognition\n\n**Common Error Patterns:**\n\n**N+1 Query Problem:**\n\n```\nMultiple database queries in loop\nPattern: SELECT * FROM users; SELECT * FROM posts WHERE user_id = ?\n```\n\n**Memory Leaks:**\n\n```\nGradually increasing memory usage\nPattern: Memory growth over time without release\n```\n\n**Race Conditions:**\n\n```\nIntermittent failures under load\nPattern: Errors only occur with concurrent requests\n```\n\n**Timeout Issues:**\n\n```\nRequests timing out\nPattern: Errors after specific duration (e.g., 30s)\n```\n\n### 6. Reproduce the Issue\n\n**Reproduction Steps:**\n\n1. Identify the exact conditions that trigger the error\n2. Create a minimal test case that reproduces the issue\n3. Verify the issue is consistent and reproducible\n4. Document the steps clearly\n\n**Example:**\n\n```markdown\n## Reproduction Steps\n\n1. Navigate to `\u002Fusers\u002F123`\n2. Click \"Edit Profile\"\n3. Submit form without filling required fields\n4. Error occurs: \"Cannot read property 'validate' of undefined\"\n```\n\n### 7. Isolate the Failure Location\n\n**Code Analysis:**\n\n- Read the code around the error location\n- Trace the execution path\n- Identify where the assumption breaks\n- Check variable states and values\n\n**Debugging Techniques:**\n\n- Add strategic logging to track execution\n- Use debugger breakpoints\n- Inspect variable states\n- Check function return values\n- Verify data structures\n\n### 8. Form and Test Hypotheses\n\n**Hypothesis Formation:**\n\n- What could cause this error?\n- What assumptions might be wrong?\n- What edge cases weren't considered?\n- What dependencies might be missing?\n\n**Testing Hypotheses:**\n\n- Add logging to verify assumptions\n- Test edge cases\n- Check input validation\n- Verify dependencies are available\n- Test with different data\n\n### 9. Root Cause Analysis\n\n**Investigation Steps:**\n\n1. **Start with Symptoms**: What error is occurring?\n2. **Work Backward**: What changed before the error?\n3. **Check Patterns**: Is this recurring or isolated?\n4. **Correlate Events**: What else happened at the same time?\n5. **Identify Cause**: What is the underlying issue?\n\n**Analysis Framework:**\n\n```markdown\n## Error Analysis\n\n**Error**: [Description]\n**Frequency**: [How often]\n**Timeline**: [When it started]\n**Affected Services**: [Which services]\n**User Impact**: [How many users affected]\n\n**Root Cause Hypothesis**:\n- [Primary hypothesis with evidence]\n- [Alternative hypotheses]\n\n**Evidence**:\n- [Log entries supporting hypothesis]\n- [Error patterns observed]\n- [Correlation with other events]\n\n**Recommended Actions**:\n- [Immediate fix]\n- [Long-term prevention]\n```\n\n### 10. Implement Minimal Fix\n\n**Fix Principles:**\n\n- Fix the root cause, not just symptoms\n- Make the smallest change possible\n- Preserve existing functionality\n- Don't introduce new complexity\n- Add appropriate error handling\n\n**Fix Verification:**\n\n- Test the fix with the reproduction case\n- Verify no regressions\n- Check edge cases\n- Ensure error handling is appropriate\n- Confirm the fix is complete\n\n### 11. Document the Solution\n\n**Documentation Should Include:**\n\n- Root cause explanation\n- Evidence supporting the diagnosis\n- Specific code fix\n- Testing approach\n- Prevention recommendations\n\n## Examples\n\n### Example 1: Null Reference Error\n\n**Input**: Error: `TypeError: Cannot read property 'name' of undefined`\n\n**Output**:\n\n```markdown\n## Debugging Analysis\n\n### Error Information\n- **Type**: TypeError\n- **Location**: `src\u002Fservices\u002Fuser.js:45`\n- **Message**: Cannot read property 'name' of undefined\n\n### Root Cause\nThe `getUser()` function returns `undefined` when a user is not found, but the code assumes it always returns a user object.\n\n### Code Location\n```javascript\n\u002F\u002F src\u002Fservices\u002Fuser.js:45\nconst user = getUser(userId);\nconsole.log(user.name); \u002F\u002F ❌ Error: user is undefined\n```\n\n### Fix\n\n```javascript\n\u002F\u002F Add null check\nconst user = getUser(userId);\nif (!user) {\n  throw new Error(`User ${userId} not found`);\n}\nconsole.log(user.name); \u002F\u002F ✅ Safe\n```\n\n### Prevention\n\n- Always validate return values from functions that might return null\u002Fundefined\n- Use optional chaining: `user?.name`\n- Add TypeScript types to catch these issues at compile time\n\n```\n\n### Example 2: Database Connection Errors (Log Analysis)\n\n**Input**: Error logs showing database connection failures\n\n**Output**:\n\n```markdown\n## Error Analysis: Database Connection Failures\n\n### Pattern Detected\n\n**Error**: `ECONNREFUSED` errors from PostgreSQL\n**Frequency**: 15 errors\u002Fminute, started 2 hours ago\n**Timeline**: Errors began after deployment at 14:30\n\n### Root Cause Analysis\n\n**Hypothesis**: Connection pool exhaustion\n\n**Evidence**:\n- Errors correlate with high traffic period (14:30-16:30)\n- Connection pool size: 10, concurrent requests: 50+\n- No connection cleanup in error handlers\n- Errors spike during peak usage\n\n**Code Location**: `src\u002Fdb\u002Fconnection.js:45`\n\n**Fix**:\n```javascript\n\u002F\u002F Add connection cleanup\ntry {\n  const result = await query(sql);\n  return result;\n} catch (error) {\n  \u002F\u002F Ensure connection is released\n  await releaseConnection();\n  throw error;\n}\n```\n\n**Monitoring Query**:\n\n```sql\nSELECT count(*) FROM pg_stat_activity WHERE state = 'active';\n```\n\n```\n\n## Reference Files\n\nFor detailed debugging workflows, error patterns, and techniques, load reference files as needed:\n\n- **`references\u002Fdebugging_workflows.md`** - Common debugging workflows by issue type, language-specific debugging, debugging techniques, debugging checklists, and common error patterns (database errors, memory leaks, race conditions, timeouts, authentication errors, network errors, application errors, performance errors)\n- **`references\u002FINCIDENT_POSTMORTEM.template.md`** - Incident postmortem template with timeline, root cause analysis, and action items\n\nWhen debugging specific types of issues or analyzing error patterns, load `references\u002Fdebugging_workflows.md` and refer to the relevant section.\n\n## Best Practices\n\n### Debugging Approach\n\n1. **Start with Symptoms**: Understand what's wrong before jumping to solutions\n2. **Work Backward**: Trace from error to cause\n3. **Test Hypotheses**: Don't assume, verify\n4. **Minimal Changes**: Fix only what's necessary\n5. **Verify Fixes**: Always test that the fix works\n\n### Log Analysis Techniques\n\n1. **Use Structured Logging**: JSON logs are easier to parse and analyze\n2. **Include Context**: Add request IDs, user IDs, timestamps to all logs\n3. **Log Levels**: Use appropriate levels (error, warn, info, debug)\n4. **Correlation IDs**: Use request IDs to trace errors across services\n5. **Error Grouping**: Group similar errors to identify patterns\n\n### Error Pattern Recognition\n\n**Time-Based Patterns:**\n- Errors at specific times (deployment windows, peak hours)\n- Errors after specific duration (timeouts, memory leaks)\n- Errors during specific events (database migrations, cache clears)\n\n**Frequency Patterns:**\n- Sudden spikes (deployment issues, traffic spikes)\n- Gradual increases (memory leaks, resource exhaustion)\n- Intermittent (race conditions, timing issues)\n\n**Correlation Patterns:**\n- Errors in multiple services simultaneously (infrastructure issues)\n- Errors after specific user actions (application bugs)\n- Errors correlated with external services (dependency issues)\n\n### Common Debugging Patterns\n\n**Null\u002FUndefined Checks:**\n```javascript\n\u002F\u002F Always check for null\u002Fundefined\nif (!value) {\n  \u002F\u002F Handle missing value\n}\n```\n\n**Error Handling:**\n\n```javascript\ntry {\n  \u002F\u002F Risky operation\n} catch (error) {\n  \u002F\u002F Log error with context\n  console.error('Operation failed:', error);\n  \u002F\u002F Handle gracefully\n}\n```\n\n**Logging:**\n\n```javascript\n\u002F\u002F Strategic logging\nconsole.log('Before operation:', { userId, data });\nconst result = await operation();\nconsole.log('After operation:', { result });\n```\n\n**Type Checking:**\n\n```javascript\n\u002F\u002F Verify types\nif (typeof value !== 'string') {\n  throw new TypeError('Expected string');\n}\n```\n\n### Monitoring Setup\n\n**Error Rate Monitoring:**\n\n```javascript\n\u002F\u002F Track error rate over time\nconst errorRate = errors.length \u002F totalRequests;\nif (errorRate > 0.01) { \u002F\u002F 1% error rate threshold\n  alert('High error rate detected');\n}\n```\n\n**Error Alerting:**\n\n- Alert on error rate spikes (> 5% increase)\n- Alert on new error types\n- Alert on critical error patterns\n- Alert on error correlation across services\n\n### Prevention Strategies\n\n1. **Input Validation**: Validate all inputs at boundaries\n2. **Type Safety**: Use TypeScript or type checking\n3. **Error Boundaries**: Catch errors at appropriate levels\n4. **Testing**: Write tests for edge cases\n5. **Code Review**: Review code for common pitfalls\n\n## Related Use Cases\n\n- Fixing production bugs\n- Debugging test failures\n- Investigating user-reported issues\n- Analyzing error logs\n- Root cause analysis\n- Performance debugging\n- Production incident investigation\n- System reliability analysis\n- Error monitoring setup\n- Post-mortem analysis\n- Debugging distributed systems\n","# Debugging\n\nThis 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.\n\n## When to Use This Skill\n\n- When encountering errors or exceptions in code\n- When tests are failing and you need to understand why\n- When investigating unexpected behavior or bugs\n- When analyzing stack traces and error messages\n- When debugging production issues\n- When fixing issues reported by users or QA\n- When analyzing error logs and stack traces\n- When investigating performance issues or anomalies\n- When correlating errors across multiple services\n- When identifying recurring error patterns\n- When setting up error monitoring and alerting\n- When conducting post-mortem analysis of incidents\n\n## What This Skill Does\n\n1. **Error Analysis**: Captures and analyzes error messages and stack traces\n2. **Log Parsing**: Extracts errors from logs using regex patterns and structured parsing\n3. **Stack Trace Analysis**: Analyzes stack traces across multiple programming languages\n4. **Error Correlation**: Identifies relationships between errors across distributed systems\n5. **Pattern Recognition**: Detects common error patterns and anti-patterns\n6. **Reproduction**: Identifies steps to reproduce the issue\n7. **Isolation**: Locates the exact failure point in code\n8. **Root Cause Analysis**: Works backward from symptoms to identify underlying causes\n9. **Minimal Fix**: Implements the smallest change that resolves the issue\n10. **Verification**: Confirms the solution works and doesn't introduce new issues\n11. **Monitoring Setup**: Creates queries and alerts for error detection\n\n## Helper Scripts\n\nThis skill includes Python helper scripts in `scripts\u002F`:\n\n- **`parse_logs.py`**: Parses log files and extracts errors, exceptions, and stack traces. Outputs JSON with error analysis and pattern detection.\n\n  ```bash\n  python scripts\u002Fparse_logs.py \u002Fvar\u002Flog\u002Fapp.log\n  ```\n\n## How to Use\n\n### Debug an Error\n\n```\nDebug this error: TypeError: Cannot read property 'x' of undefined\n```\n\n```\nInvestigate why the test is failing in test_user_service.js\n```\n\n### Analyze Error Logs\n\n```\nAnalyze the error logs in \u002Fvar\u002Flog\u002Fapp.log and identify the root cause\n```\n\n```\nInvestigate why the API is returning 500 errors\n```\n\n### Pattern Detection\n\n```\nFind patterns in these error logs from the past 24 hours\n```\n\n```\nCorrelate errors between the API service and database\n```\n\n## Debugging Process\n\n### 1. Capture Error Information\n\n**Error Message:**\n\n- Read the full error message\n- Note the error type (TypeError, ReferenceError, etc.)\n- Identify the error location (file and line number)\n\n**Stack Trace:**\n\n- Analyze the call stack\n- Identify the sequence of function calls\n- Find where the error originated\n\n**Context:**\n\n- Check recent code changes\n- Review related code files\n- Understand the execution flow\n\n### 2. Error Extraction (Log Analysis)\n\n**Using Helper Script:**\n\nThe skill includes a Python helper script for parsing logs:\n\n```bash\n# Parse log file and extract errors\npython scripts\u002Fparse_logs.py \u002Fvar\u002Flog\u002Fapp.log\n```\n\n**Manual Log Parsing Patterns:**\n\n```bash\n# Extract errors from logs\ngrep -i \"error\\|exception\\|fatal\\|critical\" \u002Fvar\u002Flog\u002Fapp.log\n\n# Extract stack traces\ngrep -A 20 \"Exception\\|Error\\|Traceback\" \u002Fvar\u002Flog\u002Fapp.log\n\n# Extract specific error types\ngrep \"TypeError\\|ReferenceError\\|SyntaxError\" \u002Fvar\u002Flog\u002Fapp.log\n```\n\n**Structured Log Parsing:**\n\n```javascript\n\u002F\u002F Parse JSON logs\nconst errors = logs\n  .filter(log => log.level === 'error' || log.level === 'critical')\n  .map(log => ({\n    timestamp: log.timestamp,\n    message: log.message,\n    stack: log.stack,\n    context: log.context\n  }));\n```\n\n### 3. Stack Trace Analysis\n\n**Common Patterns:**\n\n**JavaScript\u002FNode.js:**\n\n```\nError: Cannot read property 'x' of undefined\n    at FunctionName (file.js:123:45)\n    at AnotherFunction (file.js:456:78)\n```\n\n**Python:**\n\n```\nTraceback (most recent call last):\n  File \"app.py\", line 123, in function_name\n    result = process(data)\n  File \"utils.py\", line 45, in process\n    return data['key']\nKeyError: 'key'\n```\n\n**Java:**\n\n```\njava.lang.NullPointerException\n    at com.example.Class.method(Class.java:123)\n    at com.example.AnotherClass.call(AnotherClass.java:456)\n```\n\n### 4. Error Correlation\n\n**Timeline Analysis:**\n\n- Group errors by timestamp\n- Identify error spikes and patterns\n- Correlate with deployments or changes\n- Check for cascading failures\n\n**Service Correlation:**\n\n- Map errors across service boundaries\n- Identify upstream\u002Fdownstream relationships\n- Track error propagation paths\n- Find common failure points\n\n### 5. Pattern Recognition\n\n**Common Error Patterns:**\n\n**N+1 Query Problem:**\n\n```\nMultiple database queries in loop\nPattern: SELECT * FROM users; SELECT * FROM posts WHERE user_id = ?\n```\n\n**Memory Leaks:**\n\n```\nGradually increasing memory usage\nPattern: Memory growth over time without release\n```\n\n**Race Conditions:**\n\n```\nIntermittent failures under load\nPattern: Errors only occur with concurrent requests\n```\n\n**Timeout Issues:**\n\n```\nRequests timing out\nPattern: Errors after specific duration (e.g., 30s)\n```\n\n### 6. Reproduce the Issue\n\n**Reproduction Steps:**\n\n1. Identify the exact conditions that trigger the error\n2. Create a minimal test case that reproduces the issue\n3. Verify the issue is consistent and reproducible\n4. Document the steps clearly\n\n**Example:**\n\n```markdown\n## Reproduction Steps\n\n1. Navigate to `\u002Fusers\u002F123`\n2. Click \"Edit Profile\"\n3. Submit form without filling required fields\n4. Error occurs: \"Cannot read property 'validate' of undefined\"\n```\n\n### 7. Isolate the Failure Location\n\n**Code Analysis:**\n\n- Read the code around the error location\n- Trace the execution path\n- Identify where the assumption breaks\n- Check variable states and values\n\n**Debugging Techniques:**\n\n- Add strategic logging to track execution\n- Use debugger breakpoints\n- Inspect variable states\n- Check function return values\n- Verify data structures\n\n### 8. Form and Test Hypotheses\n\n**Hypothesis Formation:**\n\n- What could cause this error?\n- What assumptions might be wrong?\n- What edge cases weren't considered?\n- What dependencies might be missing?\n\n**Testing Hypotheses:**\n\n- Add logging to verify assumptions\n- Test edge cases\n- Check input validation\n- Verify dependencies are available\n- Test with different data\n\n### 9. Root Cause Analysis\n\n**Investigation Steps:**\n\n1. **Start with Symptoms**: What error is occurring?\n2. **Work Backward**: What changed before the error?\n3. **Check Patterns**: Is this recurring or isolated?\n4. **Correlate Events**: What else happened at the same time?\n5. **Identify Cause**: What is the underlying issue?\n\n**Analysis Framework:**\n\n```markdown\n## Error Analysis\n\n**Error**: [Description]\n**Frequency**: [How often]\n**Timeline**: [When it started]\n**Affected Services**: [Which services]\n**User Impact**: [How many users affected]\n\n**Root Cause Hypothesis**:\n- [Primary hypothesis with evidence]\n- [Alternative hypotheses]\n\n**Evidence**:\n- [Log entries supporting hypothesis]\n- [Error patterns observed]\n- [Correlation with other events]\n\n**Recommended Actions**:\n- [Immediate fix]\n- [Long-term prevention]\n```\n\n### 10. Implement Minimal Fix\n\n**Fix Principles:**\n\n- Fix the root cause, not just symptoms\n- Make the smallest change possible\n- Preserve existing functionality\n- Don't introduce new complexity\n- Add appropriate error handling\n\n**Fix Verification:**\n\n- Test the fix with the reproduction case\n- Verify no regressions\n- Check edge cases\n- Ensure error handling is appropriate\n- Confirm the fix is complete\n\n### 11. Document the Solution\n\n**Documentation Should Include:**\n\n- Root cause explanation\n- Evidence supporting the diagnosis\n- Specific code fix\n- Testing approach\n- Prevention recommendations\n\n## Examples\n\n### Example 1: Null Reference Error\n\n**Input**: Error: `TypeError: Cannot read property 'name' of undefined`\n\n**Output**:\n\n```markdown\n## Debugging Analysis\n\n### Error Information\n- **Type**: TypeError\n- **Location**: `src\u002Fservices\u002Fuser.js:45`\n- **Message**: Cannot read property 'name' of undefined\n\n### Root Cause\nThe `getUser()` function returns `undefined` when a user is not found, but the code assumes it always returns a user object.\n\n### Code Location\n```javascript\n\u002F\u002F src\u002Fservices\u002Fuser.js:45\nconst user = getUser(userId);\nconsole.log(user.name); \u002F\u002F ❌ Error: user is undefined\n```\n\n### Fix\n\n```javascript\n\u002F\u002F Add null check\nconst user = getUser(userId);\nif (!user) {\n  throw new Error(`User ${userId} not found`);\n}\nconsole.log(user.name); \u002F\u002F ✅ Safe\n```\n\n### Prevention\n\n- Always validate return values from functions that might return null\u002Fundefined\n- Use optional chaining: `user?.name`\n- Add TypeScript types to catch these issues at compile time\n\n```\n\n### Example 2: Database Connection Errors (Log Analysis)\n\n**Input**: Error logs showing database connection failures\n\n**Output**:\n\n```markdown\n## Error Analysis: Database Connection Failures\n\n### Pattern Detected\n\n**Error**: `ECONNREFUSED` errors from PostgreSQL\n**Frequency**: 15 errors\u002Fminute, started 2 hours ago\n**Timeline**: Errors began after deployment at 14:30\n\n### Root Cause Analysis\n\n**Hypothesis**: Connection pool exhaustion\n\n**Evidence**:\n- Errors correlate with high traffic period (14:30-16:30)\n- Connection pool size: 10, concurrent requests: 50+\n- No connection cleanup in error handlers\n- Errors spike during peak usage\n\n**Code Location**: `src\u002Fdb\u002Fconnection.js:45`\n\n**Fix**:\n```javascript\n\u002F\u002F Add connection cleanup\ntry {\n  const result = await query(sql);\n  return result;\n} catch (error) {\n  \u002F\u002F Ensure connection is released\n  await releaseConnection();\n  throw error;\n}\n```\n\n**Monitoring Query**:\n\n```sql\nSELECT count(*) FROM pg_stat_activity WHERE state = 'active';\n```\n\n```\n\n## Reference Files\n\nFor detailed debugging workflows, error patterns, and techniques, load reference files as needed:\n\n- **`references\u002Fdebugging_workflows.md`** - Common debugging workflows by issue type, language-specific debugging, debugging techniques, debugging checklists, and common error patterns (database errors, memory leaks, race conditions, timeouts, authentication errors, network errors, application errors, performance errors)\n- **`references\u002FINCIDENT_POSTMORTEM.template.md`** - Incident postmortem template with timeline, root cause analysis, and action items\n\nWhen debugging specific types of issues or analyzing error patterns, load `references\u002Fdebugging_workflows.md` and refer to the relevant section.\n\n## Best Practices\n\n### Debugging Approach\n\n1. **Start with Symptoms**: Understand what's wrong before jumping to solutions\n2. **Work Backward**: Trace from error to cause\n3. **Test Hypotheses**: Don't assume, verify\n4. **Minimal Changes**: Fix only what's necessary\n5. **Verify Fixes**: Always test that the fix works\n\n### Log Analysis Techniques\n\n1. **Use Structured Logging**: JSON logs are easier to parse and analyze\n2. **Include Context**: Add request IDs, user IDs, timestamps to all logs\n3. **Log Levels**: Use appropriate levels (error, warn, info, debug)\n4. **Correlation IDs**: Use request IDs to trace errors across services\n5. **Error Grouping**: Group similar errors to identify patterns\n\n### Error Pattern Recognition\n\n**Time-Based Patterns:**\n- Errors at specific times (deployment windows, peak hours)\n- Errors after specific duration (timeouts, memory leaks)\n- Errors during specific events (database migrations, cache clears)\n\n**Frequency Patterns:**\n- Sudden spikes (deployment issues, traffic spikes)\n- Gradual increases (memory leaks, resource exhaustion)\n- Intermittent (race conditions, timing issues)\n\n**Correlation Patterns:**\n- Errors in multiple services simultaneously (infrastructure issues)\n- Errors after specific user actions (application bugs)\n- Errors correlated with external services (dependency issues)\n\n### Common Debugging Patterns\n\n**Null\u002FUndefined Checks:**\n```javascript\n\u002F\u002F Always check for null\u002Fundefined\nif (!value) {\n  \u002F\u002F Handle missing value\n}\n```\n\n**Error Handling:**\n\n```javascript\ntry {\n  \u002F\u002F Risky operation\n} catch (error) {\n  \u002F\u002F Log error with context\n  console.error('Operation failed:', error);\n  \u002F\u002F Handle gracefully\n}\n```\n\n**Logging:**\n\n```javascript\n\u002F\u002F Strategic logging\nconsole.log('Before operation:', { userId, data });\nconst result = await operation();\nconsole.log('After operation:', { result });\n```\n\n**Type Checking:**\n\n```javascript\n\u002F\u002F Verify types\nif (typeof value !== 'string') {\n  throw new TypeError('Expected string');\n}\n```\n\n### Monitoring Setup\n\n**Error Rate Monitoring:**\n\n```javascript\n\u002F\u002F Track error rate over time\nconst errorRate = errors.length \u002F totalRequests;\nif (errorRate > 0.01) { \u002F\u002F 1% error rate threshold\n  alert('High error rate detected');\n}\n```\n\n**Error Alerting:**\n\n- Alert on error rate spikes (> 5% increase)\n- Alert on new error types\n- Alert on critical error patterns\n- Alert on error correlation across services\n\n### Prevention Strategies\n\n1. **Input Validation**: Validate all inputs at boundaries\n2. **Type Safety**: Use TypeScript or type checking\n3. **Error Boundaries**: Catch errors at appropriate levels\n4. **Testing**: Write tests for edge cases\n5. **Code Review**: Review code for common pitfalls\n\n## Related Use Cases\n\n- Fixing production bugs\n- Debugging test failures\n- Investigating user-reported issues\n- Analyzing error logs\n- Root cause analysis\n- Performance debugging\n- Production incident investigation\n- System reliability analysis\n- Error monitoring setup\n- Post-mortem analysis\n- Debugging distributed systems\n",{"tag":47,"name":5,"type":47,"author":48,"status":49,"updated":50,"version":51,"description":7},"skill","Joseph OBrien","unpublished","2025-12-23","1.0.1","main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Faiskillstore\u002Fmarketplace\u002F89jobrien\u002Fdebugging",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":8,"skillName":5,"commands":62,"prompt":72,"zipAvailable":73},[63,66,69],{"tool":64,"command":65},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill debugging",{"tool":67,"command":68},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill debugging",{"tool":70,"command":71},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill debugging","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002F89jobrien\u002Fdebugging\u002FSKILL.md",true,[75,81,87,91,95,99,103,107,111,115],{"path":76,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":79,"sourceHtmlUrl":80},"codex\u002Fprompt.md","REFERENCE","参考文档",11800,"https:\u002F\u002Fgithub.com\u002Fberlinguyinca\u002Fautospec\u002Fblob\u002Fmain\u002Fskills\u002Fautospec-compose-normalize\u002Fcodex\u002Fprompt.md",{"path":82,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":85,"sourceHtmlUrl":86},"install.sh","SCRIPT","脚本",8101,"https:\u002F\u002Fgithub.com\u002Fberlinguyinca\u002Fautospec\u002Fblob\u002Fmain\u002Fskills\u002Fautospec-compose-normalize\u002Finstall.sh",{"path":88,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":89,"sourceHtmlUrl":90},"opencode\u002Fagent.md",11962,"https:\u002F\u002Fgithub.com\u002Fberlinguyinca\u002Fautospec\u002Fblob\u002Fmain\u002Fskills\u002Fautospec-compose-normalize\u002Fopencode\u002Fagent.md",{"path":92,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":93,"sourceHtmlUrl":94},"README.md",374,"https:\u002F\u002Fgithub.com\u002Fberlinguyinca\u002Fautospec\u002Fblob\u002Fmain\u002Fskills\u002Fautospec-compose-normalize\u002FREADME.md",{"path":96,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":97,"sourceHtmlUrl":98},"references\u002Fdebugging-workflows.md",10481,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002F89jobrien\u002Fdebugging\u002Freferences\u002Fdebugging-workflows.md",{"path":100,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":101,"sourceHtmlUrl":102},"references\u002Fincident-postmortem.template.md",3539,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002F89jobrien\u002Fdebugging\u002Freferences\u002Fincident-postmortem.template.md",{"path":104,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":105,"sourceHtmlUrl":106},"scripts\u002Fparse-logs.py",3640,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002F89jobrien\u002Fdebugging\u002Fscripts\u002Fparse-logs.py",{"path":108,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":109,"sourceHtmlUrl":110},"scripts\u002Fworkflow-guard.sh",6111,"https:\u002F\u002Fgithub.com\u002Fberlinguyinca\u002Fautospec\u002Fblob\u002Fmain\u002Fskills\u002Fautospec-compose-normalize\u002Fscripts\u002Fworkflow-guard.sh",{"path":112,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":113,"sourceHtmlUrl":114},"skill-report.json",8960,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002F89jobrien\u002Fdebugging\u002Fskill-report.json",{"path":116,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":117,"sourceHtmlUrl":118},"uninstall.sh",2109,"https:\u002F\u002Fgithub.com\u002Fberlinguyinca\u002Fautospec\u002Fblob\u002Fmain\u002Fskills\u002Fautospec-compose-normalize\u002Funinstall.sh",[120,130,140,149,155,162],{"skillNo":121,"name":122,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":126,"publishedAt":42},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[125],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[127,128,129],"model","model hierarchy","model hierarchy skill",{"skillNo":131,"name":132,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":133,"categories":134,"keywords":136,"publishedAt":42},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[135],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[137,138,139],"MCP","zoom","zoom mcp",{"skillNo":141,"name":142,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":143,"categories":144,"keywords":145,"publishedAt":42},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[146,147,148,138],"sdk","zoom apps sdk","apps",{"skillNo":150,"name":151,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":152,"categories":153,"keywords":154,"publishedAt":42},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[151],{"skillNo":156,"name":157,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":158,"categories":159,"keywords":161,"publishedAt":42},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[160],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[157],{"skillNo":163,"name":164,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":165,"categories":166,"keywords":167,"publishedAt":42},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[164]]