dbg — a flight recorder for debugging
Runtime debugging for Claude Code and for humans. Record what a program actually
did, then interrogate the recording — instead of adding console.log, re-running,
and reading a wall of output.
Zero dependencies. One file to run: bin/dbg.js (Node ≥ 22).
# capture a race condition without touching a single line of source
dbg run --lp 'bank.js:8 who, cur, amt' -- node bank.js
dbg timeline
# t src label data
1 +0.0ms node:812 bank.js:8 {who="A" amt=60}
2 +0.2ms node:812 bank.js:8 {who="B" amt=60}
3 +6.2ms node:812 bank.js:10 {who="A" cur=100 amt=60}
4 +8.6ms node:812 bank.js:10 {who="B" cur=100 amt=60} <-- both read 100
Why not just add log statements
| console.log | dbg |
|---|
| Requires editing source | yes | no |
| Can leave debug code behind | yes | nothing to leave behind |
| Works on an already-running process | no | dbg attach --pid |
| Preserves true execution order | mostly | yes, sequenced at capture time |
| Survives a process that exits immediately | often not | yes |
| Follows a request across processes | no | yes, correlation ids |
| Output size | grows without bound | bounded by design |
| Comparing two runs | by eye | dbg diff |
| Changes the program's behaviour | no | no — and it is tested |
Install
# as a Claude Code plugin
claude plugin marketplace add pzep1/claudecode-debug-mode
claude plugin install claude-debug-plugin@pzep1-claudecode-debug-mode
# or as a skill
npx skills add pzep1/claudecode-debug-mode
# or just use it directly
git clone https://github.com/pzep1/claudecode-debug-mode
ln -s "$PWD/claudecode-debug-mode/bin/dbg.js" /usr/local/bin/dbg
Capture
dbg run --lp 'src/a.js:42 x, y' -- node a.js # run a program under the recorder
dbg run --bg --agent -- node server.js # a server, with HTTP tracing
dbg attach --pid 4821 # an ALREADY RUNNING node process
dbg attach --chrome --net # a Chrome page, with network capture
dbg exec -- node client.js # another process, same recording
dbg sink # listen for python/shell/browser
dbg stop # detach, remove every probe
dbg attach --pid works on a process that was not started with --inspect —
your dev server does not have to be restarted.
Probe
Logpoints are breakpoints whose condition has a side effect and always evaluates
false, so the program never pauses and its stdout stays clean.
dbg lp add 'src/order.js:42 orderId, qty' # capture named expressions
dbg lp add 'src/order.js:42' --snapshot # capture the whole local+closure scope
dbg lp add 'src/order.js:42' --when 'qty > 100' --max 20
dbg lp ls # hits, and whether each probe bound
dbg scripts # what the runtime actually loaded
dbg eval '<expr>' # evaluate in the live process
Read
Everything is bounded. dbg stats stays under 40 lines whether the run captured
12 events or 500,000.
dbg stats # errors, label counts, stalls, network failures, traces
dbg tail -n 20 # latest events
dbg where 'd.qty > 100' # JS predicate over event data
dbg timeline --corr <id> # one request across every process, in order
dbg around 42 / dbg show 42
dbg slow # spans by duration
dbg net --all # requests; failures first, with response bodies
dbg diff <runA> <runB> # first divergence between two runs
Flaky bugs
dbg repeat -n 20 --until-fail --lp 'flaky.js:5 jitter' -- node flaky.js
Runs until it fails, then diffs a passing run against the failing one:
context (A): 1 +0.0ms flaky.js:5 {jitter=7.535} exit=0
context (B): 1 +0.0ms flaky.js:5 {jitter=17.563} exit=1
Network and HAR
dbg attach --chrome --net # live capture from Chrome
dbg import session.har # merge a DevTools / Charles / mitmproxy HAR
dbg export har -o out.har # write captured traffic back out
dbg net
Imported and live traffic land on the same timeline as your logpoints, so
"the request never went out" and "the handler never ran" stop looking identical.
Other languages
dbg sink, then paste a producer:
dbg snippet python # also: browser, shell, node
dbg("row", i=i, raw=r, kind=type(r).__name__)
Non-blocking, ordered, with uncaught exceptions captured automatically.
Source probes (fallback)
For runtimes with no inspector. Every inserted line is marked, so removal is
mechanical and verifiable — the failure mode of hand-written debug statements is
that they ship.