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.
npx agentmods add skills/dkmqflx/fastapi-best-practices-plugin/fastapi-best-practicesnpx skills add dkmqflx/fastapi-best-practices-plugin --skill fastapi-best-practicesgit clone --depth 1 https://github.com/dkmqflx/fastapi-best-practices-pluginWrote 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.
[](https://agentmods.dev/skills/dkmqflx/fastapi-best-practices-plugin/fastapi-best-practices)<a href="https://agentmods.dev/skills/dkmqflx/fastapi-best-practices-plugin/fastapi-best-practices"><img src="https://agentmods.dev/badge/skills/dkmqflx/fastapi-best-practices-plugin/fastapi-best-practices.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00097 | $0.01503 |
| Opus 5 | $0.00048 | $0.00751 |
| Sonnet 5 | $0.00019 | $0.00301 |
| Haiku 4.5 | $0.00010 | $0.00150 |
Grade A, and why
fastapi-best-practices 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 5d 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.
How it starts
The opening of the file, as written. The whole thing — 132 lines — stays where its author put it; the contents beside it link to each section on GitHub.
FastAPI Best Practices
Reference guide for writing FastAPI code that follows the official documentation (https://fastapi.tiangolo.com/). 33 rules across 11 categories, prioritized by impact — correctness first, structure/validation next, performance and polish last. Each rule pairs an incorrect example with the official correct pattern and links the relevant docs page.
Security/authentication and testing are covered by two companion skills —
fastapi-security and fastapi-testing — since they tend to live in their own
files (auth modules, test suites) rather than alongside routing/model code.
When to Apply
Reference these guidelines when:
- Writing new FastAPI endpoints, routers, parameters, or Pydantic models
- Designing dependency injection or error handling
- Adding streaming, background tasks, settings/config, or middleware
- Reviewing or refactoring a FastAPI backend
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Request/Response Models | CRITICAL | model- |
| 2 | Request Parameters & Validation | HIGH | params- |
| 3 | App Structure & Routing | HIGH | structure- |
| 4 | Dependency Injection | HIGH | di- |
| 5 | Error Handling | HIGH | error- |
| 6 | Async & Concurrency | MEDIUM | async- |
| 7 | Responses & Streaming | MEDIUM | response- |
| 8 | Background Tasks & Config | MEDIUM | background-, config- |
| 9 | Lifespan & Resources | MEDIUM | lifespan- |
| 10 | Middleware & Cross-cutting | MEDIUM | mw- |
| 11 | OpenAPI Documentation | LOW | docs- |
Quick Reference
1. Request/Response Models (CRITICAL)
model-response-model— declare a response model on every endpointmodel-separate-input-output— separate input vs output models so secrets never leakmodel-return-type-annotation— prefer the return-type annotation; useresponse_model=only when types differmodel-pydantic-validation— validate with PydanticField/Literal, not manualifchecksmodel-exclude-unset—response_model_exclude_unsetfor partial/sparse data
What ships with it
33 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.
- rules/async-await-all-io.md 1.1 KB
- rules/async-def-vs-def.md 1.3 KB
- rules/async-no-blocking-in-async.md 1.2 KB
- rules/background-tasks.md 1.4 KB
- rules/config-pydantic-settings.md 1.6 KB
- rules/di-annotated.md 1.1 KB
- rules/di-reusable-type-alias.md 1.2 KB
- rules/di-use-depends.md 1.4 KB
- rules/di-yield-cleanup.md 1.3 KB
- rules/docs-openapi-metadata.md 1.2 KB
- rules/error-custom-handler.md 1.5 KB
- rules/error-raise-httpexception.md 1.2 KB
- rules/error-reraise-httpexception.md 1.5 KB
- rules/error-specific-status-codes.md 1.4 KB
- rules/lifespan-context-manager.md 1.2 KB
- rules/lifespan-load-once.md 1.3 KB
- rules/model-exclude-unset.md 1.4 KB
- rules/model-pydantic-validation.md 1.4 KB
- rules/model-response-model.md 1.3 KB
- rules/model-return-type-annotation.md 1.2 KB
- rules/model-separate-input-output.md 1.4 KB
- rules/mw-cors.md 1.3 KB
- rules/mw-custom-http.md 1.5 KB
- rules/params-pagination.md 1.5 KB
- rules/params-path-validation.md 1.1 KB
- rules/params-query-param-models.md 1.5 KB
- rules/params-query-validation.md 1.3 KB
- rules/response-additional-responses.md 1.4 KB
- rules/response-streaming.md 1.6 KB
- rules/structure-apirouter-prefix-tags.md 1.2 KB
- rules/structure-bigger-app-layout.md 1.4 KB
- rules/structure-import-submodule.md 1.1 KB
- rules/structure-status-code-decorator.md 1.1 KB
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.
- 5d ago First seen · 132 lines · 97 tokens per session scan A 5059fd77644a
fastapi-best-practices is a skill published in the GitHub repository dkmqflx/fastapi-best-practices-plugin (1 stars, last pushed 2mo ago), licensed MIT. It adds 97 tokens to every session and 1,503 once invoked, about $0.0005 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-31.
Other skills, from other repositories
Cursor rules for FastAPI services with router/service/repository boundaries, typ
Cursor rules for FastAPI services with router/service/repository boundaries, typed provider adapters, bulkhead isolation, idempotency, and domain exceptions.
FastAPI best practices and patterns for building modern Python web APIs
Skill "FastAPI best practices and patterns for building modern Python web APIs" from AmariahAK/atlarix-skills, covering when to use this skill, source, fastapi best practices, project structure and api design.
FastAPI Patterns
Use this skill when building Python APIs with FastAPI and you want consistent boundary validation, async correctness, and maintainable dependency injection patterns.
datamodel-code-generator
Use this skill when the user wants Python data models, Pydantic models, dataclasses, TypedDicts, msgspec structs, or type-safe Python classes generated from OpenAPI, AsyncAPI, JSON Schema, GraphQL, JSON/YAML/CSV sample data, MCP tool schemas, Protocol Buffers, XML Schema, Apache Avro, or existing Python model objects.…
api-contrib
Contributing to the Kokoro-FastAPI Python API: module layout, endpoint gating pattern, test expectations. Use when adding or changing endpoints, services, or inference code.
fastapi
FastAPI best practices and conventions. Use when working with FastAPI APIs and Pydantic models for them. Keeps FastAPI code clean and up to date with the latest features and patterns, updated with new versions. Write new code or refactor and update old code.