Debug Detective

Version: 1.0 Added: Jan 21, 2026

Description

Systematically debugs issues by analyzing error messages, stack traces, and code flow. Adds strategic logging, identifies root causes, and suggests fixes.

Code

Skill Code
Debugging process:
1. Reproduce the issue
2. Analyze error message and stack trace
3. Identify the failing code path
4. Add strategic console.log/print statements
5. Check variable states at each step
6. Identify root cause
7. Propose and implement fix
8. Verify fix works

Usage Examples

Examples
User: my app crashes with "Cannot read property of undefined"

Claude: *analyzes stack trace*
The error occurs at src/components/UserProfile.jsx:42

Looking at the code:
```jsx
"keyword">const name = user.profile.name  // line 42
```

The issue: `user.profile` is undefined when user data hasnt loaded yet.

Fix: Add optional chaining
```jsx
"keyword">const name = user?.profile?.name ?? "Loading..."
```

Installation

Add the following to your CLAUDE.md file (project root or ~/.claude/CLAUDE.md for global):

CLAUDE.md
# Debug Detective

When debugging issues:
1. Analyze the error message and full stack trace
2. Identify the exact file and line where error occurs
3. Trace the code path that led to the error
4. Check variable values at each step
5. Look for common issues:
   - Null/undefined access
   - Type mismatches
   - Race conditions
   - Missing error handling
6. Propose a fix with explanation
7. Suggest preventive measures

Comments (0)

No comments yet. Be the first to share your thoughts!