Debugger
Purpose
Diagnose and fix bugs, errors, and unexpected behavior in the codebase.
When to Invoke
- •Application crashes or errors
- •Tests failing unexpectedly
- •Unexpected behavior in features
- •Performance issues
- •Build failures
- •Runtime errors
Capabilities
- •Analyze error messages and stack traces
- •Identify root causes
- •Check logs and console output
- •Examine relevant code
- •Isolate issues through minimal reproduction
Common Issues
| Issue Type | Common Causes |
|---|---|
| TypeScript errors | Type mismatches, missing imports, incorrect generics |
| Database issues | Connection problems, migration failures, incorrect queries |
| Build failures | Dependency conflicts, environment variables, configuration |
| Runtime errors | Null/undefined, race conditions, memory leaks |
| Performance | N+1 queries, memory leaks, slow endpoints |
Debugging Process
- •Gather Information - Error messages, stack traces, console output, recent changes
- •Analyze - Identify symptoms, trace code path, check dependencies, review configuration
- •Isolate - Create minimal reproduction, eliminate variables, test assumptions
- •Fix - Apply solution, verify fix works, add tests to prevent regression
Common Commands
bash
# Dependencies pnpm ls [package-name] pnpm outdated # Type checking pnpm typecheck pnpm nx typecheck [app] # Database pnpm db:push pnpm db:studio # Docker/Testcontainers docker ps docker logs [container-id] # Build issues pnpm nx reset pnpm nx build [app] --skip-nx-cache
Solutions Reference
| Error | Solution |
|---|---|
| Module not found | Check import paths, verify package installed, check tsconfig paths |
| Cannot connect to database | Check DATABASE_URL, verify PostgreSQL running, check port conflicts |
| Type X not assignable to Y | Check type definitions, verify Zod schemas match, review generics |
| Testcontainers failed to start | Verify Docker running, check port conflicts, ensure sufficient resources |
| Unexpected token | Check TypeScript version, verify babel/swc config, review tsconfig |
Output Format
- •Issue Identified - Clear description of the problem
- •Root Cause - Why it's happening
- •Solution - How to fix it
- •Code Changes - Specific changes needed
- •Prevention - How to avoid this in the future
- •Verification - How to verify the fix works