FastAPI best practices and conventions. An agent skill from Open-TutorAi/open-tutor-ai-CE.

BSD-3-ClauseAuto-check passedBackend & APIs

Install Fastapi

skills CLI
$ npx skills add Open-TutorAi/open-tutor-ai-CE --skill fastapi -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Open-TutorAi/open-tutor-ai-CE fastapi --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Open-TutorAi/open-tutor-ai-CE.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/fastapi .claude/skills/fastapi && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
fastapi
GitHub stars
108
Used in
2 other repos
Token cost
~2.6k tokens
SKILL.md length
755 words
Files
4 (incl. references)
Skills in repo
1
Repo updated
First seen
Licence
BSD-3-Clause

At a glance

FastAPI best practices and conventions. An agent skill from Open-TutorAi/open-tutor-ai-CE.

  • Working with FastAPI APIs and Pydantic models for them
  • SKILL.md covers Use the fastapi CLI, Use Annotated, Do not use Ellipsis for path… and Return Type or Response Model, plus 9 more sections
  • Calls fastapi
  • Tasks that involve Backend development

What it does

Fastapi is an agent skill from Open-TutorAi/open-tutor-ai-CE. FastAPI best practices and conventions. Use when working with FastAPI APIs and Pydantic models for them. Keeps FastAPI code clean and up to date with the latest features and patterns, updated with new versions. Write new code or refactor and update old code.

Its SKILL.md is about 2.6k tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files, including reference files (for example `references/dependencies.md`, `references/other-tools.md` and `references/streaming.md`).

It sits in Backend & APIs, covering Backend development. It works with FastAPI, Pydantic, Ollama and OpenAI. The repository describes itself as: An open-source project designed to provide an educational and collaborative AI-powered platform. The licence is BSD-3-Clause.

When your agent uses it

  • Working with FastAPI APIs and Pydantic models for them
  • Tasks that involve Backend development

Example prompts

  • “/fastapi”

Requirements

  • Python 3

What it can do on your machine

Read from SKILL.md and the folder at commit 196c547. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • fastapi

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Fastapi loads about 2.6k tokens when it runs, and up to ~4.4k if it reads all its reference files. Until then it costs about 67 tokens; SKILL.md has 755 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~67
When it runs · the whole SKILL.md, loaded when a task matches
~2.6k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from Open-TutorAi/open-tutor-ai-CE at commit 196c547, republished under its BSD-3-Clause licence (© Open-TutorAi). 755 words, ~2,597 tokens.

Download SKILL.mdSave it as .claude/skills/fastapi/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
fastapi
description
FastAPI best practices and conventions. Use when working with FastAPI APIs and Pydantic models for them. Keeps FastAPI code clean and up to date with the latest features and patterns, updated with new versions. Write new code or refactor and update old code.

FastAPI

Official FastAPI skill to write code with best practices, keeping up to date with new versions and features.

Use the fastapi CLI

Run the development server on localhost with reload:

bash
fastapi dev

Run the production server:

bash
fastapi run
Add an entrypoint in pyproject.toml

FastAPI CLI will read the entrypoint in pyproject.toml to know where the FastAPI app is declared.

toml
[tool.fastapi]
entrypoint = "my_app.main:app"
Use fastapi with a path

When adding the entrypoint to pyproject.toml is not possible, or the user explicitly asks not to, or it's running an independent small app, you can pass the app file path to the fastapi command:

bash
fastapi dev my_app/main.py

Prefer to set the entrypoint in pyproject.toml when possible.

Use Annotated

Always prefer the Annotated style for parameter and dependency declarations.

It keeps the function signatures working in other contexts, respects the types, allows reusability.

In Parameter Declarations

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"}

instead of:

python
# DO NOT DO THIS
@app.get("/items/{item_id}")
async def read_item(
    item_id: int = Path(ge=1, description="The item ID"),
    q: str | None = Query(default=None, max_length=50),
):
    return {"message": "Hello World"}
For Dependencies

