FastAPI Skill for Claude Code: Official Best Practices
Makes Claude write modern FastAPI code the way the FastAPI project recommends, for anyone building or maintaining a FastAPI API.
- Installs
- 14.2K
- on skills.sh
- Stars
- 104.5K
- on GitHub
- Files
- 6
- besides SKILL.md
- Updated
- Nov 2026
- last repo commit
fastapi is a skill that ships inside the FastAPI repository itself. It makes Claude follow current FastAPI conventions: Annotated parameters and dependencies, return types instead of ORJSONResponse, routers that carry their own prefix and tags, and one function per HTTP operation. It also covers newer features such as app.frontend(), Server-Sent Events and built-in OpenTelemetry.
It triggers when you work on FastAPI APIs, Pydantic models, dependencies, streaming or frontend serving. It bundles six reference guides and no scripts. It tells Claude to use the fastapi CLI, and to prefer uv, Ruff, ty, Asyncer, SQLModel and HTTPX where they fit.
Good for
- Python developers building APIs with FastAPI and Pydantic
- Teams whose AI-written FastAPI code uses old patterns
- Developers adding SSE streaming, OpenTelemetry or a bundled frontend
Install fastapi
Claude Code
- 1
Copy this prompt.
Install the fastapi skill in Claude Code. Run this command: npx skills add https://github.com/fastapi/fastapi --skill fastapi Then check that it loaded and tell me how to use it.
- 2
Paste it into Claude Code. It shows the change and asks before running it.
Requires Node.js.
From its listing on skills.sh. Source.
What's in the skill
When it loads
FastAPI best practices and conventions. Use when working with FastAPI APIs, Pydantic models, dependencies, streaming responses including Server-Sent Events (SSE), and serving frontend apps. Keeps FastAPI code clean and up to date with the latest features and patterns.
Sections in SKILL.md
- Quick Reference
- Use the fastapi CLI
- Use Annotated
- Do not use Ellipsis for path operations or Pydantic models
- Return Type or Response Model
- Performance
- Including Routers
- Serve Frontend Apps
- OpenTelemetry
- Dependency Injection
- Async vs Sync path operations
- Streaming (JSON Lines, SSE, bytes)
- Tooling
- Other Libraries
- Do not use Pydantic RootModels
- Use one HTTP operation per function
Key facts
- Repository
- fastapi/fastapi
- Installs on skills.sh
- 14,162 as of 2026-11-02
- GitHub stars
- 104,535 for the whole fastapi/fastapi repo
- License
- MIT (repo LICENSE)
- Last repo commit
- 2026-11-01
What it includes
fastapi dev to develop, fastapi run for production
Prefers declaring the entrypoint under [tool.fastapi] in pyproject.toml. A file path is passed only when that is not possible or you ask.
Try: “Add a /items endpoint with a Pydantic model and a shared auth dependency using the fastapi skill.”
Runs code ·
fastapi CLIAnnotated for Path, Query, Header and Depends
Create a type alias for each dependency so it can be reused.
Annotated styleRequired fields have no ... default; use plain annotations
Do not use ... for required parameters or model fields, and do not use Pydantic RootModel.
No Ellipsis, no RootModelDeclare return types; response_model when the public shape differs
Return types validate, filter, document and serialize the response. ORJSONResponse and UJSONResponse are called deprecated.
Return types and response_modelPrefix, tags and dependencies go on the APIRouter
Set them on the router, not in include_router().
RoutersServe a built Vite, Astro, Vue or similar frontend
Use app.frontend("/", directory="dist") or router.frontend() instead of mounting StaticFiles by hand. API routes match first.
app.frontend()Native traces, metrics and logs via fastapi[standard]
Set FASTAPI_OTEL_AUTO_CONFIGURE=true, OTEL_SERVICE_NAME and OTEL_EXPORTER_OTLP_ENDPOINT, plus OTEL_EXPORTER_OTLP_HEADERS if the collector needs auth.
Network ·
OpenTelemetryAnnotated Depends, yield with scope, class dependencies
Apply shared dependencies at the router level. Details are in references/dependencies.md.
Dependency injectionPlain def by default; async only when sure nothing blocks
Regular def functions run in a threadpool. Blocking code inside async functions hurts performance.
Async vs syncJSON Lines, Server-Sent Events and byte streams
Use response_class=EventSourceResponse and yield items for SSE. ServerSentEvent gives control over event, id, retry and comment fields.
Streaminguv, Ruff, ty, Asyncer, SQLModel, HTTPX
Use uv for dependencies, Asyncer to mix blocking and async code, SQLModel over SQLAlchemy and HTTPX over Requests. The guide shows uv add asyncer.
Runs code ·
Other toolsDo not mix GET and POST in one function
Keeps concerns separate and code easier to organize.
One operation per function
From the official docs
Permissions
Low risk
The skill bundles no scripts, but it tells Claude to run the fastapi CLI and uv in your project.
What it can do
- Read your data
- Create and change things
- Delete things
- Read-only mode
Watch out for
It suggests running servers and installing packages
fastapi dev starts a local server and uv add installs a package. Approve these commands like any other. github.com
Security advisories
No published security advisories as of Nov 2, 2026.
Technical details
| Turning on read-only | No read-only mode is described. The skill bundles SKILL.md and 6 reference files and no scripts. |
|---|---|
| Talks to | OpenTelemetry settings point the app at a collector URL you set |
| Sign-in and keys | SKILL.md mentions OTEL_EXPORTER_OTLP_HEADERS for collector auth, which you set yourself. |
| Data retention | Not described in SKILL.md. |
| Scopes |
|
Questions
What does the FastAPI skill do?
It makes Claude write FastAPI code using the conventions in the FastAPI repo, such as Annotated dependencies, return types, router-level settings, SSE streaming and OpenTelemetry. It is meant to keep generated code current with new FastAPI versions.
How do I install the FastAPI skill?
Use the install box at the top of this page. It copies the skill folder from the fastapi/fastapi repo. The folder sits at fastapi/.agents/skills/fastapi.
Is it the official FastAPI skill?
The SKILL.md calls itself the "Official FastAPI skill", and it lives in the main FastAPI repository.
Does it need a specific FastAPI version?
SKILL.md states no version number. It covers features such as app.frontend() and EventSourceResponse, which are newer parts of FastAPI, so check your installed version supports them.
Does it work in Cursor, Codex or Claude.ai?
SKILL.md does not list clients. The skill is a folder of Markdown files, so check your tool's skills docs for how it loads skills.
Is it safe?
It bundles no scripts. It tells Claude to run commands such as fastapi dev and uv add in your project, so approve each command as you would any other. The fastapi dev server runs on localhost.
Information
updated Nov 2, 2026
- Repository
- fastapi/fastapi
- Folder
fastapi/.agents/skills/fastapi
Sources
Docs, issue trackers and discussions this page is built from.
Show all 3Hide
- fastapi SKILL.md · github.com
- references/other-tools.md · github.com
- references/dependencies.md · github.com