Skip to main content

A zero-dependency Python debugger CLI built for Claude Code

Project description

pydebug

A zero-dependency Python debugger CLI built for Claude Code.

Run your script with breakpoints, capture locals and stack state, get clean structured output — all in one shot. No interactive session required.


Install

bash install.sh

Or manually:

cp pydebug.py /usr/local/bin/pydebug
chmod +x /usr/local/bin/pydebug

Requires Python 3.9+. No pip dependencies.


Usage

Basic breakpoints

pydebug run script.py --breakpoints 42
pydebug run script.py --breakpoints 10,25,42

Captures all locals at each breakpoint hit.

Watch specific expressions

pydebug run script.py --breakpoints 42 --watch "user_id,response.status,len(items)"

Evaluates each expression in the breakpoint's local scope.

Evaluate arbitrary expressions

pydebug run script.py --breakpoints 42 --eval "df.shape,type(result),items[:3]"

Like --watch but separate section in output — useful for computed values.

Capture on exception

pydebug run script.py --on-exception
pydebug run script.py --on-exception --watch "self,request,data"

Captures locals, stack, and full traceback at the crash site.

Conditional breakpoints

pydebug run script.py --breakpoints "42:x>100,67:status=='error'"

Only fires when the condition evaluates to True.

Pass arguments to your script

pydebug run script.py --breakpoints 10 -- --input data.csv --verbose

Anything after -- is forwarded to the script as sys.argv.

JSON output (for programmatic use)

pydebug run script.py --breakpoints 42 --format json

Timeout

pydebug run script.py --breakpoints 10 --timeout 60   # 60s limit
pydebug run script.py --breakpoints 10 --timeout 0    # no limit

Default timeout is 30 seconds.


Example output

════════════════════════════════════════════════════════════
  pydebug report  →  script.py
════════════════════════════════════════════════════════════

┌─ BREAKPOINT HIT #1  script.py:42
│  Source:      result = process(item)
│
│  Call Stack (innermost last):
│  <module>()  [script.py:80]
│  main()  [script.py:60]
│  run_batch()  [script.py:42]
│
│  Locals:
│    items                = list[150 items]: [{'id': 1, ...}, ...]
│    item                 = {'id': 1, 'name': 'foo', 'active': True}
│    result               = None
│  Watched:
│    item['id']           = 1
│    len(items)           = 150
└────────────────────────────────────────────────────────────

How Claude Code uses it

Claude Code treats pydebug like any other shell command. A typical debugging loop:

  1. Claude reads your code and identifies suspicious lines
  2. Calls pydebug run script.py --breakpoints 34,67 --watch "x,response"
  3. Reads the report output
  4. Adjusts breakpoints or patches the bug
  5. Repeats if needed

The --on-exception flag is especially useful as a first pass — just run it and let the crash tell Claude where to look.


Options reference

Flag Short Description
--breakpoints LINES -b Comma-separated line numbers, optionally with conditions (42:x>0)
--watch EXPRS -w Comma-separated expressions to evaluate at each hit
--eval EXPRS -e Additional expressions to evaluate (shown separately)
--on-exception -x Capture state on unhandled exception
--timeout SECS -t Script timeout in seconds (default: 30)
--format FORMAT -f Output format: text (default) or json
--max-hits N Max breakpoint hits to record (default: 20)

Limitations

  • Works on .py scripts run directly. Not designed for long-running servers or async event loops.
  • Breakpoints must be on executable lines (not blank lines, comments, or def/class headers — use the first line inside the function body).
  • sys.settrace has a small performance overhead — not suitable for tight performance benchmarks.
  • Multi-threaded scripts: only the main thread is traced.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybreakz-0.1.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pybreakz-0.1.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file pybreakz-0.1.1.tar.gz.

File metadata

  • Download URL: pybreakz-0.1.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for pybreakz-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7403cc849f182935f219fa9df407a5ca681ab38038f193eca8b1dc7da9b025c5
MD5 b7b250b1117cba3e03ecde3fb1801e3e
BLAKE2b-256 ac727cb380730acd22e51584f552185df499aff98d53bc0e2c0a06f501b3ba5c

See more details on using hashes here.

File details

Details for the file pybreakz-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pybreakz-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for pybreakz-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 02ae02cfe938efbfa27424438c0985e40c199db24ede0f409659e2aefe8c115c
MD5 09175fcffba32671af1127a526f040b9
BLAKE2b-256 55b043b534d06dd4a7181be23267dd5f1562cc2d5d5ea49e11ccb909cac7f834

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page