fastapi-conventions

fastapi-conventions is a skill for Claude Code from AratKruglik/claude-sdlc. It costs 224 tokens per session (2,930 once invoked), scanned A, original, MIT.

A set of conventions for structuring FastAPI applications, Python web services built around HTTP endpoints. It covers application startup and shutdown, routes, Pydantic data schemas, dependency injection, authentication, database sessions, and configuration.

In plain words
What is it for?
Use it when adding FastAPI routes, validating request data, configuring asynchronous startup and database access, adding OAuth2/JWT authentication, documenting APIs, or managing application settings.
Why use it?
It gives developers a consistent way to organize common FastAPI features and check the installed framework and database versions before changing code. This reduces mismatches between the project setup and the implementation.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the fastapi-plugin plugin — 2 skills, 2 agents shipped together

Good fit Use it when adding FastAPI routes, validating request data, configuring asynchronous startup and database access, adding OAuth2/JWT authentication, documenting APIs, or managing application settings.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/aratkruglik/claude-sdlc/fastapi-conventions
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 AratKruglik/claude-sdlc --skill fastapi-conventions
Clone the repo
git clone --depth 1 https://github.com/AratKruglik/claude-sdlc

Made for: Claude Code.

Or install fastapi-plugin, the plugin that ships this one along with the rest of its 2 skills, 2 agents.

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

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/aratkruglik/claude-sdlc/fastapi-conventions"><img src="https://agentmods.dev/badge/skills/aratkruglik/claude-sdlc/fastapi-conventions.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 224 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,930 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. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Privilege Escalation · line 381
    Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
    Fix: Remove references to credential paths. Use environment variables or secrets managers. For docs, use placeholder paths (e.g., /path/to/config). Never load .env or token files in production code paths.
How audits are shown
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.00224 $0.02930
Opus 5 $0.00112 $0.01465
Sonnet 5 $0.00045 $0.00586
Haiku 4.5 $0.00022 $0.00293

Measured 11d ago against content hash 197f17e4441a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

fastapi-conventions 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 11d 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.

plugins/fastapi-plugin/skills/fastapi-conventions/SKILL.md · 409 lines

How it starts

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

FastAPI Conventions

Detection

Read pyproject.toml before writing any code:

  • Find the FastAPI version under [project.dependencies] or [tool.poetry.dependencies]. FastAPI 0.100+ uses Pydantic v2 by default — this is the assumed baseline.
  • Find the SQLAlchemy version. 2.0+ uses Mapped/mapped_column syntax. If the project uses SQLAlchemy 1.x, note it and use Column()/relationship() style instead.
grep -E "fastapi|sqlalchemy" pyproject.toml

App factory and lifespan

Use a create_app() factory that returns a configured FastAPI instance. Use the @asynccontextmanager lifespan pattern (introduced in FastAPI 0.93+) for startup/shutdown logic.

from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from app.core.config import settings
from app.db.session import engine
from app.users.router import router as users_router
from app.auth.router import router as auth_router


@asynccontextmanager
async def lifespan(app: FastAPI):
    # Startup: initialize DB connection pool, caches, etc.
    async with engine.begin() as conn:
        pass  # pool warm-up; alembic manages schema
    yield
    # Shutdown: close DB pool, flush caches, etc.
    await engine.dispose()


def create_app() -> FastAPI:
    app = FastAPI(
        title=settings.APP_NAME,
        version=settings.APP_VERSION,
        lifespan=lifespan,
    )

    app.add_middleware(
        CORSMiddleware,
        allow_origins=settings.CORS_ALLOWED_ORIGINS,
        allow_credentials=True,
        allow_methods=["*"],
        allow_headers=["*"],
    )

    app.include_router(auth_router)
    app.include_router(users_router)

    return app


app = create_app()

APIRouter — per-feature modules

Create one APIRouter per feature module. Group related endpoints under a shared prefix and tags. Apply shared dependencies (e.g., auth) at the router level to avoid repeating them on every endpoint.

Read the full file on GitHub · 409 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. 11d ago First seen · 409 lines · 224 tokens per session scan A 197f17e4441a

Subscribe to this mod's changes

fastapi-conventions is a skill published in the GitHub repository AratKruglik/claude-sdlc (33 stars, last pushed 6d ago), licensed MIT. It adds 224 tokens to every session and 2,930 once invoked, about $0.0011 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-30.