debugging-strategies
Apply Systematic Debugging Strategies
Debugging complex software issues often feels random and frustrating. This skill provides systematic debugging techniques, profiling tools, and root cause analysis methods that transform troubleshooting into a methodical process.
Download the skill ZIP
Upload in Claude
Go to Settings → Capabilities → Skills → Upload skill
Toggle on and start using
Test it
Using "debugging-strategies". My Node.js API returns 500 errors intermittently. The error says 'Cannot read property of undefined' but I cannot find where this happens.
Expected outcome:
Let me apply systematic debugging to find this undefined property issue.
## Step 1: Reproduce and Observe
- When does the error occur? Always or randomly?
- Which API endpoint triggers it?
- What request parameters are sent?
## Step 2: Gather Information
1. Add strategic logging before the likely crash point:
```javascript
console.log('Order data:', JSON.stringify(order, null, 2));
```
2. Check which property might be undefined:
```javascript
console.log('Items:', order?.items);
console.log('User:', order?.user?.name);
```
## Step 3: Hypothesis
Hypothesis: The error likely occurs when:
- order.items is undefined for certain request types
- order.user is null for guest users
## Step 4: Test and Verify
Add null checks and verify with sample requests:
```javascript
const items = order?.items ?? [];
const userName = order?.user?.name ?? 'Guest';
```
Would you like me to help you implement this fix?
Using "debugging-strategies". Help me debug a memory leak in my React application.
Expected outcome:
Let me guide you through debugging a React memory leak systematically.
## Reproduction Phase
1. Open Chrome DevTools > Memory tab
2. Take a heap snapshot (before)
3. Perform the suspected leaky action 10-20 times
4. Take another snapshot (after)
5. Compare snapshots to identify retained objects
## Common React Memory Leak Patterns
1. Unsubscribed event listeners
2. Timers (setInterval) not cleared in useEffect cleanup
3. Closures holding references to component scope
4. Global caches growing unbounded
## Quick Debugging Steps
```javascript
useEffect(() => {
const timer = setInterval(() => {
// ...
}, 1000);
// Cleanup function - CRITICAL for preventing leaks
return () => {
clearInterval(timer);
// Remove any subscriptions
};
}, []);
```
What symptoms are you seeing? High memory in DevTools or actual crashes?
Security Audit
SafeStatic analysis detected 54 potential issues, all confirmed as false positives. The 'scripts' patterns are Go import statements in code examples. 'External_commands' are markdown backticks used for code formatting. 'Weak cryptographic algorithm' flags are triggered by Go standard library package names (crypto/pprof). 'Network' URLs are GitHub source URLs and localhost debugging endpoints. All findings are legitimate documentation content with no security concerns.
Quality Score
What You Can Build
Fix elusive production bugs
Apply systematic debugging techniques to track down hard-to-reproduce issues in production environments using logging, stack trace analysis, and differential debugging.
Optimize slow application performance
Use profiling tools and techniques to identify performance bottlenecks, memory leaks, and inefficient code patterns across JavaScript, Python, and Go applications.
Learn structured debugging approaches
Master the scientific method for debugging, rubber duck debugging, and systematic problem isolation to become more effective at troubleshooting any code issue.
Try These Prompts
I'm seeing this error in my application: [insert error message and stack trace]. Apply systematic debugging techniques to help me identify the root cause. Walk through the scientific method: observe, hypothesize, experiment, analyze.
My [application type] application is running slowly. Help me use profiling tools to identify the bottleneck. Include step-by-step instructions for using [Chrome DevTools / cProfile / pprof] to find where the time is being spent.
I have an intermittent bug that only happens sometimes and seems related to async operations. Guide me through debugging race conditions using trace logging and timing analysis.
A bug appeared between working version [version A] and current version [version B]. Guide me through using git bisect to find the exact commit that introduced the regression.
Best Practices
- Reproduce the bug consistently before attempting fixes. Without consistent reproduction, you cannot verify your solution.
- Isolate the problem by removing unrelated code. Create a minimal reproduction case that demonstrates the issue.
- Use the debugger, not just console.log statements. Breakpoints let you inspect program state at any point.
Avoid
- Making multiple changes at once. Change one thing at a time to understand what actually fixes the issue.
- Ignoring error messages or not reading the full stack trace. The error message and stack trace contain valuable clues.
- Assuming the bug is in someone else's code. Most bugs are in your own recent changes, not third-party libraries.