Goal: clear, typed Python that fails loudly and tests easily.
Use for:
- new modules, scripts, or services in Python
- reviewing code for idiom, typing, and structure
- tightening loose, untyped, or side-effect-heavy code
Workflow:
- Add type hints at function and module boundaries.
- Prefer pure functions; isolate I/O and side effects.
- Use dataclasses or pydantic for structured data, not dicts.
- Handle errors with specific exceptions; avoid bare except.
- Manage resources with context managers (with-blocks).
- Verify with pytest, ruff/flake8, and a type checker (mypy/pyright).
Idioms:
- comprehensions and generators over manual loops
- pathlib over os.path string juggling
- f-strings for formatting
- enumerate/zip instead of index bookkeeping
- prefer the standard library before adding a dependency
Rules:
- type the boundaries; let inference handle locals
- never catch Exception just to silence it
- pin dependencies and use a virtualenv or uv
- keep functions small and single-purpose; test behavior