| name | debugging-strategies |
| description | Systematic debugging approaches for complex problems |
| triggers | ["context","debug","error","bug","fix"] |
Debugging Strategies Skill
Purpose: Apply systematic debugging approaches
Overview
This skill provides structured methodologies for identifying and resolving bugs efficiently.
The 5-Step Debugging Process
1. Reproduce
- Create minimal reproduction case
- Document exact steps to trigger
- Note environment details (OS, versions, config)
2. Isolate
3. Identify
- Read error messages carefully
- Check stack traces
- Review recent changes
4. Fix
- Make minimal change
- One fix at a time
- Don't introduce new issues
5. Verify
- Confirm fix works
- Test edge cases
- Add regression test
Debugging Tools
Console Debugging
console.log("value:", value);
console.log("[UserService.create]", { email, userId });
console.table(users);
console.time("api-call");
await fetchData();
console.timeEnd("api-call");
Breakpoint Debugging
debugger;
Common Bug Patterns
Async Issues
const user = getUserById(id);
console.log(user.name);
const user = await getUserById(id);
console.log(user.name);
Reference vs Value
const sorted = items.sort();
const sorted = [...items].sort();
Closure Issues
for (var i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 100);
}
for (let i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 100);
}
Error Investigation
Read the Stack Trace
Error: Cannot read property 'name' of undefined
at UserService.getUser (user.service.ts:45:23) ← Start here
at UserController.show (user.controller.ts:28:15)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Check Recent Changes
git log --oneline -10
git diff HEAD~5..HEAD -- src/
git blame src/services/user.service.ts
Quick Reference
| Symptom | Likely Cause |
|---|
| undefined is not an object | Null reference |
| Maximum call stack | Infinite recursion |
| Cannot read property | Missing null check |
| CORS error | Backend config |
| 401 Unauthorized | Token expired |
| 500 Internal Error | Unhandled exception |