| name | error-recovery |
| description | Expert knowledge in error diagnosis, debugging strategies, and self-healing patterns. Use when tasks fail or errors occur. |
| allowed-tools | Read, Write, Edit, Bash, Glob, Grep |
Error Recovery Skill
Comprehensive strategies for diagnosing, fixing, and preventing errors.
Error Classification
Compile-Time Errors
| Code | Type | Common Cause |
|---|
| TS2322 | Type mismatch | Wrong type assigned |
| TS2345 | Argument type | Wrong parameter type |
| TS2339 | Property missing | Typo or missing interface property |
| TS2304 | Not found | Missing import or declaration |
| TS2307 | Module not found | Wrong path or missing package |
| TS7006 | Implicit any | Missing type annotation |
| TS2531 | Possibly null | Missing null check |
Runtime Errors
| Error | Description | Common Fix |
|---|
| ReferenceError | Variable not defined | Check declaration, scope |
| TypeError | Wrong type operation | Add null check, fix type |
| RangeError | Value out of range | Validate input range |
| SyntaxError | Invalid syntax | Check JSON, string format |
Build Errors
| Error | Description | Fix |
|---|
| Module not found | Package missing | npm install |
| Out of memory | Heap limit | Increase NODE_OPTIONS |
| Config error | Invalid config | Check tsconfig, vite.config |
Test Failures
| Type | Cause | Fix |
|---|
| Assertion | Logic error | Fix implementation or expectation |
| Timeout | Async issue | Add await, increase timeout |
| Mock error | Wrong mock setup | Fix mock configuration |
Recovery Strategies
Strategy 1: Auto-Fix (Lint/Format)
npx eslint . --fix
npx prettier --write .
Strategy 2: Dependency Fix
rm -rf node_modules package-lock.json
npm install
npm update package-name
npm install --legacy-peer-deps
Strategy 3: Type Error Fix
const value: string = 123;
const value: number = 123;
element.innerHTML = 'text';
if (element) element.innerHTML = 'text';
user.email
if ('email' in user) user.email
Strategy 4: Runtime Error Fix
const name = user.profile.name;
const name = user?.profile?.name ?? 'Unknown';
Strategy 5: Test Failure Fix
console.log('Actual:', result);
console.log('Expected:', expected);
test('async test', async () => {
const result = await asyncOperation();
expect(result).toBeDefined();
}, 10000);
vi.mock('./module', () => ({
default: vi.fn().mockReturnValue('mocked'),
}));
Recovery Protocol
┌─────────────────────────────────────────┐
│ ERROR DETECTED │
└─────────────────┬───────────────────────┘
▼
┌─────────────────────────────────────────┐
│ 1. CLASSIFY ERROR │
│ Syntax | Type | Runtime | Build | Test │
└─────────────────┬───────────────────────┘
▼
┌─────────────────────────────────────────┐
│ 2. IDENTIFY FIX │
│ Auto-fix | Manual | Delegate │
└─────────────────┬───────────────────────┘
▼
┌─────────────────────────────────────────┐
│ 3. APPLY FIX │
│ Make minimal, targeted change │
└─────────────────┬───────────────────────┘
▼
┌─────────────────────────────────────────┐
│ 4. VERIFY FIX │
│ tsc && eslint && npm test │
└─────────────────┬───────────────────────┘
▼
┌─────────┴─────────┐
│ Fixed? │
└─────────┬─────────┘
Yes │ No
│ │ │
▼ │ ▼
┌─────┐ │ ┌─────────────────┐
│ Done│ │ │ Increment retry │
└─────┘ │ │ (max 3) │
│ └────────┬────────┘
│ ▼
│ ┌─────────────────┐
│ │ Retry < 3? │
│ └────────┬────────┘
│ Yes │ No
│ │ │ │
│ ▼ │ ▼
│ ┌──────┐ │ ┌────────┐
└───│Retry │ │ │Escalate│
└──────┘ │ └────────┘
Prevention Strategies
- TypeScript Strict Mode - Catch errors at compile time
- ESLint Rules - Enforce best practices
- Pre-commit Hooks - Validate before commit
- Unit Tests - Catch regressions
- Code Review - Human verification