python-best-practices
Installation
SKILL.md
Python + FastAPI Best Practices — Quick Reference
Layered Architecture
Router → Service → Repository → Database. Each layer only calls the one below it.
See code-patterns.md for full project structure and layer examples.
Pydantic v2
Separate Create/Update/Response schemas. Use ConfigDict(from_attributes=True) for ORM integration. Use str | None syntax (not Optional[str]).
See code-patterns.md for schema examples.
Async Patterns
async def for I/O routes, plain def for CPU-bound. Use lifespan context manager (not on_event). Use httpx.AsyncClient for external HTTP calls.
See code-patterns.md for async examples.