fastapi

fastapi is a skill for Claude Code, Codex from mfmezger/ai_agent_dotfiles. It costs 87 tokens per session (1,212 once invoked), scanned A, original, MIT.

A set of conventions for building FastAPI services, Python applications that expose web APIs.

In plain words
What is it for?
Use it when creating or changing FastAPI endpoints, routers, validation schemas, dependencies, streaming endpoints, or API tests.
Why use it?
It provides a consistent structure for routes, request and response data, dependencies, application startup, and API tests.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/mfmezger/ai_agent_dotfiles/fastapi
Any agent
npx skills add mfmezger/ai_agent_dotfiles --skill fastapi
Clone the repo
git clone --depth 1 https://github.com/mfmezger/ai_agent_dotfiles

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for fastapi

README.md
[![agentmods](https://agentmods.dev/badge/skills/mfmezger/ai_agent_dotfiles/fastapi.svg)](https://agentmods.dev/skills/mfmezger/ai_agent_dotfiles/fastapi)
Your own site
<a href="https://agentmods.dev/skills/mfmezger/ai_agent_dotfiles/fastapi"><img src="https://agentmods.dev/badge/skills/mfmezger/ai_agent_dotfiles/fastapi.svg" alt="Measured on agentmods" height="20"></a>
Per session 87 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,212 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00087 $0.01212
Opus 5 $0.00044 $0.00606
Sonnet 5 $0.00017 $0.00242
Haiku 4.5 $0.00009 $0.00121

Measured 4d ago against content hash 0733a98072a8, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

fastapi scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

shared/skills/fastapi/SKILL.md · 167 lines

How it starts

The opening of the file, as written. The whole thing — 167 lines — stays where its author put it; the contents beside it link to each section on GitHub.

FastAPI Conventions

Assume the general Python tooling conventions from the python-stack skill. This skill only covers FastAPI-specific patterns.

App Layout

Prefer a small, explicit structure:

src/<package>/
  main.py
  routers/
    __init__.py
    items.py
  dependencies.py
  schemas.py
  models.py
  settings.py
  • Keep the ASGI app in main.py
  • Group path operations into routers by bounded area
  • Put shared dependency helpers in dependencies.py
  • Keep request/response schemas separate from persistence models when that improves clarity

Running the App

Prefer the FastAPI CLI over invoking Uvicorn directly.

uv run fastapi dev src/<package>/main.py
uv run fastapi run src/<package>/main.py

If the project has a stable app entrypoint, prefer configuring it in pyproject.toml:

[tool.fastapi]
entrypoint = "src.<package>.main:app"

Path Operations

Use one HTTP operation per function. Do not collapse multiple methods into a single handler.

Use Annotated for request parameters and dependencies:

from typing import Annotated

from fastapi import APIRouter, Depends, Path, Query

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

ItemId = Annotated[int, Path(ge=1)]
SearchQuery = Annotated[str | None, Query(max_length=100)]


@router.get("/{item_id}")
async def get_item(item_id: ItemId, q: SearchQuery = None) -> dict[str, str | int | None]:
    return {"item_id": item_id, "q": q}
  • Prefer reusable type aliases for common dependencies and parameter declarations
  • Do not use ... as a required marker in FastAPI parameters or Pydantic fields
  • Do not use @app.api_route(..., methods=[...]) unless there is a strong reason

Request and Response Models

Declare response types deliberately.

  • Prefer a concrete return type when the returned value already matches the public schema
  • Use response_model= when the runtime return value differs from the public schema
  • Treat response models as a data-exposure boundary; never return raw internal models that contain secrets or extra fields
  • Prefer regular Pydantic models or standard typed containers over RootModel

Read the full file on GitHub · 167 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 167 lines · 87 tokens per session scan A 0733a98072a8

Subscribe to this mod's changes

fastapi is a skill published in the GitHub repository mfmezger/ai_agent_dotfiles (5 stars, last pushed 1mo ago), licensed MIT. It adds 87 tokens to every session and 1,212 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

python-patterns

Python idioms — type hints, dataclasses, async/await, generators, pytest, common pitfalls. Activate when writing or reviewing Python code.

DVNghiem/FlowDeck · 33 tokens

embedded-dev

Use when developing firmware on ESP32/STM32/RP2040/nRF52, experiencing DMA overflow, SPI timeout, LCD blank display, frame corruption, GPIO conflicts, sensor reading errors, Wi-Fi disconnect, or needing driver configuration, hardware debugging, display/GUI setup, protocol implementation, serial monitoring. Use even if…

lhbsaa/embedded-dev-skill · 93 tokens

embedded-dev

Guide for embedded systems development on ESP32, STM32, RP2040, nRF52 chips. Use this skill whenever the user mentions embedded systems, firmware development, MCU programming, hardware drivers, sensors, LCD displays, IMU devices, SPI/I2C/UART interfaces, compilation, debugging, remote monitoring, Wi-Fi/BLE/MQTT…

lhbsaa/embedded-dev-skill · 131 tokens

embedded-gui-feedback

Use for LCD/GUI projects after verification passes - captures display via camera, analyzes layout/font/color, detects display issues.

lhbsaa/embedded-dev-skill · 28 tokens

embedded-verification

Use after implementation complete - runs build-flash-monitor loop, verifies runtime behavior, no completion claims without fresh evidence.

lhbsaa/embedded-dev-skill · 26 tokens

embedded-brainstorming

Use before any embedded development - explores hardware requirements, confirms configuration, validates feasibility, saves design spec.

lhbsaa/embedded-dev-skill · 25 tokens