/python:pythonfrom python
Python idiom, review and diagnosis covering typing, exceptions, resource lifetimes, asyncio, retries and background jobs, profiling, and pytest. Use when writing, reviewing or debugging *.py code, or when ruff, mypy, pyright, pytest or uv settings in pyproject.toml shape the change.
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.
Read when SKILL.md points to them.
Preserve the public contract (results, raised exceptions, ordering, side effects, import-time behavior, supported Python versions) unless the request changes it. Write direct, idiomatic code that the repository's configured formatter, linter, type checker, and test runner accept.
Not for building or releasing distributions (python-packaging) or FastAPI routes and dependencies (fastapi).
pyproject.toml (and setup.cfg, tox.ini, noxfile.py, .python-version when present). Note requires-python, the package manager (uv, poetry, pip-tools, hatch), and the configured ruff/black, mypy/pyright, and pytest settings.uv run, poetry run, hatch run, or the active venv), never a global interpreter.requires-python allows (for example match, except*, TaskGroup, PEP 695 generics).requires-python allows it (what's new in 3.14 on docs.python.org): annotations are evaluated lazily (PEP 649), so quoted forward references are unneeded and code reading __annotations__ should call annotationlib.get_annotations(); the Unix default multiprocessing and ProcessPoolExecutor start method is now forkserver, not fork, which breaks code relying on inherited globals or unpicklable arguments; python -m asyncio ps PID lists a running process's tasks; t"..." makes a Template, not a str; free-threaded builds are officially supported.search_graph, trace_path) when the project is indexed; otherwise Grep. The LSP tool, when configured, gives references and inferred types.resolve-library-id, then query-docs) against the installed version (uv pip show <pkg> or the lockfile).Iterable, Mapping, Sequence) only when callers need alternatives; return concrete types.X | None and distinct valid states with a small value type or enum, not flag combinations.Protocol, generics, @overload, or TypeGuard/TypeIs only when they clarify a real caller contract. Read references/typing.md before adding generics, protocols, callable types, or tightening mypy/pyright strictness.Any, untyped dict, blanket cast, or file-wide ignores. A necessary suppression stays on one line with the specific error code (# type: ignore[attr-defined], # pyright: ignore[reportX]) and a reason.raise NewError(...) from err so the cause survives.Exception to log and continue or to return a sentinel. Return expected outcomes as values only when the local API already does.with / async with for files, locks, sessions, responses, temp dirs, and any acquire/release pair. contextlib.ExitStack / AsyncExitStack handle a variable number of them.__exit__ returns a true value only to suppress one named, expected exception. Return False (or None) otherwise.KeyboardInterrupt, SystemExit, and asyncio.CancelledError propagate after bounded cleanup. except Exception doesn't catch them, and it shouldn't be widened to BaseException without re-raising.async commits every caller to it.asyncio.to_thread, an executor, or the project's established mechanism, and define its timeout and cancellation behavior.asyncio.TaskGroup (3.11+) or the project's structured equivalent. Keep a reference to any bare create_task result, since the loop holds only a weak one.asyncio.timeout() (3.11+) or wait_for for deadlines. On timeout, cancellation, or partial startup, release everything acquired and surface the primary failure, not cleanup noise.contextvars doesn't flow into threads unless you copy the context.sys.path or rely on the current directory.uv add, uv lock, poetry add). Never hand-edit a lockfile.python-packaging. Before adding an unfamiliar dependency, use dependency-vetting if installed.uv run ruff check <paths>, uv run ruff format --check <paths>, uv run mypy <pkg> or uv run pyright <paths>, and uv run pytest <path>::<test> -x.ruff check --fix (safe fixes), then ruff format. Apply --unsafe-fixes only after reading ruff check --diff --unsafe-fixes, because an unsafe fix can change behavior (an exception type, a comment). Re-run until nothing changes. Suppress with # noqa: <code> and a reason, not a bare # noqa, and ask the user when a finding has more than one reasonable fix.python -X dev (or -W error::ResourceWarning) surfaces unclosed resources. PYTHONASYNCIODEBUG=1 reports slow callbacks and never-awaited coroutines.unit-testing if installed to choose which regression tests to add.When asked to review Python, or before finalizing a non-trivial change, walk references/review-checklist.md. Report findings with file:line and the concrete failure each one causes.
Before changing code for speed or memory, read references/performance.md.
| Signal | Look first at | Avoid |
|---|---|---|
| Type error | Runtime contract; narrow at the boundary, then fix the annotation or code | cast, Any, or a broad ignore |
ResourceWarning or pending-task warning | The owner and exit path of the resource or task | Sleeps, finalizers, test-order luck |
RuntimeWarning: coroutine ... was never awaited | The call site missing await or a task owner | Wrapping it in asyncio.run inside a running loop |
| Async hang or lost cancellation | A minimized task graph; awaits, timeouts, shutdown | Retries or swallowing CancelledError |
| Works in checkout, fails installed | The built artifact (see python-packaging) | Patching sys.path |
references/async.md (opens in a new tab)references/observability.md (opens in a new tab)references/performance.md (opens in a new tab)references/pytest.md (opens in a new tab)references/reliability.md (opens in a new tab)references/review-checklist.md (opens in a new tab)references/typing.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub adminhead/claude-plugins --plugin python