← ClaudeAtlas

python-conventionslisted

Use when a ticket adds or changes Python code and it must follow the repo's Python conventions — PEP 8, full type hints, dataclasses, pythonic idioms, explicit error handling, and pytest with coverage. Invoke for "add this in Python", "fix the type/lint errors", "add the FastAPI/Django endpoint", or as the language pack for any Python change.
tmj-90/gaffer · ★ 0 · AI & Automation · score 69
Install: claude install-skill tmj-90/gaffer
# Write idiomatic, typed Python Add Python that reads as pythonic, is fully type-hinted, and matches the repo's existing idioms and tooling — clear and correct, not just runnable. ## Steps 1. **Read the lore first.** Call `search_lore` (Memory MCP) for the repo's Python conventions and respect its config: the Python version, `pyproject.toml` (dependencies, tool config), the formatter/linter (ruff / black), and the type checker (mypy / pyright). Use the project's environment manager (poetry / venv / uv) — never install globally. 2. **Find a sibling module** and copy its patterns — package layout, import style, error handling, how data is modelled, and how tests are organised. 3. **Type everything.** Add type hints on every function signature and public attribute; prefer precise types (`Sequence`, `Mapping`, `Protocol`, `TypedDict`, `Literal`) over bare `Any`. Justify any `Any` in a comment. Run the project's type checker and fix the cause of errors rather than `# type: ignore`-ing them. 4. **Model data with `@dataclass`** (frozen where it should be immutable) or Pydantic when the repo already uses it for validation at boundaries — not loose dicts of stringly-typed keys. 5. **Be pythonic.** Comprehensions and generators over manual loops where readable; context managers (`with`) for resources; `pathlib` over string paths; f-strings for formatting; `enumerate`/`zip` over index juggling. 6. **Handle errors explicitly.** Catch the **narrowest