FastAPI

FastAPI is a skill for Claude Code, Codex from kok-o/contextos-agents. It costs 10 tokens per session (1,115 once invoked), scanned A, original, Apache-2.0.

A set of architecture guidance for FastAPI, a Python framework for building web APIs. It covers typed request validation, API documentation, asynchronous endpoints, database access, and project structure.

In plain words
What is it for?
Use it when building Python REST APIs, microservices, background jobs, or services that connect machine-learning code to a web API.
Why use it?
It helps make Python APIs clearer and safer by defining expected request and response data and separating web handling from business and database code.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when building Python REST APIs, microservices, background jobs, or services that connect machine-learning code to a web API.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/kok-o/contextos-agents/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 kok-o/contextos-agents --skill fastapi
Clone the repo
git clone --depth 1 https://github.com/kok-o/contextos-agents

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/kok-o/contextos-agents/fastapi/github.svg)](https://agentmods.dev/skills/kok-o/contextos-agents/fastapi)
Your own site
<a href="https://agentmods.dev/skills/kok-o/contextos-agents/fastapi"><img src="https://agentmods.dev/badge/skills/kok-o/contextos-agents/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/kok-o/contextos-agents/fastapi"><img src="https://agentmods.dev/badge/skills/kok-o/contextos-agents/fastapi.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 10 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,115 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.00010 $0.01115
Opus 5.5 $0.00004 $0.00446
Sonnet 5.5 $0.00002 $0.00223
Haiku 4.5 $0.00001 $0.00112

Measured today against content hash 5050acfc5fc4, 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 today.

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.

catalog/skills/fastapi/SKILL.md · 172 lines

How it starts

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

FastAPI

Overview

High-performance Python backend engineering using FastAPI, Pydantic v2, and async SQLAlchemy/Tortoise ORM. Enforces type-driven request validation, OpenAPI contracts, and async non-blocking endpoints.

When to Use

Activate when building Python REST APIs, microservices, asynchronous background jobs, or integrating Python ML services into web backends.

Rules & Patterns

FastAPI - Best Practices

Project Structure

app/
├── main.py              # App entry, CORS, middleware
├── config.py            # Settings with Pydantic BaseSettings
├── database.py          # Database session, engine
├── models/              # SQLAlchemy models
│   ├── __init__.py
│   └── user.py
├── schemas/             # Pydantic schemas (request/response)
│   ├── __init__.py
│   └── user.py
├── api/                 # Route handlers
│   ├── __init__.py
│   ├── deps.py          # Dependency injection
│   └── v1/
│       ├── __init__.py
│       └── users.py
├── services/            # Business logic
│   └── user_service.py
├── repositories/        # Database access
│   └── user_repo.py
└── tests/
    └── test_users.py

Pydantic Models

from pydantic import BaseModel, EmailStr, Field, ConfigDict

class UserCreate(BaseModel):
    email: EmailStr
    name: str = Field(..., min_length=1, max_length=100)
    
class UserResponse(BaseModel):
    id: int
    email: str
    name: str
    
    model_config = ConfigDict(from_attributes=True)

Dependency Injection

from typing import AsyncGenerator
from fastapi import Depends, HTTPException, status
from fastapi.security import OAuth2PasswordBearer
from sqlalchemy.ext.asyncio import AsyncSession
import jwt

oauth2_scheme = OAuth2PasswordBearer(tokenUrl="api/v1/auth/token")

async def get_db() -> AsyncGenerator[AsyncSession, None]:
    async with async_session() as session:
        yield session

async def get_current_user(
    token: str = Depends(oauth2_scheme),
    db: AsyncSession = Depends(get_db)
) -> User:
    try:
        payload = jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM])
        user_id: str = payload.get("sub")
        if user_id is None:
            raise HTTPException(
                status_code=status.HTTP_401_UNAUTHORIZED,
                detail="Could not validate credentials",
                headers={"WWW-Authenticate": "Bearer"},
            )
    except jwt.PyJWTError:
        raise HTTPException(
            status_code=status.HTTP_401_UNAUTHORIZED,
            detail="Invalid token signature or expired token",
            headers={"WWW-Authenticate": "Bearer"},
        )

    user = await user_repo.get_by_id(db, user_id=user_id)
    if user is None:
        raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="User not found")
    return user

Read the full file on GitHub · 172 lines

Files

What ships with it

4 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. today First seen · 172 lines · 10 tokens per session scan A 5050acfc5fc4

Subscribe to this mod's changes

FastAPI is a skill published in the GitHub repository kok-o/contextos-agents (10 stars, last pushed today), licensed Apache-2.0. It adds 10 tokens to every session and 1,115 once invoked, about $0.0000 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-10-25.

Related

Other skills, from other repositories

fastapi-templates

Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.

wshobson/agents · 37 tokens

manimgl-best-practices

Trigger when: (1) User mentions "manimgl" or "ManimGL" or "3b1b manim", (2) Code contains from manimlib import , (3) User runs manimgl CLI commands, (4) Working with InteractiveScene, self.frame, self.embed(), ShowCreation(), or ManimGL-specific patterns. Best practices for ManimGL (Grant Sanderson's 3Blue1Brown…

calesthio/OpenMontage · 167 tokens

python-programming-expert

Expert-level skill for Python programming (Python 3.13/3.14+). Covers type safety, generic syntax (PEP 695), async/await TaskGroups, FastAPI 0.115+, Pydantic v2, uv package manager, Ruff, and pytest in English and Indonesian.

roedyrustam/vibes-plug · 68 tokens

fastapi-async-microservices

Design and develop production-grade asynchronous microservices using FastAPI, Python 3.12+, Pydantic v2 Settings and Schemas, SQLAlchemy 2.0 async sessions, dependency injection, lifespan state management, structured JSON logging, and connection pooling. Trigger when building async Python APIs, microservices, or…

hamzabellouch/agent-skills · 77 tokens

django

Expert Django assistance covering ORM, models, class-based views, admin interface, migrations, and Django REST Framework. Use when developing robust, scalable Python web applications and REST APIs.

G1Joshi/Agent-Skills · 37 tokens

fastapi

Expert FastAPI assistance covering Pydantic models, async endpoints, dependency injection, and OpenAPI generation. Use when developing high-performance Python REST APIs and microservices.

G1Joshi/Agent-Skills · 36 tokens