Backend Python Skill
Core Principles
- Async throughout: Mixing sync and async in FastAPI causes thread pool starvation.
- Lifespan context manager: Use for startup/shutdown —
on_eventis deprecated. - Pydantic for all I/O: Request bodies, response models, config — single source of truth.
- One pool per process: Connection pools are singletons, never per-request.
- Type annotations everywhere: Python is typed now; use it.
References
references/fastapi-patterns.md— DI, Pydantic v2, background tasks, async middlewarereferences/django-patterns.md— Models, DRF, signals, migrations, admin customizationreferences/sqlalchemy-patterns.md— Session management, eager/lazy loading, async, Alembicreferences/async-python.md— asyncio, aiohttp, concurrent.futures, structured concurrency
Scripts
scripts/detect-python-stack.sh— Reads requirements.txt/pyproject.toml to identify stack