$npx -y skills add ancoleman/ai-design-components --skill debugging-techniquesDebugging workflows for Python (pdb, debugpy), Go (delve), Rust (lldb), and Node.js, including container debugging (kubectl debug, ephemeral containers) and production-safe debugging techniques with distributed tracing and correlation IDs. Use when setting breakpoints, debugging
| 1 | # Debugging Techniques |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | Provides systematic debugging workflows for local, remote, container, and production environments across Python, Go, Rust, and Node.js. Covers interactive debuggers, container debugging with ephemeral containers, and production-safe techniques using correlation IDs and distributed tracing. |
| 6 | |
| 7 | ## When to Use This Skill |
| 8 | |
| 9 | Trigger this skill for: |
| 10 | - Setting breakpoints in Python, Go, Rust, or Node.js code |
| 11 | - Debugging running containers or Kubernetes pods |
| 12 | - Setting up remote debugging connections |
| 13 | - Safely debugging production issues |
| 14 | - Inspecting goroutines, threads, or async tasks |
| 15 | - Analyzing core dumps or stack traces |
| 16 | - Choosing the right debugging tool for a scenario |
| 17 | |
| 18 | ## Quick Reference by Language |
| 19 | |
| 20 | ### Python Debugging |
| 21 | |
| 22 | **Built-in: pdb** |
| 23 | ```python |
| 24 | # Python 3.7+ |
| 25 | def buggy_function(x, y): |
| 26 | breakpoint() # Stops execution here |
| 27 | return x / y |
| 28 | |
| 29 | # Older Python |
| 30 | import pdb |
| 31 | pdb.set_trace() |
| 32 | ``` |
| 33 | |
| 34 | **Essential pdb commands:** |
| 35 | - `list` (l) - Show code around current line |
| 36 | - `next` (n) - Execute current line, step over functions |
| 37 | - `step` (s) - Execute current line, step into functions |
| 38 | - `continue` (c) - Continue until next breakpoint |
| 39 | - `print var` (p) - Print variable value |
| 40 | - `where` (w) - Show stack trace |
| 41 | - `quit` (q) - Exit debugger |
| 42 | |
| 43 | **Enhanced tools:** |
| 44 | - `ipdb` - Enhanced pdb with tab completion, syntax highlighting (`pip install ipdb`) |
| 45 | - `pudb` - Terminal GUI debugger (`pip install pudb`) |
| 46 | - `debugpy` - VS Code integration (included in Python extension) |
| 47 | |
| 48 | **Debugging tests:** |
| 49 | ```bash |
| 50 | pytest --pdb # Drop into debugger on test failure |
| 51 | ``` |
| 52 | |
| 53 | For detailed Python debugging patterns, see `references/python-debugging.md`. |
| 54 | |
| 55 | ### Go Debugging |
| 56 | |
| 57 | **Delve - Official Go debugger** |
| 58 | |
| 59 | **Installation:** |
| 60 | ```bash |
| 61 | go install github.com/go-delve/delve/cmd/dlv@latest |
| 62 | ``` |
| 63 | |
| 64 | **Basic usage:** |
| 65 | ```bash |
| 66 | dlv debug main.go # Debug main package |
| 67 | dlv test github.com/me/pkg # Debug test suite |
| 68 | dlv attach <pid> # Attach to running process |
| 69 | dlv debug -- --config prod.yaml # Pass arguments |
| 70 | ``` |
| 71 | |
| 72 | **Essential commands:** |
| 73 | - `break main.main` (b) - Set breakpoint at function |
| 74 | - `break file.go:10` (b) - Set breakpoint at line |
| 75 | - `continue` (c) - Continue execution |
| 76 | - `next` (n) - Step over |
| 77 | - `step` (s) - Step into |
| 78 | - `print x` (p) - Print variable |
| 79 | - `goroutine` (gr) - Show current goroutine |
| 80 | - `goroutines` (grs) - List all goroutines |
| 81 | - `goroutines -t` - Show goroutine stacktraces |
| 82 | - `stack` (bt) - Show stack trace |
| 83 | |
| 84 | **Goroutine debugging:** |
| 85 | ```bash |
| 86 | (dlv) goroutines # List all goroutines |
| 87 | (dlv) goroutines -t # Show stacktraces |
| 88 | (dlv) goroutines -with user # Filter user goroutines |
| 89 | (dlv) goroutine 5 # Switch to goroutine 5 |
| 90 | ``` |
| 91 | |
| 92 | For detailed Go debugging patterns, see `references/go-debugging.md`. |
| 93 | |
| 94 | ### Rust Debugging |
| 95 | |
| 96 | **LLDB - Default Rust debugger** |
| 97 | |
| 98 | **Compilation:** |
| 99 | ```bash |
| 100 | cargo build # Debug build includes symbols by default |
| 101 | ``` |
| 102 | |
| 103 | **Usage:** |
| 104 | ```bash |
| 105 | rust-lldb target/debug/myapp # LLDB wrapper for Rust |
| 106 | rust-gdb target/debug/myapp # GDB wrapper (alternative) |
| 107 | ``` |
| 108 | |
| 109 | **Essential LLDB commands:** |
| 110 | - `breakpoint set -f main.rs -l 10` - Set breakpoint at line |
| 111 | - `breakpoint set -n main` - Set breakpoint at function |
| 112 | - `run` (r) - Start program |
| 113 | - `continue` (c) - Continue execution |
| 114 | - `next` (n) - Step over |
| 115 | - `step` (s) - Step into |
| 116 | - `print variable` (p) - Print variable |
| 117 | - `frame variable` (fr v) - Show local variables |
| 118 | - `backtrace` (bt) - Show stack trace |
| 119 | - `thread list` - List all threads |
| 120 | |
| 121 | **VS Code integration:** |
| 122 | - Install CodeLLDB extension (`vadimcn.vscode-lldb`) |
| 123 | - Configure `launch.json` for Rust projects |
| 124 | |
| 125 | For detailed Rust debugging patterns, see `references/rust-debugging.md`. |
| 126 | |
| 127 | ### Node.js Debugging |
| 128 | |
| 129 | **Built-in: node --inspect** |
| 130 | |
| 131 | **Basic usage:** |
| 132 | ```bash |
| 133 | node --inspect-brk app.js # Start and pause immediately |
| 134 | node --inspect app.js # Start and run |
| 135 | node --inspect=0.0.0.0:9229 app.js # Specify host/port |
| 136 | ``` |
| 137 | |
| 138 | **Chrome DevTools:** |
| 139 | 1. Open `chrome://inspect` |
| 140 | 2. Click "Open dedicated DevTools for Node" |
| 141 | 3. Set breakpoints, inspect variables |
| 142 | |
| 143 | **VS Code integration:** |
| 144 | Configure `launch.json`: |
| 145 | ```json |
| 146 | { |
| 147 | "type": "node", |
| 148 | "request": "launch", |
| 149 | "name": "Launch Program", |
| 150 | "program": "${workspaceFolder}/app.js" |
| 151 | } |
| 152 | ``` |
| 153 | |
| 154 | **Docker debugging:** |
| 155 | ```dockerfile |
| 156 | EXPOSE 9229 |
| 157 | CMD ["node", "--inspect=0.0.0.0:9229", "app.js"] |
| 158 | ``` |
| 159 | |
| 160 | For detailed Node.js debugging patterns, see `references/nodejs-debugging.md`. |
| 161 | |
| 162 | ## Container & Kubernetes Debugging |
| 163 | |
| 164 | ### kubectl debug with Ephemeral Containers |
| 165 | |
| 166 | **When to use:** |
| 167 | - Container has crashed (kubectl exec won't work) |
| 168 | - Using distroless/minimal image |