/python:debuggingfrom python
Use when debugging Python at runtime (failing test, wrong value, swallowed exception, hang, crash, slow or growing process), covering debugpy environments, pytest stops, exception filters, attaches through pdb, and the interpreter's stack, fault, and profiling tools
Ships in python. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Covers CPython programs under debugpy and CPython's own stack, fault, and profiling tools. Use tool:debugging for the method, session answers, native stacks, crash reports, and the report.
Launches prefer debugpy in the program's Python environment. If it is absent, an installed debugpy-adapter can run the selected interpreter. Test launches still import pytest in that interpreter.
Launch readings:
No module named 'debugpy' -> add debugpy to the named interpreter's environmenttracer: pure python -> debugpy holds no compiled tracer for this interpreter (prerelease, free-threaded build): stops hold, timing defects can moveTimed out waiting for debuggee to spawn -> process-wide lazy imports stopped debugpy's startup: launch with env {"PYTHON_LAZY_IMPORTS": "normal"}, no -X lazy_imports=all| [INDEX] | [SYMPTOM] | [ROUTE] |
|---|---|---|
| [01] | Failing test | [03] |
| [02] | Wrong value in a script, module, or service | [04] |
| [03] | Exception caught, logged, or returned | [05] |
| [04] | Wrong value in a running process | [06] |
| [05] | Hung process | [07] |
| [06] | Dead process | [08] |
| [07] | Slow or growing process | [09] |
Failing tests stop where they fail, with no breakpoint set:
{"action": "launch", "language": "python", "test": "<file>::<test>", "cwd": "<project>", "args": ["<flags of the failing run>"]}
test takes a pytest node id relative to cwd (tests/test_cart.py::TestCart::test_total[0.5])args follow python -m pytest <test> -x, repeating a failing run's flags and seed, and -s shows a test's prints as they happenReadings:
stopped, exception with AssertionError -> @py_assert<n> locals hold each operand pytest's assertion rewrite computedstopped, exception with Skipped -> pytest.skip ran, and resume continue passes itpassed -> test passes under the launch's flags: compare seed, flags, and environment with a failing runcollected 0 items -> node id names no test under cwdAfter the stop:
evaluate calls code under test in the failing frame with other inputs (total(prices, 0.2)), each answer read before any editsession restart, as Python runs edited files with no buildScripts launch as program, package files as module with cwd at the project root, and settings passes debugpy keys a call lacks:
| [INDEX] | [SETTING] | [EFFECT] |
|---|---|---|
| [01] | "justMyCode": false | Stops and steps in standard library and installed packages |
| [02] | "showReturnValue": true | Steps over or out list (return) <function> among locals |
| [03] | "pythonArgs": [<flag>] | Interpreter flags (-X dev) |
Breakpoints in library files never stop until justMyCode is false. Where a call runs decides whether it stops:
| [INDEX] | [CALL] | [STOP] |
|---|---|---|
| [01] | threading, ThreadPoolExecutor, anyio.to_thread | Stops, read threads names the thread |
| [02] | subprocess, anyio.to_process | Stops under children: true as program <n> |
| [03] | concurrent.interpreters, anyio.to_interpreter | Never stops, so call on main interpreter to stop |
| [04] | async def under an event loop | Stops, tasks read below |
Stop readings:
evaluate [t.get_coro().__qualname__ for t in __import__('asyncio').all_tasks()] lists tasks of the stopped event loopnext or step_out at a raise a caller catches runs on to the next stop -> launch again with env {"PYDEVD_USE_SYS_MONITORING": "0"}PYDEVD_USE_SYS_MONITORING 0 lands such steps in the caller's except, and every call runs slowerevaluate with context repl runs statements, and names they assign join the frame's localsevaluate without context refuses a statement with SyntaxError, and __import__('<module>') reads a module with no name bounddebugpy's exception filters:
| [INDEX] | [FILTER] | [STOPS_AT] |
|---|---|---|
| [01] | uncaught | Raise ending the program, launch default |
| [02] | userUnhandled | Raise in program code a library catches (executor, server) |
| [03] | raised | Every raise in program code, caught ones included |
exceptions ["uncaught", "userUnhandled"]uncaught stays silent there and userUnhandled stops at the raisecondition over it, stops thereRunning processes of Python 3.14 or later attach by pid, the server starting debugpy inside them, and detach leaves its port open for later attaches by address. Processes started under <python> -m debugpy --listen 127.0.0.1:<port> <script> attach by address 127.0.0.1:<port>, and so do processes older than 3.14 or run with -X disable-remote-debug, restarted under debugpy --listen.
Attach facts:
printf 'p <name>\nw\nq\n' | sudo -n <target> -m pdb -p <pid>, <target> the interpreter ps -o command= -p <pid> names, reads one frame with no port, and q leaves the process runningimport statements in that pdb call bind names in the stopped frame, __import__ expressions bind nonejustMyCode offsettings {"pathMappings": [{"localRoot": "<here>", "remoteRoot": "<there>"}]}Read hung processes in order, each read leaving them running:
sudo -n <target> -m profiling.sampling dump -a <pid> prints every thread's Python stack from outside, threads inside a C call included, from Python 3.15dump --async-aware prints each asyncio task's await chain in place of event loop framesprintf 'w\nq\n' | sudo -n <target> -m pdb -p <pid> prints the main thread's stack[06]), then resume pause, which stops nothing while the thread sits in a C call and stops once it returnstool:debuggingHangs that recur dump their stacks at a deadline:
<python> -m pytest -o faulthandler_timeout=<seconds> <test> prints every thread's stack once a test runs past itfaulthandler.dump_traceback_later(<seconds>, exit=True) at a program's entry prints every thread's stack and ends the processDeaths by exception stop under a launch, as uncaught holds the raise with live locals. Deaths by signal (segmentation fault, abort inside a C extension) read in order:
<python> -X faulthandler <script> prints each thread's Python stack, then from Python 3.14 the C stack by symbol and offset<python> -X dev <script> adds debug hooks on memory allocators, ResourceWarning, and asyncio debug mode to the fault handlertool:debuggingfaulthandler.enable(file=<file>) write their dump to <file> in place of standard errorProfiles name the frame spending time or memory, and a breakpoint there reads its values:
| [INDEX] | [QUESTION] | [COMMAND] |
|---|---|---|
| [01] | Where a running process spends time | sudo -n <target> -m profiling.sampling attach -d <seconds> -a <pid> |
| [02] | Which calls a program makes | <python> -m profiling.tracing -s tottime <script> |
| [03] | What imports cost | <python> -X importtime <script> |
| [04] | Which lines hold growing memory | tracemalloc between stops, below |
profiling.sampling prints a pstats table, and --mode cpu keeps samples on a CPU in place of the wall default that counts waiting threadsprofiling.tracing is cProfile before Python 3.15, with the same optionspython:coding for reading -X importtimeMemory growth reads tracemalloc between an early and a later hit of one breakpoint, launched with env {"PYTHONTRACEMALLOC": "<frames>"}:
evaluate setattr(__import__('tracemalloc'), 'kept', __import__('tracemalloc').take_snapshot())resume continue to a later hitevaluate [str(s) for s in __import__('tracemalloc').take_snapshot().compare_to(__import__('tracemalloc').kept, 'lineno')[:5]]read value of its ref prints each line whole, as the result cuts long pathsWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub bsamiee/rasm --plugin python8 skills in this plugin
/codingUse when writing or reviewing Python, covering functional design with result and record types/cycloptsUse when writing or reviewing a cyclopts app, covering commands, parameters, user classes, meta apps, configuration, completion, and exit codes/documentUse when writing or reviewing Python docstrings or fixing ruff D or DOC findings, covering scope and Google-style syntaxOther plugins' skills for the same job
/expressionUse when calling an expression member, covering cases, results, options, unions, persistent collections, composition, effects, and codec boundaries