python-debugpy

A set of instructions for debugging Python programs with built-in tools such as pdb and breakpoint(), plus debugpy for connecting to a running or remote process.

In plain words
What is it for?
Use it to investigate failing tests, confusing state changes, subprocesses, long-running services, unhandled exceptions, or Python programs running without a visible terminal.
Why use it?
It helps you inspect variables, follow program execution, and stop at the code causing a failure instead of guessing from error messages alone.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/subhansh-dev/agent-maxxing/26-python-debugpy
Any agent
npx skills add subhansh-dev/agent-maxxing --skill 26-python-debugpy
Clone the repo
git clone --depth 1 https://github.com/subhansh-dev/agent-maxxing

Made for: Claude Code, Codex.

Per session 23 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 697 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00023 $0.00697
Opus 5 $0.00012 $0.00349
Sonnet 5 $0.00005 $0.00139
Haiku 4.5 $0.00002 $0.00070

Measured yesterday against content hash e3897c602f5b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

python-debugpy scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

engineering/26-PYTHON-DEBUGPY/SKILL.md · 74 lines

How it starts

The opening of the file, as written. The whole thing — 74 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python Debugpy

Use when Python code needs interactive debugging: hidden locals, confusing state mutation, failing tests, subprocesses, long-running services, or remote/headless attach.

Pick the smallest debugger that reaches the bad frame.

Choose

  • breakpoint(): local code, source edits ok, fastest path.
  • python3 -m pdb: no source edit, launch from the beginning.
  • python3 -m pdb -c continue: stop at an unhandled exception.
  • debugpy: remote/headless process, DAP client, already-running PID, or service startup race.

Commands

python3 -m pdb path/to/script.py arg1
python3 -m pdb -c continue path/to/script.py
python3 -c "import debugpy" || python3 -m pip install debugpy
python3 -m debugpy --listen 127.0.0.1:5678 --wait-for-client path/to/script.py
python3 -m debugpy --listen 127.0.0.1:5678 --wait-for-client -m package.module
python3 -m debugpy --listen 127.0.0.1:5678 --pid <pid>

For source-edit attach:

import debugpy

debugpy.listen(("127.0.0.1", 5678))
debugpy.wait_for_client()
debugpy.breakpoint()

For post-mortem:

import pdb, sys

try:
    run()
except Exception:
    pdb.post_mortem(sys.exc_info()[2])
    raise

pdb

  • Flow: n, s, r, c, q.
  • Stack/source: w, u, d, a, l, ll.
  • Values: p expr, pp expr, display expr.
  • Breakpoints: b file.py:42, b func, b file.py:42, condition, cl <num>.
  • Mutate/evaluate: !statement; full REPL: interact.

Rules

  • Reproduce with the smallest command/test first.
  • Disable parallel test workers for pdb; interactive stdin usually breaks inside worker pools.
  • Keep debugpy in the active env; do not add it as a project dependency unless the project already wants it.
  • Bind debug servers to 127.0.0.1; do not expose 0.0.0.0 unless isolated or tunnelled.
  • Use unique ports for parallel sessions.
  • Treat debugpy --pid as injection; avoid security-sensitive or production targets unless explicitly approved.
  • If PID attach fails on Linux, check ptrace/container privileges before changing the target.
  • Cleanup before commit: rg -n 'breakpoint\\(|pdb\\.set_trace|debugpy\\.' --type py.
  • Rerun the normal project test/gate without the debugger.
  • PYTHONBREAKPOINT=0 disables breakpoint().
  • If a process is stuck after debugger detach, confirm it is not still paused at a breakpoint.

Read the full file on GitHub · 74 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 74 lines · 23 tokens per session scan A e3897c602f5b

Subscribe to this mod's changes

python-debugpy is a skill published in the GitHub repository subhansh-dev/agent-maxxing (2 stars, last pushed 1mo ago), licensed MIT. It adds 23 tokens to every session and 697 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.