---
name: problem-solver
source: botcore
description: >
  Diagnose and fix bugs using systematic investigation.
  Use when debugging build failures, test failures, runtime errors, or unexpected behavior.
version: "2.1.0"
triggers:
  - bug
  - error
  - debug
  - fix
  - diagnose
  - broken
  - failing
  - crash
---

# Problem Solver

Systematic approach to debugging and fixing issues.

## When to Use

- Build failures
- Test failures
- Runtime errors
- Unexpected behavior

## Workflow

1. **Gather info** — Read error message carefully
2. **Reproduce** — Confirm the issue exists
3. **Form hypothesis** — "If X then Y because Z"
4. **Test hypothesis** — Isolate and verify
5. **Fix** — Apply minimal change
6. **Verify** — Ensure fix works and no regressions

## Error Pattern Recognition

| Pattern | Likely Cause |
|---------|--------------|
| `undefined is not a function` | Missing import or null ref |
| `Module not found` | Typo in import path |
| `Type 'X' is not assignable` | TypeScript mismatch |
| `Network error` | API failure or CORS |
| `Hydration mismatch` | SSR/client mismatch |
| `Maximum call stack` | Infinite recursion |
| `Cannot read property of null` | Null reference |

## Debugging Strategy

```
Error Occurs
│
├─→ Read the full error message
│   └─→ Note: file, line, stack trace
│
├─→ Reproduce consistently
│   └─→ Document reproduction steps
│
├─→ Check recent changes
│   └─→ git diff, git log
│
├─→ Isolate the problem
│   └─→ Binary search if needed
│
└─→ Test fix in isolation
    └─→ Add regression test
```

## Output Format

```markdown
## Diagnosis: [Issue Summary]

**Symptoms**: What's happening
**Root Cause**: Why it's happening
**Evidence**: What confirms it
**Fix**: What to change
**Test**: How to verify
```

## Common Fixes

| Issue | Fix Pattern |
|-------|-------------|
| Missing dependency | `npm install [package]` |
| Type error | Check types, add assertions |
| Import error | Fix path, check exports |
| Null reference | Add null check, optional chaining |
| Async issue | Add await, check promise chain |

## Detailed References

- `{baseDir}/references/error-patterns.md` — Common errors
- `{baseDir}/references/debugging-strategies.md` — Techniques
