rules/python/fastapi.md
Use these rules for FastAPI projects alongside the general Python rules.
create_app().async def for endpoints that perform I/O.requests, sync SQLAlchemy sessions, or blocking file/network operations from async routes.@router.get("/users/{user_id}")
async def get_user(
user_id: str,
db: AsyncSession = Depends(get_db),
current_user: User = Depends(get_current_user),
):
...
Do not create SessionLocal() or long-lived clients inside route handlers.
response_model on endpoints that return application data.Depends.app.dependency_overrides after tests.See skill: fastapi-patterns.