{"skill":{"slug":"debug-pro","displayName":"Debug Pro","summary":"Provides a 7-step debugging protocol plus language-specific commands to systematically identify, verify, and fix software bugs across multiple environments.","description":"# debug-pro\n\nSystematic debugging methodology and language-specific debugging commands.\n\n## The 7-Step Debugging Protocol\n\n1. **Reproduce** — Get it to fail consistently. Document exact steps, inputs, and environment.\n2. **Isolate** — Narrow scope. Comment out code, use binary search, check recent commits with `git bisect`.\n3. **Hypothesize** — Form a specific, testable theory about the root cause.\n4. **Instrument** — Add targeted logging, breakpoints, or assertions.\n5. **Verify** — Confirm root cause. If hypothesis was wrong, return to step 3.\n6. **Fix** — Apply the minimal correct fix. Resist the urge to refactor while debugging.\n7. **Regression Test** — Write a test that catches this bug. Verify it passes.\n\n## Language-Specific Debugging\n\n### JavaScript / TypeScript\n```bash\n# Node.js debugger\nnode --inspect-brk app.js\n# Chrome DevTools: chrome://inspect\n\n# Console debugging\nconsole.log(JSON.stringify(obj, null, 2))\nconsole.trace('Call stack here')\nconsole.time('perf'); /* code */ console.timeEnd('perf')\n\n# Memory leaks\nnode --expose-gc --max-old-space-size=4096 app.js\n```\n\n### Python\n```bash\n# Built-in debugger\npython -m pdb script.py\n\n# Breakpoint in code\nbreakpoint()  # Python 3.7+\n\n# Verbose tracing\npython -X tracemalloc script.py\n\n# Profile\npython -m cProfile -s cumulative script.py\n```\n\n### Swift\n```bash\n# LLDB debugging\nlldb ./MyApp\n(lldb) breakpoint set --name main\n(lldb) run\n(lldb) po myVariable\n\n# Xcode: Product → Profile (Instruments)\n```\n\n### CSS / Layout\n```css\n/* Outline all elements */\n* { outline: 1px solid red !important; }\n\n/* Debug specific element */\n.debug { background: rgba(255,0,0,0.1) !important; }\n```\n\n### Network\n```bash\n# HTTP debugging\ncurl -v https://api.example.com/endpoint\ncurl -w \"@curl-format.txt\" -o /dev/null -s https://example.com\n\n# DNS\ndig example.com\nnslookup example.com\n\n# Ports\nlsof -i :3000\nnetstat -tlnp\n```\n\n### Git Bisect\n```bash\ngit bisect start\ngit bisect bad              # Current commit is broken\ngit bisect good abc1234     # Known good commit\n# Git checks out middle commit — test it, then:\ngit bisect good  # or  git bisect bad\n# Repeat until root cause commit is found\ngit bisect reset\n```\n\n## Common Error Patterns\n\n| Error | Likely Cause | Fix |\n|-------|-------------|-----|\n| `Cannot read property of undefined` | Missing null check or wrong data shape | Add optional chaining (`?.`) or validate data |\n| `ENOENT` | File/directory doesn't exist | Check path, create directory, use `existsSync` |\n| `CORS error` | Backend missing CORS headers | Add CORS middleware with correct origins |\n| `Module not found` | Missing dependency or wrong import path | `npm install`, check tsconfig paths |\n| `Hydration mismatch` (React) | Server/client render different HTML | Ensure consistent rendering, use `useEffect` for client-only |\n| `Segmentation fault` | Memory corruption, null pointer | Check array bounds, pointer validity |\n| `Connection refused` | Service not running on expected port | Check if service is up, verify port/host |\n| `Permission denied` | File/network permission issue | Check chmod, firewall, sudo |\n\n## Quick Diagnostic Commands\n\n```bash\n# What's using this port?\nlsof -i :PORT\n\n# What's this process doing?\nps aux | grep PROCESS\n\n# Watch file changes\nfswatch -r ./src\n\n# Disk space\ndf -h\n\n# System resource usage\ntop -l 1 | head -10\n```\n","tags":{"latest":"1.0.0"},"stats":{"comments":0,"downloads":20497,"installsAllTime":205,"installsCurrent":204,"stars":44,"versions":1},"createdAt":1769625005426,"updatedAt":1778485863829},"latestVersion":{"version":"1.0.0","createdAt":1769625005426,"changelog":"debug-pro 1.0.0 initial release:\n\n- Introduces a detailed 7-step debugging protocol for systematic problem-solving.\n- Provides quick-reference debugging commands for JavaScript/TypeScript, Python, Swift, CSS/layout, network tools, and git bisect.\n- Includes a table of common error messages, their likely causes, and quick fixes.\n- Lists frequently used diagnostic shell commands for system and application troubleshooting.","license":null},"metadata":null,"owner":{"handle":"cmanfre7","userId":"s174nsk1wz65vv291vehv20gjh885wn8","displayName":"cmanfre7","image":"https://avatars.githubusercontent.com/u/232135881?v=4"},"moderation":null}