fastapi

fastapi is a skill for Claude Code from alivirgo/Major-AI-Skills. It costs 52 tokens per session (1,208 once invoked), scanned A, original, MIT.

An operational guide for FastAPI, a Python framework for building HTTP APIs. It covers request validation, routes, authentication hooks, asynchronous handlers, automatic API documentation, and API tests.

In plain words
What is it for?
Use it to create REST or JSON endpoints, define typed request and response models, add authentication dependencies, generate OpenAPI documentation, and test routes.
Why use it?
It helps agents keep API inputs and outputs consistent, avoid blocking asynchronous requests, and handle errors and authentication in a predictable way.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: mentions Codex.

Part of the major-ai-skills plugin — 147 skills, 8 plugins shipped together

Good fit Use it to create REST or JSON endpoints, define typed request and response models, add authentication dependencies, generate OpenAPI documentation, and test routes.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/alivirgo/major-ai-skills/fastapi
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.

Any agent
npx skills add alivirgo/Major-AI-Skills --skill fastapi
Clone the repo
git clone --depth 1 https://github.com/alivirgo/Major-AI-Skills

Made for: Claude Code.

Or install major-ai-skills, the plugin that ships this one along with the rest of its 147 skills, 8 plugins.

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/alivirgo/major-ai-skills/fastapi/github.svg)](https://agentmods.dev/skills/alivirgo/major-ai-skills/fastapi)
Your own site
<a href="https://agentmods.dev/skills/alivirgo/major-ai-skills/fastapi"><img src="https://agentmods.dev/badge/skills/alivirgo/major-ai-skills/fastapi/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for fastapi

Your own site · 80×15
<a href="https://agentmods.dev/skills/alivirgo/major-ai-skills/fastapi"><img src="https://agentmods.dev/badge/skills/alivirgo/major-ai-skills/fastapi.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,208 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00052 $0.01208
Opus 5.5 $0.00021 $0.00483
Sonnet 5.5 $0.00010 $0.00242
Haiku 4.5 $0.00005 $0.00121

Measured 20d ago against content hash 44b6398120dc, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 20d 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.

skills/fastapi/SKILL.md · 148 lines

How it starts

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

FastAPI Python APIs AI Skill Guide (Claude)

Overview & Engine Architecture

FastAPI builds HTTP APIs on Starlette with Pydantic validation and automatic OpenAPI. Dependencies inject auth, DB sessions, and settings. Async routes must not block the event loop with sync ORM/socket calls without run_in_threadpool.

Claude operates as a Principal API Engineer: typed I/O, webhook raw bodies, idempotent event processing, and consistent error envelopes.

uvicorn / gunicorn workers
        │
     FastAPI app
   ├── APIRouter (domain modules)
   ├── Depends() graph
   ├── Pydantic request/response models
   └── /docs OpenAPI

When to use / when not to

Use when

  • High-throughput JSON APIs with automatic schema docs.
  • Webhook receivers (Stripe, GitHub) with signature verification.
  • Internal microservices where Python ecosystem fits.

Do not use when

  • Heavy CPU work belongs in a queue worker—not BackgroundTasks alone.
  • Team standard is Django ORM/admin—don't force FastAPI for CRUD admin.

Operational Capabilities & Agent Directives

  1. Request + response models on public routes; avoid bare dict responses.
  2. APIRouter per domain with shared exception handlers.
  3. Settings via pydantic-settings cached dependency—never hardcode secrets.
  4. Async discipline: async DB drivers in async routes; sync SQLAlchemy → threadpool or sync def routes.
  5. Webhooks: Read raw body bytes for HMAC verify; use dedicated route without global JSON middleware consuming body.
  6. Idempotency: UNIQUE on event_id; return 200 on duplicate; 500 on handler failure so providers retry.
  7. CORS: Explicit origins—never * with credentials.

App sketch

from fastapi import Depends, FastAPI, HTTPException, Request
from pydantic import BaseModel, Field

app = FastAPI(title="Inventory API", version="1.2.0")

class ItemIn(BaseModel):
    sku: str = Field(min_length=1, max_length=64)
    qty: int = Field(ge=0)

class ItemOut(ItemIn):
    id: int

def get_current_user(authorization: str | None = None) -> str:
    if not authorization:
        raise HTTPException(status_code=401, detail="unauthorized")
    return "user"

@app.post("/items", response_model=ItemOut, status_code=201)
async def create_item(body: ItemIn, user: str = Depends(get_current_user)) -> ItemOut:
    return ItemOut(id=1, **body.model_dump())

Read the full file on GitHub · 148 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 20d ago Changed · +38 lines · +24 tokens per session 44b6398120dc
  2. 1mo ago Changed · -4 tokens per session 296fbebf29b8
  3. 1mo ago First seen · 110 lines · 32 tokens per session scan A be114b08ba39

Subscribe to this mod's changes

fastapi is a skill published in the GitHub repository alivirgo/Major-AI-Skills (2 stars, last pushed today), licensed MIT. It adds 52 tokens to every session and 1,208 once invoked, about $0.0002 per session on Opus 5.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-09-05.