FastAPI Expert Skill
Idiomatic FastAPI service generation and review - an Agent Skill for Python 3.14, FastAPI 0.115+, and Pydantic 2.
Search across all documentation pages
Idiomatic FastAPI service generation and review - an Agent Skill for Python 3.14, FastAPI 0.115+, and Pydantic 2.
Produces a deployable API checklist: src/ layout, pyproject.toml with uv, router modules, settings via pydantic-settings, /health and /ready, structured logging, pytest + httpx tests, and Dockerfile stub.
| Input | Why |
|---|---|
| Service name | Package name, log field, Docker image tag |
| Sync vs async DB | AsyncSession + asyncpg vs sync SQLAlchemy |
| Auth model | None, API key, OAuth2 JWT |
| Port default | 8000 or platform convention |
| Monorepo path | services/billing-api vs root repo |
pyproject.toml with fastapi, uvicorn[standard], pydantic-settings, httpx, pytestapp/main.py with lifespan, CORS policy stub, router includesapp/settings.py with BaseSettings and .env.exampleapp/routers/health.py with /health and /readytests/test_health.py using TestClient or httpx.ASGITransportmodel_validate, Field(alias=...), not v1 .dict()..env.example placeholders only.logging JSON or structlog - no bare print in prod paths.requests or heavy CPU without to_thread.requires-python >= 3.14 when org standard allows - document 3.13 fallback if needed.cd services/billing-api
uv sync
uv run ruff check .
uv run pytest -q
uv run uvicorn app.main:app --reload &
curl -sf http://localhost:8000/health
curl -sf http://localhost:8000/ready# app/main.py
from contextlib import asynccontextmanager
from fastapi import FastAPI
from app.routers import health
@asynccontextmanager
async def lifespan(app: FastAPI):
yield
app = FastAPI(title="billing-api", lifespan=lifespan)
app.include_router(health.router)# app/routers/health.py
from fastapi import APIRouter
router = APIRouter(tags=["health"])
@router.get("/health")
def health() -> dict[str, str]:
return {"status": "ok"}
@router.get("/ready")
def ready() -> dict[str, str]:
return {"status": "ready"}FastAPI for IO-bound JSON APIs. Django when admin, ORM monolith, and templates are core - skill does not override ADR.
Only when input specifies persistence day one - otherwise stub repository protocol and add DB in follow-up PR.
uvicorn for dev; production often gunicorn -k uvicorn.workers.UvicornWorker behind reverse proxy.
Stack versions: This page was written for Python 3.14.0 (stable 3.14, maintenance 3.13), FastAPI 0.115+, Django 5.2, Flask 3.1, Pydantic 2, PyTorch 2.6+, pandas 2.2+, Polars 1.x, ruff 0.9+, and uv 0.6+.
Reviewed by Chris St. John·Last updated Jul 16, 2026