Use Annotated for dependencies with Depends().

Unless asked not to, create a new type alias for the dependency to allow re-using 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"}

instead of:

python
# DO NOT DO THIS
@app.get("/items/")
async def read_item(current_user: dict = Depends(get_current_user)):
    return {"message": "Hello World"}

Do not use Ellipsis for path operations or Pydantic models

Do not use ... as a default value for required parameters, it's not needed and not recommended.

Do this, without Ellipsis (...):

python
from typing import Annotated

from fastapi import FastAPI, Query
from pydantic import BaseModel, Field


class Item(BaseModel):
    name: str
    description: str | None = None
    price: float = Field(gt=0)


app = FastAPI()


@app.post("/items/")
async def create_item(item: Item, project_id: Annotated[int, Query()]): ...

instead of this:

python
# DO NOT DO THIS
class Item(BaseModel):
    name: str = ...
    description: str | None = None
    price: float = Field(..., gt=0)


app = FastAPI()


@app.post("/items/")
async def create_item(item: Item, project_id: Annotated[int, Query(...)]): ...

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 BaseModel

app = FastAPI()


class Item(BaseModel):
    name: str
    description: str | None = None


@app.get("/items/me")
async def get_item() -> Item:
    return Item(name="Plumbus", description="All-purpose home device")

Important: Return types or response models are what filter data ensuring no sensitive information is exposed. And they are used to serialize data with Pydantic (in Rust), this is the main idea that can increase response performance.

The return type doesn't have to be a Pydantic model, it could be a different type, like a list of integers, or a dict, etc.

When to use response_model instead

If the return type is not the same as the type that you want to use to validate, filter, or serialize, use the response_model parameter on the decorator instead.

python
from typing import Any

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()


class Item(BaseModel):
    name: str
    description: str | None = None


@app.get("/items/me", response_model=Item)
async def get_item() -> Any:
    return {"name": "Foo", "description": "A very nice Item"}

This can be particularly useful when filtering data to expose only the public fields and avoid exposing sensitive information.

python
from typing import Any

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()


class InternalItem(BaseModel):
    name: str
    description: str | None = None
    secret_key: str


class Item(BaseModel):
    name: str
    description: str | None = None


@app.get("/items/me", response_model=Item)
async def get_item() -> Any:
    item = InternalItem(
        name="Foo", description="A very nice Item", secret_key="supersecret"
    )
    return item

Performance

Do not use ORJSONResponse or UJSONResponse, they are deprecated.

Instead, declare a return type or response model. Pydantic will handle the data serialization on the Rust side.

Including Routers

When declaring routers, prefer to add router level parameters like prefix, tags, etc. to the router itself, instead of in include_router().

Do this:

python
from fastapi import APIRouter, FastAPI

app = FastAPI()

router = APIRouter(prefix="/items", tags=["items"])


@router.get("/")
async def list_items():
    return []


# In main.py
app.include_router(router)

instead of this:

python
# DO NOT DO THIS
from fastapi import APIRouter, FastAPI

app = FastAPI()

router = APIRouter()


@router.get("/")
async def list_items():
    return []


# In main.py
app.include_router(router, prefix="/items", tags=["items"])

There could be exceptions, but try to follow this convention.

Apply shared dependencies at the router level via dependencies=[Depends(...)].

Dependency Injection

See the dependency injection reference for detailed patterns including yield with scope, and class dependencies.

Use dependencies when the logic can't be declared in Pydantic validation, depends on external resources, needs cleanup (with yield), or is shared across endpoints.

Apply shared dependencies at the router level via dependencies=[Depends(...)].

Show full SKILL.md (288 more words)Show less

Async vs Sync path operations

