/stackwise:fastapi-expertfrom stackwise
Builds and debugs FastAPI services with Pydantic v2, async SQLAlchemy 2.0, OAuth2/JWT auth, and async test suites using httpx. Scaffolds endpoints, designs schemas, wires dependency injection, and migrates Pydantic v1 idioms.
Ships in stackwise. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Turns Claude into a senior Python backend engineer who ships FastAPI 0.115+ services with Pydantic v2 idioms, async SQLAlchemy 2.0, and a uv/ruff/mypy toolchain.
.dict(), @validator, class Config) to v2AsyncClient and dependency overridespyproject.toml (dependency versions, tool config for ruff/mypy/pytest), the app factory / main.py, existing routers, and the session/settings modules. Match the project's layout (routers vs. flat, repository layer vs. inline queries) before writing anything. Confirm Pydantic is v2 and SQLAlchemy is 2.0 async - never mix v1 idioms in.Annotated dependencies, Pydantic v2 schemas (separate Create/Update/Read models), and async def only where the body actually awaits. Register new routers on the app. Prefer editing existing modules over new files.uv run ruff check . && uv run ruff format --check .; fix all reported issues and re-run until clean.uv run mypy .; fix all reported issues and re-run until clean. Do not silence errors with blanket # type: ignore - fix the types.AsyncClient with ASGITransport and app.dependency_overrides for DB/auth (see references/testing.md). Run uv run pytest -q; fix every failure and re-run until all tests pass.uv run uvicorn app.main:app --reload or uv run fastapi dev), hit the changed endpoints with curl (including one invalid payload to confirm the 422 shape), and check /docs renders the new routes. Fix anything broken and re-verify until the live behavior matches the spec.Load detailed guidance only when the task needs it:
| Topic | Reference | Load When |
|---|---|---|
| Pydantic v2 schemas, validators, serialization | references/pydantic-v2.md | Writing/changing any BaseModel; migrating v1 code; custom validation or serialization; settings via pydantic-settings |
| Async SQLAlchemy 2.0 engine, sessions, queries | references/async-sqlalchemy.md | Any DB model, session wiring, query, relationship loading, or MissingGreenlet/lazy-load errors |
| Dependency injection, lifespan, background tasks | references/dependencies-di.md | Writing Depends chains, yield dependencies, app startup/shutdown state, BackgroundTasks vs. task queue decisions |
| OAuth2 password flow + JWT auth | references/auth.md | Login/token endpoints, protected routes, password hashing, current-user dependencies, scopes/roles |
| pytest + httpx AsyncClient testing | references/testing.md | Writing or fixing tests, dependency overrides, test DB fixtures, async test config |
Pydantic v2 schema trio with ORM reads (never .from_orm() / class Config):
from pydantic import BaseModel, ConfigDict, EmailStr
class UserCreate(BaseModel):
email: EmailStr
password: str
class UserRead(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: int
email: EmailStr
user = UserRead.model_validate(db_user) # not User.from_orm(db_user)
payload = user.model_dump(mode="json") # not user.dict()
Annotated dependencies, aliased once, reused everywhere:
from typing import Annotated
from fastapi import Depends
from sqlalchemy.ext.asyncio import AsyncSession
async def get_db() -> AsyncIterator[AsyncSession]:
async with async_session_factory() as session:
yield session
DbDep = Annotated[AsyncSession, Depends(get_db)]
CurrentUser = Annotated[User, Depends(get_current_user)]
@router.post("/items", status_code=201, response_model=ItemRead)
async def create_item(data: ItemCreate, db: DbDep, user: CurrentUser) -> Item:
...
Lifespan context instead of deprecated @app.on_event:
from contextlib import asynccontextmanager
@asynccontextmanager
async def lifespan(app: FastAPI):
app.state.engine = create_async_engine(settings.database_url)
yield
await app.state.engine.dispose()
app = FastAPI(lifespan=lifespan)
Async query with eager loading (no lazy loads after await):
from sqlalchemy import select
from sqlalchemy.orm import selectinload
result = await db.execute(
select(Order).options(selectinload(Order.items)).where(Order.user_id == user.id)
)
orders = result.scalars().all()
.dict(), .json(), parse_obj(), from_orm(), @validator, class Config, update_forward_refs(). Use model_dump(), model_dump_json(), model_validate(), @field_validator / @model_validator, ConfigDict, model_rebuild(). Mixing generations breaks silently or at import time.async def endpoints - sync DB drivers, requests, time.sleep block the event loop for every request. Either make the call truly async or declare the endpoint def so FastAPI runs it in the threadpool.MissingGreenlet on implicit IO. Eager-load with selectinload/joinedload in the query, and create the session factory with expire_on_commit=False so committed objects stay readable.Depends(get_db) at import time - sessions must be per-request via a yield dependency; a shared session breaks under concurrency and leaks transactions.BackgroundTasks for heavy or must-not-lose work - it runs in-process after the response; a crash or deploy loses it. Use it for fire-and-forget (emails, cache warm); use a task queue (arq/Celery/SQS worker) for retries, long jobs, or anything durable.exp check, or returning 403 instead of 401 with WWW-Authenticate: Bearer on missing credentials.TestClient for an async app with overrides left dirty - use httpx AsyncClient(transport=ASGITransport(app=app)), set app.dependency_overrides in fixtures, and always clear them in teardown so tests stay isolated.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
fastapi, pydantic-v2, sqlalchemy-async, oauth2-jwt, async-testing, uv
Other plugins' skills for the same job
npx claudepluginhub aarvion-ai/stackwise-skills --plugin stackwise16 skills in this plugin
/docker-expertUse when working with Dockerfile, docker-compose.yml, .dockerignore, or multi-stage builds. Build, debug, secure, and optimize Docker 27+ images and Docker Compose services./engineering-rulesUse when writing, modifying, or reviewing code in any language or framework. Applies to every code task in this repo and every code sample inside a skill: new features, bug fixes, refactors, generated snippets, tests, scripts, docs with code. Enforces the seven repo-wide rules: reusable code, maintainable structure, top-notch readability, no AI slop, dead code removal, why-only comments, no em dashes. Invoke for implementing changes, self-reviewing a diff, cleaning up generated code, writing reference examples, or reviewing a PR./fastify-expertUse when building or debugging Fastify services - files importing fastify, fastify-plugin, @fastify/* packages, or @sinclair/typebox; projects with a Fastify app factory, route plugins, or app.inject() tests; mentions of Fastify 5, encapsulation, decorators, hooks, TypeBox type provider, @fastify/jwt, or pino logging. Builds typed REST APIs, wires plugins and encapsulation correctly, adds JSON Schema validation and JWT auth, integrates Prisma/Drizzle/pg, writes inject-based tests. Invoke for new routes/plugins, schema-first request typing, auth flows, error handling, database wiring, and test suites./flutter-expertUse when working in a Flutter project - pubspec.yaml, *.dart files, lib/main.dart, analysis_options.yaml, android/ + ios/ folders, or mentions of Flutter, Dart, widgets, Riverpod, Bloc, or GoRouter. Builds features, state management, navigation, platform channels/FFI, and tests for Flutter 3.3x / Dart 3.x apps. Invoke for adding screens or widgets, wiring Riverpod or Bloc state, GoRouter navigation and deep links, fixing jank or excess rebuilds, calling native code, writing widget/integration tests, and release/flavor setup./go-expertUse when writing or reviewing Go backend services - go.mod, *.go files, net/http handlers, pgx/sqlc database code, goroutines, context.Context plumbing, or failing `go test` runs. Builds HTTP APIs on the Go 1.22+ stdlib router, fixes error-wrapping and context-cancellation bugs, designs leak-free goroutine lifecycles with errgroup, and wires pgx/sqlc data layers. Invoke for HTTP routing, error handling, concurrency, database access, slog logging, project layout, or table-driven tests./jetpack-compose-expertUse when working in a native Android Jetpack Compose project - build.gradle.kts with androidx.compose BOM or org.jetbrains.kotlin.plugin.compose, *.kt files containing @Composable functions, MainActivity with setContent, or mentions of Compose, Material 3, recomposition, ViewModel, StateFlow, Hilt, Room, or Navigation Compose. Builds screens, state management, navigation, DI, and tests for Kotlin 2.x / Compose BOM 2026 apps. Invoke for adding composable screens, fixing recomposition or jank, wiring ViewModel + StateFlow collection, type-safe navigation routes, Hilt setup, Room + Flow data layers, side-effect handling, and Compose UI tests.