Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Master systematic debugging techniques, profiling tools, and root cause analysis to efficiently track down bugs across any codebase or technology stack. Use when investigating bugs, performance issues, or unexpected behavior.
.claude/skills/microck-debugging-strategies/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-05 | ✗→✓ | ▲ Improved | 193% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 158% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 184% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 405% | 0% |
| case-06 | ✓→✓ | = Same ✓ | 706% | 0% |
Transform debugging from frustrating guesswork into systematic problem-solving with proven strategies, powerful tools, and methodical approaches.
1. Observe: What's the actual behavior? 2. Hypothesize: What could be causing it? 3. Experiment: Test your hypothesis 4. Analyze: Did it prove/disprove your theory? 5. Repeat: Until you find the root cause
Don't Assume:
Do:
Explain your code and problem out loud (to a rubber duck, colleague, or yourself). Often reveals the issue.
markdown## Reproduction Checklist 1. **Can you reproduce it?** - Always? Sometimes? Randomly? - Specific conditions needed? - Can others reproduce it? 2. **Create minimal reproduction** - Simplify to smallest example - Remove unrelated code - Isolate the problem 3. **Document steps** - Write down exact steps - Note environment details - Capture error messages
markdown## Information Collection 1. **Error Messages** - Full stack trace - Error codes - Console/log output 2. **Environment** - OS version - Language/runtime version - Dependencies versions - Environment variables 3. **Recent Changes** - Git history - Deployment timeline - Configuration changes 4. **Scope** - Affects all users or specific ones? - All browsers or specific ones? - Production only or also dev?
markdown## Hypothesis Formation Based on gathered info, ask: 1. **What changed?** - Recent code changes - Dependency updates - Infrastructure changes 2. **What's different?** - Working vs broken environment - Working vs broken user - Before vs after 3. **Where could this fail?** - Input validation - Business logic - Data layer - External services
markdown## Testing Strategies 1. **Binary Search** - Comment out half the code - Narrow down problematic section - Repeat until found 2. **Add Logging** - Strategic console.log/print - Track variable values - Trace execution flow 3. **Isolate Components** - Test each piece separately - Mock dependencies - Remove complexity 4. **Compare Working vs Broken** - Diff configurations - Diff environments - Diff data
typescript// Chrome DevTools Debugger function processOrder(order: Order) { debugger; // Execution pauses here const total = calculateTotal(order); console.log('Total:', total); // Conditional breakpoint if (order.items.length > 10) { debugger; // Only breaks if condition true } return total; } // Console debugging techniques console.log('Value:', value); // Basic console.table(arrayOfObjects); // Table format console.time('operation'); /* code */ console.timeEnd('operation'); // Timing console.trace(); // Stack trace console.assert(value > 0, 'Value must be positive'); // Assertion // Performance profiling performance.mark('start-operation'); // ... operation code performance.mark('end-operation'); performance.measure('operation', 'start-operation', 'end-operation'); console.log(performance.getEntriesByType('measure'));
VS Code Debugger Configuration:
json// .vscode/launch.json { "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "Debug Program", "program": "${workspaceFolder}/src/index.ts", "preLaunchTask": "tsc: build - tsconfig.json", "outFiles": ["${workspaceFolder}/dist/**/*.js"], "skipFiles": ["<node_internals>/**"] }, { "type": "node", "request": "launch", "name": "Debug Tests", "program": "${workspaceFolder}/node_modules/jest/bin/jest", "args": ["--runInBand", "--no-cache"], "console": "integratedTerminal" } ] }
python# Built-in debugger (pdb) import pdb def calculate_total(items): total = 0 pdb.set_trace() # Debugger starts here for item in items: total += item.price * item.quantity return total # Breakpoint (Python 3.7+) def process_order(order): breakpoint() # More convenient than pdb.set_trace() # ... code # Post-mortem debugging try: risky_operation() except Exception: import pdb pdb.post_mortem() # Debug at exception point # IPython debugging (ipdb) from ipdb import set_trace set_trace() # Better interface than pdb # Logging for debugging import logging logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger(__name__) def fetch_user(user_id): logger.debug(f'Fetching user: {user_id}') user = db.query(User).get(user_id) logger.debug(f'Found user: {user}') return user # Profile performance import cProfile import pstats cProfile.run('slow_function()', 'profile_stats') stats = pstats.Stats('profile_stats') stats.sort_stats('cumulative') stats.print_stats(10) # Top 10 slowest
go// Delve debugger // Install: go install github.com/go-delve/delve/cmd/dlv@latest // Run: dlv debug main.go import ( "fmt" "runtime" "runtime/debug" ) // Print stack trace func debugStack() { debug.PrintStack() } // Panic recovery with debugging func processRequest() { defer func() { if r := recover(); r != nil { fmt.Println("Panic:", r) debug.PrintStack() } }() // ... code that might panic } // Memory profiling import _ "net/http/pprof" // Visit http://localhost:6060/debug/pprof/ // CPU profiling import ( "os" "runtime/pprof" ) f, _ := os.Create("cpu.prof") pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() // ... code to profile
bash# Git bisect for finding regression git bisect start git bisect bad # Current commit is bad git bisect good v1.0.0 # v1.0.0 was good # Git checks out middle commit # Test it, then: git bisect good # if it works git bisect bad # if it's broken # Continue until bug found git bisect reset # when done
Compare working vs broken:
markdown## What's Different? | Aspect | Working | Broken | |--------------|-----------------|-----------------| | Environment | Development | Production | | Node version | 18.16.0 | 18.15.0 | | Data | Empty DB | 1M records | | User | Admin | Regular user | | Browser | Chrome | Safari | | Time | During day | After midnight | Hypothesis: Time-based issue? Check timezone handling.
typescript// Function call tracing function trace(target: any, propertyKey: string, descriptor: PropertyDescriptor) { const originalMethod = descriptor.value; descriptor.value = function(...args: any[]) { console.log(`Calling ${propertyKey} with args:`, args); const result = originalMethod.apply(this, args); console.log(`${propertyKey} returned:`, result); return result; }; return descriptor; } class OrderService { @trace calculateTotal(items: Item[]): number { return items.reduce((sum, item) => sum + item.price, 0); } }
typescript// Chrome DevTools Memory Profiler // 1. Take heap snapshot // 2. Perform action // 3. Take another snapshot // 4. Compare snapshots // Node.js memory debugging if (process.memoryUsage().heapUsed > 500 * 1024 * 1024) { console.warn('High memory usage:', process.memoryUsage()); // Generate heap dump require('v8').writeHeapSnapshot(); } // Find memory leaks in tests let beforeMemory: number; beforeEach(() => { beforeMemory = process.memoryUsage().heapUsed; }); afterEach(() => { const afterMemory = process.memoryUsage().heapUsed; const diff = afterMemory - beforeMemory; if (diff > 10 * 1024 * 1024) { // 10MB threshold console.warn(`Possible memory leak: ${diff / 1024 / 1024}MB`); } });
markdown## Strategies for Flaky Bugs 1. **Add extensive logging** - Log timing information - Log all state transitions - Log external interactions 2. **Look for race conditions** - Concurrent access to shared state - Async operations completing out of order - Missing synchronization 3. **Check timing dependencies** - setTimeout/setInterval - Promise resolution order - Animation frame timing 4. **Stress test** - Run many times - Vary timing - Simulate load
markdown## Performance Debugging 1. **Profile first** - Don't optimize blindly - Measure before and after - Find bottlenecks 2. **Common culprits** - N+1 queries - Unnecessary re-renders - Large data processing - Synchronous I/O 3. **Tools** - Browser DevTools Performance tab - Lighthouse - Python: cProfile, line_profiler - Node: clinic.js, 0x
markdown## Production Debugging 1. **Gather evidence** - Error tracking (Sentry, Bugsnag) - Application logs - User reports - Metrics/monitoring 2. **Reproduce locally** - Use production data (anonymized) - Match environment - Follow exact steps 3. **Safe investigation** - Don't change production - Use feature flags - Add monitoring/logging - Test fixes in staging
markdown## When Stuck, Check: - [ ] Spelling errors (typos in variable names) - [ ] Case sensitivity (fileName vs filename) - [ ] Null/undefined values - [ ] Array index off-by-one - [ ] Async timing (race conditions) - [ ] Scope issues (closure, hoisting) - [ ] Type mismatches - [ ] Missing dependencies - [ ] Environment variables - [ ] File paths (absolute vs relative) - [ ] Cache issues (clear cache) - [ ] Stale data (refresh database)
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | pass→pass | 9,246 | 7,689 | -17% | 1 | 1 | 0% | 1,748 | 4,518 | +158% | 0 | 0 | — |
case-02 | pass→pass | 8,766 | 8,880 | +1% | 1 | 1 | 0% | 1,745 | 4,957 | +184% | 0 | 0 | — |
case-03 | pass→pass | 4,993 | 5,661 | +13% | 1 | 1 | 0% | 844 | 4,261 | +405% | 0 | 0 | — |
case-04 | fail→fail | 7,537 | 7,525 | -0% | 1 | 1 | 0% | 1,470 | 4,689 | +219% | 0 | 0 | — |
case-05 | fail→pass | 7,579 | 4,952 | -35% | 1 | 1 | 0% | 1,455 | 4,256 | +193% | 0 | 0 | — |
case-06 | pass→pass | 2,829 | 3,603 | +27% | 1 | 1 | 0% | 481 | 3,879 | +706% | 0 | 0 | — |
case-07 | pass→pass | 9,293 | 6,770 | -27% | 1 | 1 | 0% | 1,673 | 4,543 | +172% | 0 | 0 | — |
case-08 | pass→pass | 3,144 | 2,934 | -7% | 1 | 1 | 0% | 511 | 3,750 | +634% | 0 | 0 | — |
case-09 | pass→pass | 3,188 | 3,671 | +15% | 1 | 1 | 0% | 535 | 3,860 | +621% | 0 | 0 | — |
case-10 | pass→pass | 4,577 | 3,982 | -13% | 1 | 1 | 0% | 809 | 4,001 | +395% | 0 | 0 | — |
case-11 | pass→pass | 2,868 | 3,274 | +14% | 1 | 1 | 0% | 517 | 3,851 | +645% | 0 | 0 | — |
case-12 | pass→pass | 3,486 | 3,625 | +4% | 1 | 1 | 0% | 621 | 3,843 | +519% | 0 | 0 | — |
case-13 | pass→pass | 3,461 | 3,573 | +3% | 1 | 1 | 0% | 603 | 3,894 | +546% | 0 | 0 | — |
case-14 | pass→pass | 14,928 | 11,411 | -24% | 1 | 1 | 0% | 2,256 | 5,118 | +127% | 0 | 0 | — |
case-15 | pass→pass | 16,691 | 19,467 | +17% | 1 | 1 | 0% | 2,577 | 6,300 | +144% | 0 | 0 | — |
case-16 | fail→fail | 16,827 | 16,404 | -3% | 1 | 1 | 0% | 2,853 | 6,214 | +118% | 0 | 0 | — |
case-17 | pass→pass | 3,140 | 2,441 | -22% | 1 | 1 | 0% | 536 | 3,671 | +585% | 0 | 0 | — |
case-18 | pass→pass | 7,583 | 9,168 | +21% | 1 | 1 | 0% | 1,503 | 5,102 | +239% | 0 | 0 | — |
case-19 | pass→pass | 7,794 | 6,148 | -21% | 1 | 1 | 0% | 1,242 | 4,216 | +239% | 0 | 0 | — |
case-20 | pass→pass | 8,631 | 8,102 | -6% | 1 | 1 | 0% | 1,460 | 4,494 | +208% | 0 | 0 | — |
case-21 | pass→pass | 8,058 | 8,797 | +9% | 1 | 1 | 0% | 1,627 | 4,909 | +202% | 0 | 0 | — |
case-22 | pass→pass | 10,578 | 8,963 | -15% | 1 | 1 | 0% | 2,245 | 5,098 | +127% | 0 | 0 | — |
case-23 | pass→pass | 6,327 | 6,680 | +6% | 1 | 1 | 0% | 1,185 | 4,486 | +279% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +4 percentage points is the difference between those two pass rates over the 23 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.