python-samples-fastapi-restful CLAUDE.md

Repository instructions for a Python web service built with FastAPI, a framework for creating web APIs, and related tools for databases, validation, testing, and deployment.

In plain words
What is it for?
Use them when adding or changing API routes, business logic, database models and migrations, validation, caching, tests, linting, or Docker setup.
Why use it?
They give coding agents the project's technical rules and checks, reducing the chance of changes that break its API, database, tests, or formatting.

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/nanotaboada/python-samples-fastapi-restful/claude-md
Clone the repo
git clone --depth 1 https://github.com/nanotaboada/python-samples-fastapi-restful
Per session 2,459 This file is loaded in full into every session.
When invoked 2,459 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.02459 $0.02459
Opus 5 $0.01229 $0.01229
Sonnet 5 $0.00492 $0.00492
Haiku 4.5 $0.00246 $0.00246

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

Security

Grade A, and why

python-samples-fastapi-restful 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 2d 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 · 227 lines

How it starts

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

CLAUDE.md

Claude Code

  • Run /pre-commit to execute the full pre-commit checklist for this project.

Overview

REST API for managing football players built with Python and FastAPI. Implements async CRUD operations with SQLAlchemy 2.0 (async), SQLite, Pydantic validation, and in-memory caching.

Tech Stack

  • Language: Python 3.13
  • Framework: FastAPI + Uvicorn
  • ORM: SQLAlchemy 2.0 (async) + aiosqlite
  • Database: SQLite (local/test), PostgreSQL-compatible
  • Migrations: Alembic (async, render_as_batch=True)
  • Validation: Pydantic
  • Caching: aiocache (in-memory, 10-minute TTL)
  • Testing: pytest + pytest-cov + httpx
  • Linting/Formatting: Flake8 + Black
  • Containerization: Docker

Structure

main.py         — application entry point: FastAPI setup, router registration
alembic.ini     — Alembic configuration (sqlalchemy.url set dynamically)
alembic/        — Alembic migration environment and version scripts
routes/         — HTTP route definitions, caching + dependency injection [HTTP layer]
services/       — async business logic                                   [business layer]
schemas/        — SQLAlchemy ORM models (database schema)                [data layer]
databases/      — async SQLAlchemy session setup + get_database_url()
models/         — Pydantic models for request/response validation
scripts/        — shell scripts for Docker (entrypoint.sh, healthcheck.sh)
tools/          — legacy standalone seed scripts (superseded by Alembic migrations)
rest/           — HTTP request file (players.rest) for manual API testing
gunicorn.conf.py — production WSGI worker config (used by Docker entrypoint)
tests/          — pytest integration tests

Layer rule: Routes → Services → SQLAlchemy → SQLite. Routes handle HTTP concerns only; business logic belongs in services. Never skip a layer.

Coding Guidelines

  • Naming: snake_case (files, functions, variables), PascalCase (classes)
  • Type hints: Required everywhere — functions, variables, return types
  • Async: All routes and service functions must be async def; use AsyncSession (never Session); use aiosqlite (never sqlite3); use SQLAlchemy 2.0 select() (never session.query())
  • API contract: camelCase JSON via Pydantic alias_generator=to_camel; Python internals stay snake_case
  • Models: PlayerRequestModel (no id, used for POST/PUT) and PlayerResponseModel (includes id: UUID, used for GET/POST responses). One request model intentionally covers both POST and PUT — per-operation differences (conflict check on POST, mismatch guard on PUT) are handled at the route layer, not by duplicating the model. Never reintroduce the removed PlayerModel; it was removed because a single flat model conflated ORM, request, and response concerns.
  • Primary key: UUID surrogate key (id) — opaque, internal, used for GET by id only. UUID v4 for API-created records; UUID v5 (deterministic) for migration-seeded records. squad_number is the natural key — human-readable, domain-meaningful, used for all mutation endpoints (PUT, DELETE) and preferred for all external consumers
  • Caching: cache key "players" (hardcoded); clear on POST/PUT/DELETE; X-Cache header (HIT/MISS)
  • Errors: Catch specific exceptions with rollback in services; Pydantic validation returns 422 (not 400); squad number mismatch on PUT returns 400 (not 422 — it is a semantic error, not a validation failure)
  • Logging: logging module only; never print()
  • Line length: 88; complexity ≤ 10
  • Import order: stdlib → third-party → local
  • Tests: integration tests against the real SQLite DB (seeded via Alembic migrations) via TestClient — no mocking. Naming pattern test_request_{method}_{resource}_{context}_response_{outcome}; docstrings single-line, concise; tests/player_fake.py for test data; tests/conftest.py provides a function-scoped client fixture for isolation; tests/test_main.py excluded from Black; tests/test_migrations.py covers Alembic downgrade paths
  • Decisions: justify every decision on its own technical merits; never use "another project does it this way" as a reason — that explains nothing and may mean replicating a mistake
  • Avoid: sync DB access, mixing sync/async, print(), missing type hints, unhandled exceptions

Read the full file on GitHub · 227 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. 2d ago First seen · 227 lines · 2,459 tokens per session scan A 06cec1727910

Subscribe to this mod's changes

python-samples-fastapi-restful CLAUDE.md is an instructions file published in the GitHub repository nanotaboada/python-samples-fastapi-restful (137 stars, last pushed 2d ago), licensed MIT. It adds 2,459 tokens to every session, about $0.0123 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.

Related

Other instructions, from other repositories

receipts-api-mcp global-skills.instructions.md

Instructions for chf3198/receipts-api-mcp: Global skills routing contract for this repository (standard).

chf3198/receipts-api-mcp · 235 tokens

receipts-api-mcp skill-routing.instructions.md

Instructions for chf3198/receipts-api-mcp: Use repository and global customization layers together for every task.

chf3198/receipts-api-mcp · 233 tokens

receipts-api-mcp openclaw-universal.instructions.md

Instructions for chf3198/receipts-api-mcp: Use the machine-global OpenClaw system as the baseline for this repository.

chf3198/receipts-api-mcp · 169 tokens

agentic-travel-recommendations-api CLAUDE.md

Claude Code instructions for andypnguyen11-gif/agentic-travel-recommendations-api, covering claude.md — agentic travel recommendations service, what this project is, core principles (the whole design hangs on these), constraints from the assignment (do not violate) and fixtures must match the assignment prompt exactly.

andypnguyen11-gif/agentic-travel-recommendations-api · 1,176 tokens

pydantic-ai AGENTS.md

Instructions for pydantic/pydantic-ai, covering your primary responsibility is to the project and its users, gathering context on the task, ensuring the task is ready for implementation, philosophy and requirements of all contributions.

pydantic/pydantic-ai · 3,564 tokens

full-stack-ai-agent-template CLAUDE.md

Instructions for vstorm-co/full-stack-ai-agent-template, covering claude.md, project overview, commands, install dependencies and run tests.

vstorm-co/full-stack-ai-agent-template · 1,305 tokens