python
/python
Use when writing, reviewing, or modernizing Python 3.11+ code. Produces fully type-annotated modules, async I/O, dataclasses and protocols, pytest suites, and a lint/type gate built on ruff and mypy --strict. Trigger on "add type hints to this", "mypy is complaining", "convert this to asyncio", "set up pytest for this project". Do not use for FastAPI app structure — see the fastapi skill; for dataframe work, see the pandas skill.
- Author
- nimadorostkar ↗
- Repository
- Claude-Skills-collection ↗
- Licence
- MIT
- Last repository change
- 24.10.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 24.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Use when writing, reviewing, or modernizing Python 3.11+ code. Produces fully type-annotated modules, async I/O, dataclasses and protocols, pytest suites, and a lint/type gate built on ruff and mypy --strict. Trigger on "add type hints to this", "mypy is complaining", "convert this to asyncio", "set up pytest for this project". Do not use for FastAPI app structure — see the fastapi skill; for dataframe work, see the pandas skill.
Triggers from the description
Original author description
Use when writing, reviewing, or modernizing Python 3.11+ code. Produces fully type-annotated modules, async I/O, dataclasses and protocols, pytest suites, and a lint/type gate built on ruff and mypy --strict. Trigger on "add type hints to this", "mypy is complaining", "convert this to asyncio", "set up pytest for this project". Do not use for FastAPI app structure — see the fastapi skill; for dataframe work, see the pandas skill.
How it works
- Purpose
- When to Use
- Capabilities
- Inputs
- Outputs
- Workflow
- Best Practices
- Examples
- Notes
SKILL.md preview
---
name: python
description: Use when writing, reviewing, or modernizing Python 3.11+ code. Produces fully type-annotated modules, async I/O, dataclasses and protocols, pytest suites, and a lint/type gate built on ruff and mypy --strict. Trigger on "add type hints to this", "mypy is complaining", "convert this to asyncio", "set up pytest for this project". Do not use for FastAPI app structure — see the fastapi skill; for dataframe work, see the pandas skill.
metadata:
category: languages
version: 1.0.0
tags: [python, typing, async, pytest, mypy, ruff]
---
# Python
## Purpose
Write production Python that is type-safe, async-first, and testable. This skill sets a single quality bar — annotated, linted, tested — and applies it consistently to new code and to code being modernized.
## When to Use
- Writing new Python modules, packages, or services.
- Adding type coverage to an untyped or partially typed codebase.
- Converting blocking I/O to `asyncio`, or debugging async behavior.
- Standing up a pytest suite, fixtures, or parametrized tests.
- Modernizing Python 2-era or pre-3.10 idioms.
## Capabilities
- Full type annotation, including generics, `Protocol`, `TypedDict`, and `ParamSpec`.
- Async design: task groups, timeouts, cancellation, structured concurrency.
- Data modeling with `dataclasses`, `enum`, and Pydantic when validation is needed.
- Test authoring: fixtures, factories, mocking, property-based tests via Hypothesis.
- Tooling configuration: `pyproject.toml`, ruff, mypy, uv or Poetry.
- Profiling and hot-path optimization.
## Inputs
- Source files or a package path.
- Target Python version (default: 3.12).
- Existing tooling config, if any.
- Runtime constraints: sync vs async, framework, deployment target.
## Outputs
- Type-annotated source that passes `mypy --strict`.
- A pytest suite with meaningful assertions, not coverage padding.
- A `pyproject.toml` section configuring ruff and mypy.
- A short summary of behavioral changes when refactoring.
## Workflow
1. **Survey** — Read the module and its imports. Identify the runtime model (sync, async, threaded) and existing conventions. Do not fight established conventions without a reason.
2. **Model the data** — Define dataclasses, enums, and protocols before writing logic. Type the boundaries first.
3. **Implement** — Write the smallest correct version. Prefer standard library over dependencies.
4. **Test** — Cover the contract and the failure modes, not the implementation details.
5. **Gate** — Run `ruff check --fix`, `ruff format`, `mypy --strict`, `pytest`. Fix each failure and re-run until all four are clean.
## Best Practices
- Use `X | None`, not `Optional[X]`. Use `list[str]`, not `List[str]`.
- Never use a bare `except:`. Catch the narrowest exception that can actually be raised.
- Raise domain-specific exceptions; do not signal failure with `None` return values.
- Use `pathlib.Path` for every filesystem path.
- Never mutate a default argument. Use `field(default_factory=...)`.
- Guard async code with explicit timeouts; an un-timed `await` on a network call is a latency bug waiting to happen.
- Log with the `logging` module and structured extras — never `print` in library code.
## Examples
**Typed, async, cancellation-safe fetch:**
```python
import asyncio
from dataclasses import dataclass
import httpx
@dataclass(frozen=True, slots=True)
class Quote:
symbol: str
price: float
class QuoteUnavailable(Exception):
"""Raised when the upstream cannot serve a quote."""
async def fetch_quotes(symbols: list[str], *, timeout: float = 5.0) -> list[Quote]:
async with httpx.AsyncClient(timeout=timeout) as client:
async with asyncio.TaskGroup() as tg:
tasks = {s: tg.create_task(client.get(f"/quote/{s}")) for s in symbols}
quotes: list[Quote] = []
for symbol, task in tasks.items():
response = task.result()
if response.status_code != 200:
raise QuoteUnavailable(symbol)
quotes.append(Quote(symbol=symbol, price=response.json()["price"]))
return quotes
```
**Test that covers the contract and the failure:**
```python
import pytest
@pytest.mark.asyncio
async def test_fetch_quotes_raises_on_upstream_error(mock_client):
mock_client.get.return_value.status_code = 503
with pytest.raises(QuoteUnavailable, match="AAPL"):
await fetch_quotes(["AAPL"])
```
## Notes
- `TaskGroup` requires Python 3.11+. On 3.10, use `asyncio.gather(..., return_exceptions=True)` and re-raise explicitly.
- `mypy --strict` on a large legacy codebase is a project, not a task. Enable it per-module with `disallow_untyped_defs` and expand the surface gradually.
- Prefer `uv` for new projects; it is materially faster than Poetry and pip for resolution and installs.
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · nimadorostkar/Claude-Skills-collection | 100 | MIT |
| ericrisco/rsc-harness | 100 | MIT |
| xobotyi/cc-foundry | 100 | MIT |
| Aadarsh-x54/deep-agents-with-langchain | 100 | MIT |
| ahgraber/skills | 100 | CC0-1.0 |
| appwrite/claude-plugin | 100 | BSD-3-Clause |
| claude-dev-suite/claude-dev-suite | 100 | MIT |
| G1Joshi/Agent-Skills | 100 | MIT |
| chrishuffman5/domain-expert | 100 | MIT |
Database snapshot: 13.11.2026 · package version cb4e517d93b1 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100python-pro
Use when building Python 3.11+ applications requiring type safety, async programming, or robust error handling. Generates type-annotated Python code, configures mypy in strict mode, writes pytest test suites with fixtures and mocking, and validates code with black and ruff.… - 100python-pro
Use when building Python 3.11+ applications requiring type safety, async programming, or robust error handling. Generates type-annotated Python code, configures mypy in strict mode, writes pytest test suites with fixtures and mocking, and validates code with black and ruff.… - 100python-standards
Python coding standards for modern (3.11+) projects - strict typing, ruff/mypy config, uv packaging, pytest testing, async patterns, error handling, security, docstrings, Docker, and FastAPI/Pydantic/SQLAlchemy/Django/Flask conventions. Use this skill whenever the user writes,… - 100rc-python
Idiomatic typed Python 3.12+ — asyncio, dataclasses, pytest, ruff, uv. Use when writing or reviewing Python. Do not use for JS/TS or Go. - 90python-expert
Use when building Python 3.11+ applications requiring type safety, async programming, or production-grade patterns. Invoke for type hints, pytest, async/await, dataclasses, mypy configuration. - 90python-conventions
Use when a ticket adds or changes Python code and it must follow the repo's Python conventions — PEP 8, full type hints (PEP 484) checked by mypy/pyright, dataclasses, pythonic idioms, explicit error handling, asyncio and thread safety, ruff-clean, and pytest with coverage via…