FastAPI + Python 3.12
Pydantic v2 and SQLAlchemy 2.0 async only (no legacy APIs), router → service → repository layering, Alembic migrations, JWT auth, pytest + httpx.
Download free sample (2 files)Buy · $12
Included files
| File | Covers | Rules | Scope |
|---|---|---|---|
00-core.mdc | Core conventions for a Python 3.12 FastAPI service | 9 | Always on |
10-routers-schemas.mdc in free sample | FastAPI routers, dependencies and Pydantic v2 schemas | 9 | Auto-attaches to src/app/**/router.py src/app/**/schemas.py src/app/**/deps.py |
20-errors.mdc | Error handling and exception mapping | 6 | Auto-attaches to src/app/**/*.py |
30-database.mdc in free sample | SQLAlchemy 2.0 async models, sessions, repositories and Alembic migrations | 8 | Auto-attaches to src/app/**/models.py src/app/**/repository.py src/app/core/db.py alembic/**/*.py |
40-security.mdc | Authentication, authorization and secure coding | 8 | Auto-attaches to src/app/core/security.py src/app/**/deps.py src/app/auth/**/*.py src/app/main.py |
50-testing.mdc | Testing with pytest, httpx AsyncClient and a real Postgres | 8 | Auto-attaches to tests/**/*.py |
60-naming-style.mdc | Python naming and style | 6 | Auto-attaches to src/**/*.py tests/**/*.py |
CLAUDE.md | Claude Code project instructions — sections: Commands, Architecture, Pydantic v2 / SQLAlchemy 2.0, Errors, Security, Testing, Style | 21 | Always on (Claude Code) |
README.md | Install steps for Cursor and Claude Code, customization notes | – | – |
Preview: 10-routers-schemas.mdc (from the free sample)
# Routers & schemas - One `APIRouter(prefix="/<plural-resource>", tags=["<resource>"])` per feature; mounted in `main.py` under `/api/v1`. - Endpoints are `async def`, thin: parse → call service → return schema. No SQL or business rules in routers. - Always declare `response_model` (or return-type annotation) and explicit `status_code` (`201` create, `204` delete). - Schema naming: `XCreate`, `XUpdate` (all fields optional, apply with `model_dump(exclude_unset=True)`), `XRead`. - Pydantic v2 only: `model_config = ConfigDict(from_attributes=True, extra="forbid")` on input models; `model_validate`, `model_dump`, `field_validator`, `model_validator`. Never v1 APIs (`.dict()`, `.parse_obj`, `class Config`, `orm_mode`, `@validator`). - Constrain inputs: `Annotated[str, StringConstraints(min_length=1, max_length=200)]`, `EmailStr`, `PositiveInt`. - Never return ORM objects without a response schema; never accept ORM models as input. - Pagination: `limit: int = Query(20, ge=1, le=100)`, `offset: int = Query(0, ge=0)`; return `Page[XRead]` with `items` and `total`. - Dependencies (`get_current_user`, `SessionDep`) are `Annotated` aliases defined in `deps.py`.