/tsh-stack-python:writing-modern-pythonfrom TSH Stack: Python
Guides implementation and review of modern Python 3.12+ code: typing, PEP 695 generics, structural typing, module layout, control flow, asyncio/TaskGroup, exception handling, pathlib, logging, pytest, and uv/Ruff/ty workflows.
Ships in TSH Stack: 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.
Implement or review general modern Python 3.12+ code outside the dedicated data-modeling skill in this plugin.
Read the repository's own conventions first — project conventions override generic guidance where they are more specific.
Delegate dataclass, Pydantic, ORM, serialization, and persistence-boundary
contract decisions to
writing-data-models, which ships in this
same plugin. This skill owns cross-cutting concerns: typing, control flow,
concurrency, exceptions, logging, and tooling.
| Severity | Rule |
|---|---|
| MUST | Structure modules "newspaper style": docstring, imports, constants, and public API at the top; private helpers (_-prefixed) pushed to the bottom. |
| MUST | Use built-in generic syntax (list[str], dict[str, int], A | None) and PEP 695 syntax (def f[T](...), type Alias = ...). |
| NEVER | Use from __future__ import annotations — obsolete in modern Python. |
| MUST | Favor typing.Protocol over deep inheritance hierarchies for structural, duck-typed boundaries. |
| MUST | Use asyncio.TaskGroup for structured concurrency over related tasks, and handle its exceptions with except*. Use asyncio.gather only when its distinct fail-fast/collect-all semantics are actually intended. |
| NEVER | Run blocking I/O or CPU-bound work directly inside a coroutine. Offload it explicitly with asyncio.to_thread (or an equivalent thread boundary). |
| MUST | Preserve exception causes with raise ... from e when translating exceptions at a boundary; use bare raise for propagation. Use raise ... from None only to intentionally suppress an internal cause. |
| NEVER | Configure logging globally from inside a library. Use the project's logging facade and keep logs free of secrets, including in add_note(). |
| NEVER | Use assert for production validation — it is stripped under -O and is not a substitute for an explicit check. |
| MUST | Use uv for environment/dependency management, Ruff for linting/formatting, ty for type checking, and pytest for tests; run the focused checks for touched code before broadening. |
| Reference | Load when | Covers |
|---|---|---|
| Review checklist | Reviewing a change, or before finishing an implementation | The full workflow and quick-review checks: typing, data structures, idioms, concurrency, resource management, exception handling, logging, and tooling |
typing.override for inherited methods; typing.Protocol for
duck-typing boundaries.list for
mutability, tuple for fixed/hashable records, set for uniqueness and
fast lookup, collections.defaultdict for grouping,
collections.Counter for tallying.:=) —
but revert to an explicit for loop if nesting hurts readability.writing-data-models.asyncio.TaskGroup; explicit thread offload for blocking/CPU-bound work;
pathlib.Path and context managers for resource lifetime.uv, Ruff, ty, and pytest — run the focused checks for the
touched code, then broaden only when the change warrants it.review-checklist.md in full.writing-data-models — ships in this
same plugin; owns Pydantic, dataclass domain modeling, serialization, and
persistence-boundary contracts.What SKILL.md sets; muted values are Claude Code's defaults
Trigger on: choosing between list/dict/set/tuple, PEP 695 generics or type aliases, typing.Protocol vs inheritance, asyncio.TaskGroup or structured concurrency, blocking I/O inside a coroutine, exception chaining with raise ... from, logging setup in a library, or uv/Ruff/ty/pytest workflow questions.
Three short reads, in order
npx claudepluginhub thesoftwarehouse/agentic-collections --plugin tsh-stack-python2 skills in this plugin
Other plugins' skills for the same job