FastAPI and Pydantic v2 patterns for Depends, response models, async, errors, and auth. Load before any edit to a file importing fastapi, however small, and for FastAPI questions.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Fastapi Patterns?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ku5ic-fastapi-patterns)
---
name: fastapi-patterns
description: FastAPI and Pydantic v2 patterns for Depends, response models, async, errors, and auth. Load before any edit to a file importing fastapi, however small, and for FastAPI questions.
---
# FastAPI patterns
Default assumption: FastAPI 0.165 and Pydantic 2.14, per the FastAPI release notes and the Pydantic changelog. FastAPI 0.165 requires Starlette 1.6 or later.
A row applies when the FastAPI, Pydantic, or Starlette version the project pins, in `pyproject.toml`, a requirements file, or the lockfile, is at least the row's version.
## Reference files
Loading this skill isn't enough. Before your next edit, read the file of every row that matches it. The rules live in those files, and this one only points at them.
| Before | Read |
| ---------------------------------------------------------------------------- | -------------------------------------------------------- |
| Writing FastAPI code, or raising the FastAPI, Pydantic, or Starlette version | [reference/upgrades.md](reference/upgrades.md) |
| Writing, changing, or reviewing FastAPI code | [reference/anti-patterns.md](reference/anti-patterns.md) |
| Writing a route, a dependency, a schema, an error handler, or auth | [reference/practices.md](reference/practices.md) |
| Configuring ruff or mypy for a FastAPI app | [reference/tooling.md](reference/tooling.md) |