Skip to main content

pybreakz

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

pip install pybreakz

Or install from source:

git clone https://github.com/allannapier/py_debug_cli.git
cd py_debug_cli
pip install -e .

Requires Python 3.9+. No pip dependencies.


Usage

Basic breakpoints

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

Captures all locals at each breakpoint hit.

Watch specific expressions

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

Evaluates each expression in the breakpoint's local scope.

Evaluate arbitrary expressions

pybreakz 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

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

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

Conditional breakpoints

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

Only fires when the condition evaluates to True.

Pass arguments to your script

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

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

JSON output (for programmatic use)

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

Timeout

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

Default timeout is 30 seconds.


Example output

════════════════════════════════════════════════════════════
  pybreakz 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 pybreakz like any other shell command. A typical debugging loop:

  1. Claude reads your code and identifies suspicious lines
  2. Calls pybreakz 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.

Metadata

Release files for pybreakz 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pybreakz 0.1.4
File Size Uploaded
pybreakz-0.1.4.tar.gz 13.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pybreakz 0.1.4
File Interpreter ABI Platform
pybreakz-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 26.4 kB

Release files / pybreakz-0.1.4.tar.gz

Download URL pybreakz-0.1.4.tar.gz
Size 13.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d4a1f80e3207ddeb753c62ad60cf2cdd747f53bc81c7c4935f8d3559c5db4057
BLAKE2b-256 checksum
How to use checksums
4ddcbe6384a9c2ea9e2c8ad1443c7c7ce99fb965ff68c0fcb7647e4cddac7463
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / pybreakz-0.1.4-py3-none-any.whl

Download URL pybreakz-0.1.4-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b3a29229b56633b2b1771db843d35ae953a8e4059803be7f03227e3722e26c3
BLAKE2b-256 checksum
How to use checksums
08939c576896ff1b2e6ad92b61f4b3ba11d3a45bfba958a1bf8c60291c3038ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page