← ClaudeAtlas

fastapilisted

Use when building APIs with FastAPI. Covers dependency injection, Pydantic v2 validation, async database access, authentication, background tasks, and testing.
nimadorostkar/Claude-Skills-collection · ★ 27 · API & Backend · score 80
Install: claude install-skill nimadorostkar/Claude-Skills-collection
# FastAPI ## Purpose Build FastAPI services that use the framework's strengths — declarative validation and dependency injection — without falling into its two standard traps: blocking calls inside `async def`, and business logic in the route handler. ## When to Use - Building or reviewing a FastAPI application. - Structuring dependencies, authentication, and database sessions. - Diagnosing latency that appears only under concurrency. - Writing tests for FastAPI endpoints. ## Capabilities - Route and router organization. - Pydantic v2 models for request, response, and settings. - Dependency injection with scoped lifecycles. - Async SQLAlchemy sessions, correctly scoped per request. - Authentication and authorization dependencies. - Testing with `httpx.AsyncClient` and dependency overrides. ## Inputs - The API contract and the data layer. - Whether the workload is I/O-bound (nearly always) or CPU-bound. ## Outputs - Thin route handlers delegating to service functions. - Response models that control exactly what is serialized. - A test suite that overrides dependencies rather than mocking internals. ## Workflow 1. **Define the schemas** — Separate request, response, and internal models. Never return an ORM object directly; a `response_model` is your defense against leaking a password hash. 2. **Build the dependencies** — Database session, current user, feature flags. These are the injection points that make the app testable. 3. **Keep handlers thin** — Parse, author