Agent skill · writing content · aiskillstore
python-best-practices
Use when reading or writing Python files (.py, pyproject.toml, requirements.txt).
Why this skill is useful
Codifies specific Python idioms and error handling patterns that the AI could infer but now doesn't have to guess.
What it needs
About 1k tokens when loaded. Last updated 2026-08-07. 405 stars on the source repository.
What this skill does
Python Best Practices Follows type-first, functional, and error handling patterns from CLAUDE.md. This skill covers language-specific idioms only. Make Illegal States Unrepresentable Use Python's type system to prevent invalid states at type-check time. Frozen dataclasses for immutable domain models: Discriminated unions with Literal: NewType for domain primitives: Protocol for structural typing: Python-Specific Error Handling Chain exceptions with from err to preserve the original traceback: Structured Logging Use a module-level logger with %s formatting (deferred string interpolation): Optional: ty For fast type checking, consider ty from Astral (creators of ruff and uv). Written in Rust, significantly faster than mypy or pyright. When to choose: ty — fastest, good for CI and large codebases (early stage, rapidly evolving) pyright — most complete type inference, VS Code integration mypy — mature, extensive plugin ecosystem
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills aiskillstore/python-best-practices