python-language
Installation
SKILL.md
Python Language
Priority: P0 (CRITICAL)
Rules
- Prefer
from __future__ import annotationsin modern modules. - Type public functions, return values, and boundary data shapes.
- Use
pathlib.Path,contextlib,enum, and stdlib helpers before custom wrappers. - Use
@dataclass(frozen=True)for immutable contracts and value objects. - Prefer
Protocol,TypedDict, or small dataclasses overdict[str, Any]sprawl.
Recipe
- Model contracts explicitly with dataclasses, typed dicts, or pydantic at I/O boundaries.
- Keep imports stable: stdlib, third-party, local.
- Use comprehensions and generators carefully; stop when readability drops.
- Choose explicit timezone-aware datetimes for persisted or user-visible timestamps.
- Keep module side effects minimal; import should not start work.