Skip to content

Commit 086f673

Browse files
Document Python (debugpy) debugging in the dbg skill (#13)
Python is already supported via the debugpy DAP adapter, but the skill docs only listed Node/Bun/Java/native. Add Python to the description, runtimes table, and core loop, plus a dedicated section covering both the launch flow (`dbg launch python3 app.py`) and the TCP attach flow (`python -m debugpy --listen <port>` + `dbg attach <port> --runtime python`). Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 95ade65 commit 086f673

2 files changed

Lines changed: 51 additions & 8 deletions

File tree

.claude/skills/debug-that/SKILL.md

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
name: dbg
33
description: >
44
Debug applications using the dbg CLI debugger.
5-
Supports Node.js (V8/CDP), Bun (WebKit/JSC), and native code via LLDB (DAP).
5+
Supports Node.js (V8/CDP), Bun (WebKit/JSC), Python (debugpy/DAP), Java (JDWP/DAP), and native code via LLDB (DAP).
66
Use when: (1) investigating runtime bugs by stepping through code, (2) inspecting
77
variable values at specific execution points, (3) setting breakpoints and conditional
88
breakpoints, (4) evaluating expressions in a paused context, (5) hot-patching code
99
without restarting (JS/TS), (6) debugging test failures by attaching to a running process,
10-
(7) debugging C/C++/Rust/Swift with LLDB, (8) any task where understanding runtime
11-
behavior requires a debugger.
10+
(7) debugging C/C++/Rust/Swift with LLDB, (8) debugging Python via debugpy,
11+
(9) any task where understanding runtime behavior requires a debugger.
1212
Triggers: "debug this", "set a breakpoint", "step through", "inspect variables",
1313
"why is this value wrong", "trace execution", "attach debugger", "runtime error",
1414
"segfault", "core dump".
1515
---
1616

1717
# dbg Debugger
1818

19-
`dbg` is a CLI debugger that supports **Node.js** (V8/CDP), **Bun** (WebKit/JSC), **Java** (via JDWP/DAP) and **native code** (C/C++/Rust/Swift via LLDB/DAP). It uses short `@refs` for all entities -- use them instead of long IDs.
19+
`dbg` is a CLI debugger that supports **Node.js** (V8/CDP), **Bun** (WebKit/JSC), **Python** (via debugpy/DAP), **Java** (via JDWP/DAP) and **native code** (C/C++/Rust/Swift via LLDB/DAP). It uses short `@refs` for all entities -- use them instead of long IDs.
2020

2121
## Supported Runtimes
2222

@@ -25,17 +25,19 @@ description: >
2525
| Node.js | JavaScript | `dbg launch --brk node app.js` |
2626
| tsx / ts-node | TypeScript | `dbg launch --brk tsx src/app.ts` |
2727
| Bun | JavaScript / TypeScript | `dbg launch --brk bun app.ts` |
28+
| debugpy | Python | `dbg launch --brk python3 app.py` (or attach -- see Python section) |
2829
| LLDB | C / C++ / Rust / Swift | `dbg launch --brk --runtime lldb ./program` |
2930
| JDWP | Java | `dbg launch --brk --runtime java ./program` |
3031

31-
The runtime is auto-detected from the launch command for JS runtimes. For native code, use `--runtime lldb`.
32+
The runtime is auto-detected from the launch command for JS and Python runtimes. For native code, use `--runtime lldb`. Python can also attach to a running `debugpy` listener over TCP (`--runtime python`).
3233

3334
## Core Debug Loop
3435

3536
```bash
3637
# 1. Launch with breakpoint at first line
3738
dbg launch --brk node app.js
3839
# Or: dbg launch --brk bun app.ts
40+
# Or: dbg launch --brk python3 app.py
3941
# Or: dbg launch --brk --runtime lldb ./my_program
4042
# Or attach to a running process with the --inspect flag
4143
dbg attach 9229
@@ -86,7 +88,45 @@ dbg eval "array[i]" # evaluate expression
8688
dbg step into # step into function
8789
```
8890

89-
### Attach to running/test process
91+
### Python debugging (debugpy)
92+
Python uses the `debugpy` DAP adapter. Two ways in:
93+
94+
**Launch** (auto-detected from a `python`/`python3` command):
95+
```bash
96+
dbg launch --brk python3 app.py # pauses at first line
97+
dbg break app.py:42
98+
dbg continue
99+
dbg state # location + locals + stack
100+
dbg eval "some_expr" # evaluate in the paused frame
101+
dbg step over
102+
```
103+
104+
**Attach** -- the debuggee runs its own `debugpy` listener and `dbg` connects
105+
over TCP (no adapter spawned in between). Useful when the process must be
106+
launched a specific way (a test runner, a virtualenv, a secrets wrapper):
107+
```bash
108+
# 1. Start the program listening on a port. --wait-for-client blocks before
109+
# the first line runs, so you have time to attach and set breakpoints.
110+
python3 -m debugpy --listen 5679 --wait-for-client app.py &
111+
112+
# 2. Attach. --runtime python (alias: debugpy) is REQUIRED for a bare port.
113+
dbg attach 5679 --runtime python
114+
115+
# 3. Set breakpoints (use absolute paths), then drive execution.
116+
dbg break /abs/path/app.py:42
117+
dbg continue
118+
dbg state
119+
```
120+
Notes:
121+
- `--wait-for-client` treats the FIRST TCP connection as the client -- don't
122+
probe the port to check readiness; just attach once debugpy prints its
123+
startup banner to stderr.
124+
- A short script can run to completion before you set a breakpoint. Set it
125+
immediately after attaching, or attach to a long-running entry point.
126+
- `dbg set` / `dbg hotpatch` are JS/TS only; inspection (`break`, `continue`,
127+
`state`, `vars`, `eval`, `step`, `break-fn`) all work for Python.
128+
129+
### Attach to running/test process (Node/Bun)
90130
```bash
91131
# Start with inspector enabled
92132
node --inspect app.js
@@ -144,6 +184,7 @@ See [references/commands.md](references/commands.md) for full command details an
144184
- `dbg eval` supports `await` -- useful for async inspection (JS/TS)
145185
- `dbg blackbox "node_modules/**"` -- skip stepping into dependencies
146186
- `dbg hotpatch file` reads the file from disk -- edit the file first, then hotpatch (JS/TS only)
147-
- `dbg break-fn funcName` -- function breakpoints work with DAP runtimes (LLDB)
187+
- `dbg break-fn funcName` -- function breakpoints work with DAP runtimes (LLDB, Python, Java)
188+
- Python: `dbg launch --brk python3 app.py`, or attach to a `debugpy --listen <port>` server with `dbg attach <port> --runtime python`
148189
- Execution commands (`continue`, `step`, `pause`, `run-to`) auto-return status
149190
- `dbg stop` kills the debugged process and daemon

.claude/skills/debug-that/references/commands.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
```bash
1616
dbg launch [--brk] <command...> # Start + attach debugger (--brk pauses at first line)
1717
dbg launch --brk --runtime lldb ./program # Native debugging via LLDB (DAP)
18+
dbg launch --brk python3 app.py # Python debugging via debugpy (DAP)
1819
dbg attach <pid|ws-url|port> # Attach to running process
20+
dbg attach <port> --runtime python # Python: attach to a `debugpy --listen <port>` server
1921
dbg stop # Kill process + daemon
2022
dbg sessions [--cleanup] # List active sessions
2123
dbg status # Session info (pid, state, pause location)
@@ -170,7 +172,7 @@ dbg sourcemap --disable # Disable resolution globally
170172

171173
```bash
172174
--session NAME # Target session (default: "default")
173-
--runtime NAME # Debug adapter: lldb, codelldb, etc. (for native debugging)
175+
--runtime NAME # Debug adapter: lldb, codelldb, python (debugpy), java, etc.
174176
--json # JSON output
175177
--color # Enable ANSI colors
176178
--help-agent # LLM-optimized reference card

0 commit comments

Comments
 (0)