FastAPI's own conventions, kept current.
Best practices from the FastAPI project for APIs, Pydantic models, dependencies and streaming responses, so the code your agent writes uses the latest features and patterns.
Install this skill
npx skills add https://github.com/fastapi/fastapi --skill fastapiRuns the open-source skills CLI in your own terminal. It asks which agents to add the skill to. Read what it tells your agent to do before you install it.
Install for your agent
Claude Code
Run this in your project
npx skills add https://github.com/fastapi/fastapi --skill fastapi -a claude-codeAdd
-gto install it for every project instead.Or ask Claude Code to do it
Install the "fastapi" skill from https://github.com/fastapi/fastapi for Claude Code. Copy the skill folder (the one containing SKILL.md, with any scripts or reference files next to it) into .claude/skills/ in this project. Before copying, show me the SKILL.md and list any scripts it includes, and wait for me to confirm.
Or copy the folder yourself
Unzip the download into
.claude/skills/for this project, or~/.claude/skills/for all your projects.Picked up in the current session, no restart needed.
Claude Code skills docsClaude.ai
Upload the ZIP
- In Settings > Capabilities, turn on Code execution and file creation.
- Go to Customize > Skills, press +, then Create skill.
- Choose Upload a skill and pick the ZIP you downloaded.
Free, Pro and Max plans. On Team and Enterprise, an owner turns skills on in Organization settings first.
Claude.ai skills docsChatGPT
Upload the ZIP
- Open Skills in ChatGPT and select Create.
- Select Upload from your computer and pick the ZIP you downloaded.
- Wait for ChatGPT's safety scan. A skill marked Needs Review asks you to check it before use.
Skills that rely on scripts or a terminal may not work unchanged in ChatGPT.
ChatGPT skills docsCodex
Run this in your project
npx skills add https://github.com/fastapi/fastapi --skill fastapi -a codexAdd
-gto install it for every project instead.Or ask Codex to do it
Install the "fastapi" skill from https://github.com/fastapi/fastapi for Codex. Copy the skill folder (the one containing SKILL.md, with any scripts or reference files next to it) into .agents/skills/ in this project. Before copying, show me the SKILL.md and list any scripts it includes, and wait for me to confirm.
Or copy the folder yourself
Unzip the download into
.agents/skills/for this project, or~/.agents/skills/for all your projects.Restart Codex if the skill does not show up.
Codex skills docsCursor
Run this in your project
npx skills add https://github.com/fastapi/fastapi --skill fastapi -a cursorAdd
-gto install it for every project instead.Or ask Cursor to do it
Install the "fastapi" skill from https://github.com/fastapi/fastapi for Cursor. Copy the skill folder (the one containing SKILL.md, with any scripts or reference files next to it) into .cursor/skills/ in this project. Before copying, show me the SKILL.md and list any scripts it includes, and wait for me to confirm.
Or copy the folder yourself
Unzip the download into
.cursor/skills/for this project, or~/.cursor/skills/for all your projects.Run it by typing / and the skill name in chat.
Cursor skills docsGitHub Copilot
Run this in your project
npx skills add https://github.com/fastapi/fastapi --skill fastapi -a github-copilotAdd
-gto install it for every project instead.Or ask GitHub Copilot to do it
Install the "fastapi" skill from https://github.com/fastapi/fastapi for GitHub Copilot. Copy the skill folder (the one containing SKILL.md, with any scripts or reference files next to it) into .github/skills/ in this project. Before copying, show me the SKILL.md and list any scripts it includes, and wait for me to confirm.
Or copy the folder yourself
Unzip the download into
.github/skills/for this project, or~/.copilot/skills/for all your projects.Works in Copilot CLI, the cloud agent and agent mode in VS Code and JetBrains.
GitHub Copilot skills docsAntigravity
Run this in your project
npx skills add https://github.com/fastapi/fastapi --skill fastapi -a antigravityAdd
-gto install it for every project instead.Or ask Antigravity to do it
Install the "fastapi" skill from https://github.com/fastapi/fastapi for Antigravity. Copy the skill folder (the one containing SKILL.md, with any scripts or reference files next to it) into .agents/skills/ in this project. Before copying, show me the SKILL.md and list any scripts it includes, and wait for me to confirm.
Antigravity skills docsOr copy the folder yourself
Unzip the download into
.agents/skills/for this project, or~/.gemini/config/skills/for all your projects.Gemini CLI
Run this in your project
npx skills add https://github.com/fastapi/fastapi --skill fastapi -a gemini-cliAdd
-gto install it for every project instead.Or ask Gemini CLI to do it
Install the "fastapi" skill from https://github.com/fastapi/fastapi for Gemini CLI. Copy the skill folder (the one containing SKILL.md, with any scripts or reference files next to it) into .gemini/skills/ in this project. Before copying, show me the SKILL.md and list any scripts it includes, and wait for me to confirm.
Or copy the folder yourself
Unzip the download into
.gemini/skills/for this project, or~/.gemini/skills/for all your projects.Run /skills to check it was found.
Gemini CLI skills docs
- Installs
- 9.6K via skills.sh
- GitHub
- 102.3K stars ↗
- Last updated
- 1 Sept 2026
- Licence
- MIT
Security checks
Run by independent scanners and published on skills.sh. Their results, not a Viberation review.
- 1 Mar 2026
Gen Agent Trust Hub Pass
This skill provides comprehensive best practices for FastAPI development, emphasizing the use of modern Python features like Type Hints and Pydantic models. It explicitly promotes security by instructing the agent to use response models to filter and protect sensitive data. All recommended tools and commands are standard for the FastAPI ecosystem.
- 18 Mar 2026
Socket Pass
No alerts
- 1 Mar 2026
Snyk Pass
Risk: LOW · No issues
- 1 Mar 2026
Runlayer Pass
4 files scanned · No issues
- 16 Apr 2026
ZeroLeaks Pass
Score: 93/100 · 2 sections analyzed
What's inside (7 files)
references/dependencies.md3.3K charsreferences/other-tools.md1.5K charsreferences/path-operations.md1.6K charsreferences/pydantic.md1.8K charsreferences/responses.md1.9K charsreferences/streaming.md2.6K charsSKILL.md10.1K chars
SKILL.md, first part. Shown as plain text.
---
name: fastapi
description: 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.
---
# FastAPI
Official FastAPI skill to write code with best practices, keeping up to date with new versions and features.
## Quick Reference
* Serve frontend apps: use `app.frontend()` or `router.frontend()` for built frontend assets; see [Serve Frontend Apps](#serve-frontend-apps).
* Server-Sent Events (SSE): use `response_class=EventSourceResponse` and `yield`; see [Streaming](#streaming-json-lines-sse-bytes) and [the streaming reference](references/streaming.md).
* JSON Lines and byte streaming: see [the streaming reference](references/streaming.md).
* Dependencies: use `Annotated[..., Depends(...)]`; see [Dependency Injection](#dependency-injection) and [the dependency injection reference](references/dependencies.md) for `yield`, scopes, and class dependencies.
* Response models: prefer return types; use `response_model` when the public response schema differs from the internal return value; see [the response reference](references/responses.md).
* Pydantic models: do not use ellipsis or `RootModel`; see [the Pydantic reference](references/pydantic.md).
* Routing: declare router-level prefix, tags, and shared dependencies on the `APIRouter`; see [the path operation reference](references/path-operations.md).
* Tooling and related libraries: use uv, Ruff, ty, Asyncer, SQLModel, and HTTPX when applicable; see [the other tools reference](references/other-tools.md).
## Use the `fastapi` CLI
Run the development server on localhost with reload:
```bash
fastapi dev
```
Run the production server:
```bash
fastapi run
```
Prefer declaring the entrypoint in `pyproject.toml`:
```toml
[tool.fastapi]
entrypoint = "my_app.main:app"
```
When adding the entrypoint is not possible, or the user explicitly asks not to, pass the app file path:
```bash
fastapi dev my_app/main.py
```
## Use `Annotated`
Always prefer the `Annotated` style for parameter and dependency declarations. It keeps function signatures working in other contexts, respects the types, and allows reusability.
Use `Annotated` for parameter declarations, including `Path`, `Query`, `Header`, etc.:
```python
from typing import Annotated
from fastapi import FastAPI, Path, Query
app = FastAPI()
@app.get("/items/{item_id}")
async def read_item(
item_id: Annotated[int, Path(ge=1, description="The item ID")],
q: Annotated[str | None, Query(max_length=50)] = None,
):
return {"message": "Hello World"}
```
Use `Annotated` for dependencies with `Depends()`. Unless asked not to, create a new type alias for the dependency to allow reusing it:
```python
from typing import Annotated
from fastapi import Depends, FastAPI
app = FastAPI()
def get_current_user():
return {"username": "johndoe"}
CurrentUserDep = Annotated[dict, Depends(get_current_user)]
@app.get("/items/")
async def read_item(current_user: CurrentUserDep):
return {"message": "Hello World"}
```
## Do not use Ellipsis for *path operations* or Pydantic models
Do not use `...` as a default value for required parameters or model fields. It's not needed and not recommended.
```python
from typing import Annotated
from fastapi import FastAPI, Query
from pydantic import BaseModel, Field
app = FastAPI()
class Item(BaseModel):
name: str
description: str | None = None
price: float = Field(gt=0)
@app.post("/items/")
async def create_item(item: Item, project_id: Annotated[int, Query()]):
return item
```
See [the Pydantic reference](references/pydantic.md) for more details.
## Return Type or Response Model
When possible, include a return type. It will be used to validate, filter, document, and serialize the response.
```python
from fastapi import FastAPI
from pydantic import Key info
- Pricing
- Open source
- Category
- Skills
Related reading
- Fundamentals
Row level security is the security boundary
If your database rows are protected by a check in your application code, they are not protected. Anything holding a key can talk to the database directly, an…
Expert