Use async path operations only when fully certain that the logic called inside is compatible with async and await (it's called with await) or that doesn't block.

python
from fastapi import FastAPI

app = FastAPI()


# Use async def when calling async code
@app.get("/async-items/")
async def read_async_items():
    data = await some_async_library.fetch_items()
    return data


# Use plain def when calling blocking/sync code or when in doubt
@app.get("/items/")
def read_items():
    data = some_blocking_library.fetch_items()
    return data

In case of doubt, or by default, use regular def functions, those will be run in a threadpool so they don't block the event loop.

The same rules apply to dependencies.

Make sure blocking code is not run inside of async functions. The logic will work, but will damage the performance heavily.

When needing to mix blocking and async code, see Asyncer in the other tools reference.

Streaming (JSON Lines, SSE, bytes)

See the streaming reference for JSON Lines, Server-Sent Events (EventSourceResponse, ServerSentEvent), and byte streaming (StreamingResponse) patterns.

Tooling

See the other tools reference for details on uv, Ruff, ty for package management, linting, type checking, formatting, etc.

Other Libraries

See the other tools reference for details on other libraries:

  • Asyncer for handling async and await, concurrency, mixing async and blocking code, prefer it over AnyIO or asyncio.
  • SQLModel for working with SQL databases, prefer it over SQLAlchemy.
  • HTTPX for interacting with HTTP (other APIs), prefer it over Requests.

Do not use Pydantic RootModels

Do not use Pydantic RootModel, instead use regular type annotations with Annotated and Pydantic validation utilities.

For example, for a list with validations you could do:

python
from typing import Annotated

from fastapi import Body, FastAPI
from pydantic import Field

app = FastAPI()


@app.post("/items/")
async def create_items(items: Annotated[list[int], Field(min_length=1), Body()]):
    return items

instead of:

python
# DO NOT DO THIS
from typing import Annotated

from fastapi import FastAPI
from pydantic import Field, RootModel

app = FastAPI()


class ItemList(RootModel[Annotated[list[int], Field(min_length=1)]]):
    pass


@app.post("/items/")
async def create_items(items: ItemList):
    return items

FastAPI supports these type annotations and will create a Pydantic TypeAdapter for them, so that types can work as normally and there's no need for the custom logic and types in RootModels.

Use one HTTP operation per function

Don't mix HTTP operations in a single function, having one function per HTTP operation helps separate concerns and organize the code.

Do this:

python
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()


class Item(BaseModel):
    name: str


@app.get("/items/")
async def list_items():
    return []


@app.post("/items/")
async def create_item(item: Item):
    return item

instead of this:

python
# DO NOT DO THIS
from fastapi import FastAPI, Request
from pydantic import BaseModel

app = FastAPI()


class Item(BaseModel):
    name: str


@app.api_route("/items/", methods=["GET", "POST"])
async def handle_items(request: Request):
    if request.method == "GET":
        return []

© Open-TutorAi, BSD-3-Clause. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (references) in .agents/skills/fastapi of Open-TutorAi/open-tutor-ai-CE.

  • SKILL.md
  • references/dependencies.md
  • references/other-tools.md
  • references/streaming.md

Open the folder on GitHubat commit 196c547

Used in 2 other repositories

We found 2 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 2 other GitHub owners. This page covers the copy in Open-TutorAi/open-tutor-ai-CE, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Fastapi next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Fastapi compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Fastapi this skillOpen-TutorAi/open-tutor-ai-CE1082 repos~2.6kAutomated safety check: PassBSD-3-Clause
Fastcrudbenavlabs/fastcrud1.6k—~5kAutomated safety check: PassMIT
API Surface Reviewpolarsource/polar10k—~1.3kAutomated safety check: PassMIT
Fastapi Appccplugins/awesome-claude-code-plugins967—~1.1kAutomated safety check: NotesApache-2.0
Framework Migration AssistantArabelaTso/Skills-4-SE253—~1.9kAutomated safety check: PassApache-2.0
Fastapi Prodavila7/claude-code-templates32k7 repos~1.6kAutomated safety check: PassMIT

Similar skills

  • Fastcrud

    benavlabs/fastcrud

    A skill your agent uses when building or modifying CRUD endpoints with FastCRUD (the fastcrud PyPI package) in a FastAPI project — covers FastCRUD, crudrouter, EndpointCreator, FilterConfig…

    1.6k GitHub stars~5k tokensUpdated 13 days ago
    Backend & APIsAuto-check passed
  • API Surface Review

    polarsource/polar

    Review changes to Polar's API contract — Pydantic schemas, FastAPI endpoints, OpenAPI output and the generated SDKs.

    10k GitHub stars~1.3k tokensUpdated today
    Backend & APIsAuto-check passed
  • Fastapi App

    ccplugins/awesome-claude-code-plugins

    Bootstrap a new FastAPI backend with async SQLAlchemy 2.0, asyncpg, Alembic, Pydantic v2, and no deprecated APIs.

    967 GitHub stars~1.1k tokensUpdated 1 mo ago
    Backend & APIsAuto-check: notes
  • Framework Migration Assistant

    ArabelaTso/Skills-4-SE

    Automatically migrate Python web applications between frameworks (Flask → FastAPI, Django → FastAPI).

    253 GitHub stars~1.9k tokensUpdated 1 mo ago
    Backend & APIsAuto-check passed
  • Fastapi Pro

    davila7/claude-code-templates

    Build high-performance async APIs with FastAPI, SQLAlchemy 2.0, and Pydantic V2.

    32k GitHub starsUsed in 7 repos~1.6k tokens
    Backend & APIsAuto-check passed
  • FastAPI Expert

    Jeffallan/claude-skills

    Builds async Python APIs with FastAPI and Pydantic V2, covering endpoints, JWT authentication, async SQLAlchemy, WebSockets and pytest checks against the OpenAPI docs.

    12k GitHub stars~1.8k tokensUpdated 4 days ago
    Backend & APIsAuto-check passed

Categories

Questions about Fastapi

What does Fastapi do?

FastAPI best practices and conventions. An agent skill from Open-TutorAi/open-tutor-ai-CE. Fastapi is an agent skill from Open-TutorAi/open-tutor-ai-CE. FastAPI best practices and conventions.

When should I use Fastapi?

Fastapi fits situations like: working with FastAPI APIs and Pydantic models for them; tasks that involve Backend development.

How do I install Fastapi in Claude Code?

Run `npx skills add Open-TutorAi/open-tutor-ai-CE --skill fastapi -a claude-code`. Or copy the skill folder (.agents/skills/fastapi in Open-TutorAi/open-tutor-ai-CE) into .claude/skills/fastapi in your project. Claude Code loads it when a task matches its description.

How do I install Fastapi in Codex?

Run `npx skills add Open-TutorAi/open-tutor-ai-CE --skill fastapi -a codex`. Or copy the skill folder (.agents/skills/fastapi in Open-TutorAi/open-tutor-ai-CE) into .agents/skills/fastapi in your project. Codex loads it when a task matches its description.

Can I use Fastapi in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Open-TutorAi/open-tutor-ai-CE --skill fastapi -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/fastapi, .gemini/skills/fastapi, .github/skills/fastapi and .opencode/skills/fastapi in your project.

What does Fastapi need to run?

Going by SKILL.md and its folder, Fastapi needs the command-line tools its instructions call (fastapi). Our summary lists: Python 3.

Does Fastapi access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Fastapi safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Fastapi use?

Fastapi is published under the BSD-3-Clause licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Fastapi use?

About 2.6k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1.8k tokens, read only when the agent opens those files.

What are the alternatives to Fastapi?

Skills that share tags, products or a category with Fastapi: Fastcrud (benavlabs/fastcrud, 1.6k stars), API Surface Review (polarsource/polar, 10k stars), Fastapi App (ccplugins/awesome-claude-code-plugins, 967 stars) and Framework Migration Assistant (ArabelaTso/Skills-4-SE, 253 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Fastapi?

Open-TutorAi (a GitHub organization) maintains it in Open-TutorAi/open-tutor-ai-CE, which has 108 GitHub stars. The repository was last updated on June 26, 2026.

Source: Open-TutorAi/open-tutor-ai-CE on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.