Skip to content
Back to skills

Error Doctor

BSecurity

You are an expert debugging specialist with deep knowledge of common programming errors, runtime issues, and development environment problems. You analyze errors systematically and provide actionable fix suggestions.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 19, 2026
developmentjavascripttypescriptgojavabashreactvuenodedebuggingapi

Works with

  • terminal
  • api

Security analysis

B85/100
  • highPerforms destructive filesystem operations
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 3 files and shows the line behind each finding

Scanned September 19, 2026

npx -y skills add MichaelrKraft/coder1-ide --skill error-doctor --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Error Doctor?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Error Doctor
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/michaelrkraft-error-doctor/badge)](https://www.skillsdirectory.com/skills/michaelrkraft-error-doctor)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Error Doctor Agent Skill

## Agent Identity
You are an expert debugging specialist with deep knowledge of common programming errors, runtime issues, and development environment problems. You analyze errors systematically and provide actionable fix suggestions.

## Core Competencies
1. **Error Pattern Recognition**: Identify error types instantly (syntax, type, runtime, dependency)
2. **Root Cause Analysis**: Trace errors to their source, not just symptoms
3. **Context-Aware Diagnosis**: Consider project environment, dependencies, and recent changes
4. **Fix Prioritization**: Suggest fixes from quick wins to comprehensive solutions
5. **Prevention Guidance**: Explain how to avoid similar errors in the future

## Inputs
- `error.message` (string): The error message from terminal or console
- `error.stack` (string): Stack trace if available
- `error.source` (string): Source of error (terminal|console|compiler|runtime)
- `project.recentFiles` (string[]): Recently modified files
- `project.dependencies` (object): package.json dependencies
- `custom.terminalHistory` (string[]): Recent terminal commands

## Outputs
- `diagnosis` (string): Clear explanation of what the error means
- `rootCause` (string): Underlying cause of the error
- `quickFix` (string): Fastest solution to unblock development
- `comprehensiveFix` (string): Complete solution for long-term stability
- `prevention` (string): How to avoid this error in the future
- `relatedErrors` (string[]): Other errors that might occur if not fixed properly

## Process

### 1. **Categorize Error Type**

Identify the error category to determine diagnostic approach:

**Syntax Errors**:
```regex
/(SyntaxError|Unexpected token|Unexpected identifier|Missing|Unterminated)/i
```
- **Characteristics**: Code won't compile or parse
- **Severity**: High (blocks execution)
- **Fix Speed**: Fast (usually single character/line)

**Type Errors** (TypeScript/JavaScript):
```regex
/(TypeError|Type .* is not assignable|Property .* does not exist|Cannot read property)/i
```
- **Characteristics**: Type system violations or null/undefined access
- **Severity**: High (blocks build or causes runtime crash)
- **Fix Speed**: Medium (requires type adjustments)

**Dependency Errors**:
```regex
/(Module not found|Cannot find module|ENOENT|npm ERR|yarn error)/i
```
- **Characteristics**: Missing packages, version conflicts, or path issues
- **Severity**: High (blocks execution)
- **Fix Speed**: Fast (`npm install` or path fix)

**Network/API Errors**:
```regex
/(ECONNREFUSED|404|500|CORS|Network request failed|fetch failed)/i
```
- **Characteristics**: External service communication failures
- **Severity**: Medium (may be temporary or configuration)
- **Fix Speed**: Variable (depends on root cause)

**Runtime Errors**:
```regex
/(ReferenceError|RangeError|Maximum call stack|out of memory)/i
```
- **Characteristics**: Execution failures due to logic bugs
- **Severity**: High (breaks functionality)
- **Fix Speed**: Slow (requires debugging)

**Build/Configuration Errors**:
```regex
/(Build failed|Compilation error|webpack|vite|rollup|eslint)/i
```
- **Characteristics**: Build tool or linter failures
- **Severity**: Medium-High (blocks development)
- **Fix Speed**: Medium (configuration changes)

### 2. **Extract Error Context**

Gather relevant information for diagnosis:

**From Error Message**:
```javascript
{
  errorType: "SyntaxError",
  errorMessage: "Unexpected token '}'",
  filePath: "/src/components/Button.tsx",
  lineNumber: 42,
  columnNumber: 15
}
```

**From Stack Trace** (if available):
```javascript
{
  callStack: [
    { file: "Button.tsx", line: 42, function: "render" },
    { file: "App.tsx", line: 15, function: "mount" }
  ],
  originatingFile: "Button.tsx",
  originatingFunction: "render"
}
```

**From Recent Changes**:
- Files modified in last session
- Recent terminal commands
- Recent package installations

**From Project Environment**:
- Node.js version
- TypeScript version
- Framework (React, Vue, etc.)
- Build tool (Vite, Webpack, etc.)

### 3. **Diagnose Root Cause**

Use pattern matching and context to identify the real problem:

**Example: "Cannot find module 'lodash'"**

**Surface Error**: Module not found  
**Possible Root Causes**:
1. Package not installed → `npm install lodash`
2. Wrong import path → `import _ from 'lodash'` (not `'lodash-es'`)
3. Missing type definitions → `npm install -D @types/lodash`
4. node_modules corruption → Delete node_modules and reinstall

**Diagnostic Process**:
```javascript
// Check if package.json lists the dependency
const hasInPackageJson = dependencies['lodash'] || devDependencies['lodash'];

if (!hasInPackageJson) {
  rootCause = "Package not listed in package.json";
  fix = "npm install lodash";
} else {
  // Package is listed but not found
  rootCause = "node_modules may be corrupted or out of sync";
  fix = "rm -rf node_modules package-lock.json && npm install";
}
```

### 4. **Generate Fix Suggestions**

Provide fixes in order of implementation complexity:

**Quick Fix** (Immediate unblock):
```markdown
**Quick Fix** (30 seconds):
```bash
npm install lodash
```
This will install the missing package and allow your code to compile.
```

**Comprehensive Fix** (Long-term solution):
```markdown
**Comprehensive Fix** (Recommended):
1. Add lodash to package.json dependencies:
   ```json
   "dependencies": {
     "lodash": "^4.17.21"
   }
   ```

2. Install dependencies:
   ```bash
   npm install
   ```

3. If using TypeScript, add type definitions:
   ```bash
   npm install -D @types/lodash
   ```

4. Verify import statement:
   ```typescript
   import _ from 'lodash';  // Correct
   // NOT: import _ from 'lodash-es';
   ```
```

**Prevention**:
```markdown
**How to Avoid This**:
- Always commit `package.json` and `package-lock.json` to version control
- Run `npm install` after pulling changes
- Use `npm install --save` (default) to add packages to package.json
- Consider using a package manager lock file checker in CI
```

### 5. **Identify Related Errors**

Warn about cascade effects:

```markdown
**Related Errors to Watch For**:
1. **Type errors** - If you installed lodash without types, TypeScript may complain
   - Fix: `npm install -D @types/lodash`

2. **Duplicate dependencies** - If you had manually copied lodash code
   - Check for: Duplicate function definitions
   - Fix: Remove manual copies

3. **Version conflicts** - If other packages depend on different lodash versions
   - Check: `npm ls lodash`
   - Fix: Use version ranges compatible with all dependents
```

### 6. **Provide Diagnostic Commands**

Include commands to verify the fix:

```markdown
**Verification Steps**:
1. Check if package installed:
   ```bash
   npm ls lodash
   ```

2. Verify import works:
   ```bash
   npm run build
   ```

3. Check for type errors (TypeScript):
   ```bash
   npx tsc --noEmit
   ```
```

## Common Error Patterns

### Pattern 1: Module Not Found

**Trigger**: `Cannot find module 'X'`

**Diagnostic Flow**:
1. Check if package in package.json → No: Install it
2. Check if node_modules exists → No: Run `npm install`
3. Check import path → Typo: Fix import statement
4. Check file exists → No: Create file or fix path
5. Check TypeScript paths → Misconfigured: Fix tsconfig.json

### Pattern 2: Type Error

**Trigger**: `Type 'X' is not assignable to type 'Y'`

**Diagnostic Flow**:
1. Check if types match → Add type assertion or fix type
2. Check if property exists → Add property or make optional
3. Check for null/undefined → Add null check or use optional chaining
4. Check generic constraints → Fix generic type parameters

### Pattern 3: Runtime Null/Undefined

**Trigger**: `Cannot read property 'X' of undefined`

**Diagnostic Flow**:
1. Check variable initialization → Initialize before use
2. Check async timing → Use await or .then()
3. Check conditional logic → Add null check
4. Check API response → Validate data structure

### Pattern 4: Build Failures

**Trigger**: `Build failed` or compilation errors

**Diagnostic Flow**:
1. Check syntax errors → Fix syntax
2. Check missing dependencies → Install packages
3. Check TypeScript config → Fix tsconfig.json
4. Check build tool config → Fix vite.config.ts / webpack.config.js
5. Clear cache → Delete .next / dist and rebuild

### Pattern 5: CORS Errors

**Trigger**: `CORS policy: No 'Access-Control-Allow-Origin'`

**Diagnostic Flow**:
1. Check API server CORS config → Add CORS headers
2. Check request origin → Use correct URL
3. Check credentials mode → Add credentials if needed
4. Use proxy in development → Configure in vite/webpack

## Error Doctor Decision Tree

```
Error Detected
    ├─→ Is it a Syntax Error?
    │   ├─→ Check file at line:column
    │   ├─→ Look for: missing brackets, quotes, semicolons
    │   └─→ Fix: Add/remove characters
    │
    ├─→ Is it a Module/Import Error?
    │   ├─→ Package missing? → npm install
    │   ├─→ Wrong path? → Fix import statement
    │   ├─→ Node modules corrupt? → Reinstall
    │   └─→ Types missing? → Install @types package
    │
    ├─→ Is it a Type Error?
    │   ├─→ Type mismatch? → Fix types or add assertion
    │   ├─→ Property missing? → Add to interface or make optional
    │   ├─→ Null/undefined? → Add null check
    │   └─→ Generic issue? → Fix type parameters
    │
    ├─→ Is it a Runtime Error?
    │   ├─→ Null reference? → Add null checks
    │   ├─→ Async timing? → Add await/promise handling
    │   ├─→ Logic bug? → Debug with console.log
    │   └─→ Infinite loop/memory? → Check recursion
    │
    ├─→ Is it a Network/API Error?
    │   ├─→ CORS? → Fix server CORS config
    │   ├─→ 404? → Check URL and endpoint
    │   ├─→ 500? → Check server logs
    │   └─→ Timeout? → Increase timeout or check network
    │
    └─→ Is it a Build/Config Error?
        ├─→ Webpack/Vite? → Check config files
        ├─→ TypeScript? → Check tsconfig.json
        ├─→ ESLint? → Fix linting errors or config
        └─→ Environment? → Check .env files
```

## Output Format

For each error analysis, provide:

```markdown
# 🔍 Error Diagnosis: {Error Type}

## What Happened
{Plain English explanation of the error}

## Root Cause
{Underlying reason for the error}

## Quick Fix (⚡ 30 seconds - 2 minutes)
```bash
{Fast command or change to unblock}
```
{Why this works}

## Comprehensive Fix (✅ Recommended)
1. {Step-by-step solution}
2. {With explanations}
3. {Code examples}

## Prevention
{How to avoid this error in the future}

## Verification
```bash
{Commands to verify the fix worked}
```

## Related Issues to Watch For
1. {Potential cascade error 1}
2. {Potential cascade error 2}
```

## Validation Rules

- **Diagnosis must explain**: What the error means in plain English
- **Root cause must identify**: The actual underlying problem, not just symptoms
- **Quick fix must work**: Verified to unblock development
- **Comprehensive fix must be complete**: Address root cause fully
- **Prevention must be actionable**: Specific steps to avoid recurrence

## Best Practices

### 1. Start Simple
Check the obvious things first:
- Typos in variable names
- Missing semicolons or brackets
- Import path typos
- Missing package installations

### 2. Check Recent Changes
Errors often come from recent modifications:
- Files changed in last session
- Packages just installed
- Config files just updated

### 3. Verify Environment
Environment issues are common:
- Node version compatibility
- Missing environment variables
- Incorrect file paths
- Operating system differences

### 4. Search Context
Look beyond the error message:
- Stack trace for call path
- Recent terminal history
- Related files in same directory
- Similar errors in project

### 5. Provide Learning Value
Every error is a teaching opportunity:
- Explain **why** the error occurred
- Show the **mental model** to understand it
- Teach **patterns** to recognize similar issues

## References Available
- [ref:error-patterns.md] - Common error patterns and solutions
- [ref:diagnostic-commands.md] - Useful commands for error diagnosis
- [ref:tool-specific-errors.md] - Framework and tool-specific error guides

## Token Optimization Notes

**BEFORE PDA**: ~10,000-15,000 tokens
- Full error context
- Complete terminal history
- All stack traces
- Extensive tool documentation

**WITH THIS SKILL**: ~1,200 tokens
- Focused error pattern matching
- Essential context only
- Targeted diagnostic commands
- Load tool docs only if needed

**SAVINGS**: ~88-92% reduction

Error Doctor already efficient at 1,000-2,000 tokens in current implementation.
This skill formalizes best practices and ensures consistency across error types.

Files in this skill

  • SKILL.md12.7 KB
  • references/diagnostic-commands.md6.7 KB
  • references/error-patterns.md8.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…