fastapi-claude-template CLAUDE.md

fastapi-claude-template CLAUDE.md is an instructions file for coding agents from ocbunknown/fastapi-claude-template. It costs 7,589 tokens per session, scanned A, original, MIT.

An architecture guide for a FastAPI application template. FastAPI is a Python framework for building web APIs; the guide explains how application logic, databases, security, and external services are separated.

In plain words
What is it for?
It is for building FastAPI features such as authentication, users, events, caching, database access, and security while following the template's dependency rules.
Why use it?
It helps developers place new code in the right layer and prevents business rules from becoming tied to web requests or infrastructure details. This makes the project's structure easier to maintain.

Instructions file

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 instructions/ocbunknown/fastapi-claude-template/claude-md
Clone the repo
git clone --depth 1 https://github.com/ocbunknown/fastapi-claude-template

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-claude-template CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/ocbunknown/fastapi-claude-template/claude-md.svg)](https://agentmods.dev/instructions/ocbunknown/fastapi-claude-template/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/ocbunknown/fastapi-claude-template/claude-md"><img src="https://agentmods.dev/badge/instructions/ocbunknown/fastapi-claude-template/claude-md.svg" alt="Measured on agentmods" height="20"></a>
Per session 7,589 This file is loaded in full into every session.
When invoked 7,589 The same file — it is already loaded in full.
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.07589 $0.07589
Opus 5 $0.03794 $0.03794
Sonnet 5 $0.01518 $0.01518
Haiku 4.5 $0.00759 $0.00759

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

Security

Grade A, and why

fastapi-claude-template CLAUDE.md 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 3d 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.

CLAUDE.md · 484 lines

How it starts

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

FastAPI Template — Architecture Guide

High-level structure

src/
├── application/          ← USE CASES (transport-agnostic business logic)
│   ├── common/
│   │   ├── interfaces/   ← ports: bus, request_bus, event_bus, wrapper, usecase, cache, hasher, jwt, broker
│   │   ├── bus/          ← RequestBusImpl, EventBusImpl (both inherit Bus[M])
│   │   ├── events/       ← Event base, BrokerEvent, StreamEvent, @event decorator
│   │   ├── pagination.py ← OffsetPagination (lenient, internal)
│   │   ├── exceptions.py ← AppException + DetailedError hierarchy
│   │   └── request.py    ← Request base (Pydantic, frozen)
│   ├── v1/
│   │   ├── usecases/     ← use case classes, grouped by domain (auth/, user/)
│   │   ├── services/     ← domain services (AuthService) + ServiceGateway
│   │   ├── results/      ← use case return types (UserResult, OffsetResult, etc.)
│   │   ├── events/       ← v1 domain events (UserRegistered, etc.)
│   │   └── constants.py
│   └── provider.py       ← ApplicationProvider (Dishka)
│
├── infrastructure/       ← OUTBOUND ADAPTERS (accessed through ports)
│   ├── cache/            ← Redis adapter (implements StrCache port)
│   ├── security/         ← JWT, Argon2 (implement JWT, Hasher ports)
│   ├── http/             ← HTTP client stack
│   │   ├── clients/      ← Client + Request base classes (provider-agnostic)
│   │   └── provider/     ← AsyncProvider Protocol + AiohttpProvider + middleware chain
│   ├── broker/nats/      ← NatsBroker, NatsJetStreamBroker
│   ├── logging/          ← setup_logging
│   └── provider.py       ← InfrastructureProvider (Dishka)
│
├── database/             ← PERSISTENCE — first-class layer (see "Persistence")
│   └── psql/             ← SQLAlchemy + Postgres (the only backend)
│       ├── models/       ← ORM models (inherit Base with .as_dict())
│       ├── repositories/ ← repository implementations (BaseRepository + CRUD helper)
│       ├── queries/      ← Query Object pattern (complex SQL builders)
│       ├── types/        ← OrderBy, Loads literals, TypedDict payloads
│       ├── interfaces/   ← internal ports (DBGateway, CRUD)
│       ├── manager.py    ← TransactionManager
│       ├── connection.py ← engine + session factory
│       ├── exceptions.py ← integrity-error translation to AppException
│       ├── tools.py      ← on_integrity decorator + sqla-autoloads re-exports (sqla_select, sqla_offset_query, sqla_cursor_query, unique_scalars, add_conditions)
│       └── provider.py   ← DatabaseProvider (Dishka)
│
├── presentation/         ← INBOUND ADAPTERS — synchronous client interface
│   └── http/             ← FastAPI HTTP transport
│       ├── common/       ← middlewares, serializers (exclude_none=True), guards, contract.py, responses, exception_handlers
│       └── v1/
│           ├── contracts/      ← Pydantic request/response schemas + pagination.py (strict OffsetPagination)
│           ├── guards/         ← v1-specific gates (Authorization JWT+roles)
│           └── endpoints/      ← audience-first organization (see below)
│               ├── public/         no auth (healthcheck, register, login, refresh)
│               ├── user/           JWT, any role (router-level Authorization())
│               ├── admin/          JWT + Admin role (router-level Authorization("Admin"))
│               └── internal/       service-to-service stub (include_in_schema=False)
│
├── consumers/            ← INBOUND ADAPTERS — message-driven (FastStream)
│   ├── routers/          ← @subscriber-decorated functions calling request_bus
│   ├── subjects.py       ← NATS subject constants
│   └── streams.py        ← NATS JetStream stream constants
│
├── tasks/                ← INBOUND ADAPTERS — time-driven (Taskiq)
│   ├── broker.py         ← Taskiq broker + scheduler factories
│   └── *.py              ← scheduled task functions calling request_bus
│
├── entrypoints/          ← composition root + module-level app instances
│   ├── container.py      ← build_container() — shared across all transports
│   ├── http.py           ← FastAPI app + lifespan + run()
│   ├── consumers.py      ← FastStream app
│   ├── tasks.py          ← Taskiq broker + scheduler
│   └── server/           ← ASGI server runners (granian) — process bootstrap
│
├── common/               ← shared leaf utilities (no upper-layer deps)
│   ├── di/               ← Dishka helpers (DynamicContainer, Depends marker, inject)
│   └── tools/            ← formatter, cache key builder, text utils, types
│
└── settings/             ← Pydantic Settings + SettingsProvider

Read the full file on GitHub · 484 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. 3d ago First seen · 484 lines · 7,589 tokens per session scan A 34399a06808e

Subscribe to this mod's changes

fastapi-claude-template CLAUDE.md is an instructions file published in the GitHub repository ocbunknown/fastapi-claude-template (32 stars, last pushed 4mo ago), licensed MIT. It adds 7,589 tokens to every session, about $0.0379 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.