fastapi-templates

fastapi-templates is a skill for Claude Code, Codex from jh941213/codex-lattice. It costs 96 tokens per session (3,673 once invoked), scanned A, original, MIT.

A guide for creating Python web APIs with FastAPI, including project structure, asynchronous code, dependency injection, error handling, and testing. An API lets software exchange data over the web.

In plain words
What is it for?
Use it to start FastAPI REST APIs, web services, or microservices that connect to databases such as PostgreSQL or MongoDB.
Why use it?
It provides a consistent starting structure for new FastAPI services instead of leaving routing, configuration, database access, and business logic mixed together. The input describes new projects, not general changes to existing ones.

Skill for Claude CodeCodex

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

Good fit Use it to start FastAPI REST APIs, web services, or microservices that connect to databases such as PostgreSQL or MongoDB.

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

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-templates

README.md
[![agentmods](https://agentmods.dev/badge/skills/jh941213/codex-lattice/fastapi-templates/github.svg)](https://agentmods.dev/skills/jh941213/codex-lattice/fastapi-templates)
Your own site
<a href="https://agentmods.dev/skills/jh941213/codex-lattice/fastapi-templates"><img src="https://agentmods.dev/badge/skills/jh941213/codex-lattice/fastapi-templates/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-templates

Your own site · 80×15
<a href="https://agentmods.dev/skills/jh941213/codex-lattice/fastapi-templates"><img src="https://agentmods.dev/badge/skills/jh941213/codex-lattice/fastapi-templates.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 96 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,673 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.00096 $0.03673
Opus 5.5 $0.00038 $0.01469
Sonnet 5.5 $0.00019 $0.00735
Haiku 4.5 $0.00010 $0.00367

Measured 3mo ago against content hash 57d282f3bfa2, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

fastapi-templates 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 3mo 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-templates/SKILL.md · 571 lines

How it starts

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

FastAPI Project Templates

Production-ready FastAPI project structures with async patterns, dependency injection, middleware, and best practices for building high-performance APIs.

When to Use This Skill

  • Starting new FastAPI projects from scratch
  • Implementing async REST APIs with Python
  • Building high-performance web services and microservices
  • Creating async applications with PostgreSQL, MongoDB
  • Setting up API projects with proper structure and testing

Core Concepts

1. Project Structure

Recommended Layout:

app/
├── api/                    # API routes
│   ├── v1/
│   │   ├── endpoints/
│   │   │   ├── users.py
│   │   │   ├── auth.py
│   │   │   └── items.py
│   │   └── router.py
│   └── dependencies.py     # Shared dependencies
├── core/                   # Core configuration
│   ├── config.py
│   ├── security.py
│   └── database.py
├── models/                 # Database models
│   ├── user.py
│   └── item.py
├── schemas/                # Pydantic schemas
│   ├── user.py
│   └── item.py
├── services/               # Business logic
│   ├── user_service.py
│   └── auth_service.py
├── repositories/           # Data access
│   ├── user_repository.py
│   └── item_repository.py
└── main.py                 # Application entry

2. Dependency Injection

FastAPI's built-in DI system using Depends:

  • Database session management
  • Authentication/authorization
  • Shared business logic
  • Configuration injection

3. Async Patterns

Proper async/await usage:

  • Async route handlers
  • Async database operations
  • Async background tasks
  • Async middleware

Implementation Patterns

Pattern 1: Complete FastAPI Application

# main.py
from fastapi import FastAPI, Depends
from fastapi.middleware.cors import CORSMiddleware
from contextlib import asynccontextmanager

@asynccontextmanager
async def lifespan(app: FastAPI):
    """Application lifespan events."""
    # Startup
    await database.connect()
    yield
    # Shutdown
    await database.disconnect()

app = FastAPI(
    title="API Template",
    version="1.0.0",
    lifespan=lifespan
)

# CORS middleware
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# Include routers
from app.api.v1.router import api_router
app.include_router(api_router, prefix="/api/v1")

# core/config.py
from pydantic_settings import BaseSettings
from functools import lru_cache

class Settings(BaseSettings):
    """Application settings."""
    DATABASE_URL: str
    SECRET_KEY: str
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
    API_V1_STR: str = "/api/v1"

    class Config:
        env_file = ".env"

@lru_cache()
def get_settings() -> Settings:
    return Settings()

# core/database.py
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from app.core.config import get_settings

settings = get_settings()

engine = create_async_engine(
    settings.DATABASE_URL,
    echo=True,
    future=True
)

AsyncSessionLocal = sessionmaker(
    engine,
    class_=AsyncSession,
    expire_on_commit=False
)

Base = declarative_base()

async def get_db() -> AsyncSession:
    """Dependency for database session."""
    async with AsyncSessionLocal() as session:
        try:
            yield session
            await session.commit()
        except Exception:
            await session.rollback()
            raise
        finally:
            await session.close()

Read the full file on GitHub · 571 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. 3mo ago First seen · 571 lines · 96 tokens per session scan A 57d282f3bfa2

Subscribe to this mod's changes

fastapi-templates is a skill published in the GitHub repository jh941213/codex-lattice (19 stars, last pushed 6mo ago), licensed MIT. It adds 96 tokens to every session and 3,673 once invoked, about $0.0004 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-08-30.

Related

fastapi-templates compared with skills from other repositories

fastapi-templates next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
fastapi-templatesjh941213/codex-latticeSkill196mo agoMITA96Claude Code, Codex
fastapi-patternsaffaan-m/ECCSkill315k2d agoMITA35Claude Code, Kiro
stripe-projectse2b-dev/E2BSkill15kyesterdayApache-2.0A51Claude Code, Codex
azure-messaging-webpubsubservice-pymicrosoft/skillsSkill3.3kyesterdayMITA64Claude Code
azure-mgmt-botservice-pymicrosoft/skillsSkill3.3kyesterdayMITA59Claude Code
azure-appconfiguration-pybenjaminasterA/antigravity-awesome-skillsSkill526yesterdayMITA0Claude Code, Codex
azure-messaging-webpubsubservice-pybenjaminasterA/antigravity-awesome-skillsSkill526yesterdayMITA0Claude Code, Codex