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 skills add ApexIQ/skillsmith --skill fastapi_best_practicesgit clone --depth 1 https://github.com/ApexIQ/skillsmithWrote 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/apexiq/skillsmith/fastapi_best_practices)<a href="https://agentmods.dev/skills/apexiq/skillsmith/fastapi_best_practices"><img src="https://agentmods.dev/badge/skills/apexiq/skillsmith/fastapi_best_practices/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.
<a href="https://agentmods.dev/skills/apexiq/skillsmith/fastapi_best_practices"><img src="https://agentmods.dev/badge/skills/apexiq/skillsmith/fastapi_best_practices.svg" alt="Reviewed on agentmods" width="80" 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.00032 | $0.00515 |
| Opus 5 | $0.00016 | $0.00258 |
| Sonnet 5 | $0.00006 | $0.00103 |
| Haiku 4.5 | $0.00003 | $0.00052 |
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 9d 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.
What it actually says
⚡ FastAPI Best Practices
1. Project Structure
- Modular Features: Organize code by feature/domain, not by type.
- Each feature folder:
router.py,service.py,models.py,tests/.
- Each feature folder:
- No Global State: Use Dependency Injection (
Depends), not global variables.
2. API Design (RESTful URLs)
| Pattern | Example | Why |
|---|---|---|
| ✅ Resource-based | GET /users/{id} |
Predictable, cacheable. |
| ❌ Verb-based | GET /get_user_by_id |
Unclear, non-standard. |
- Pydantic Models: Always use for Request/Response schemas.
CreateUserRequest(Input),UserResponse(Output).- Never return ORM/DB objects directly from endpoints.
3. Dependency Injection
from fastapi import Depends
def get_current_user(token: str = Depends(oauth2_scheme)): ...
def get_db(session: Session = Depends(get_session)): ...
@router.get("/items/{item_id}")
def get_item(item_id: int, user = Depends(get_current_user), db = Depends(get_db)):
...
4. Error Handling
- Use
HTTPExceptionwith specific status codes (400, 401, 403, 404, 500). - Log errors before raising the exception for traceability.
5. Security (Critical)
- Ownership Verification: ALWAYS check if resource belongs to user.
if item.owner_id != user.id: raise HTTPException(status_code=404, detail="Not found") # Use 404, not 403 - Rate Limiting: Apply on public/sensitive endpoints.
Examples
- New endpoint: Define Pydantic schema -> Add route -> Add ownership check -> Write test.
Guidelines
- Keep endpoints thin. Business logic goes in service layer.
- Every new endpoint MUST have a corresponding test.
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.
- 9d ago First seen · 63 lines · 32 tokens per session scan A f554df3a53e4
fastapi-best-practices is a skill published in the GitHub repository ApexIQ/skillsmith (5 stars, last pushed 5mo ago), licensed MIT. It adds 32 tokens to every session and 515 once invoked, about $0.0002 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
api-testing
Comprehensive API testing, validation, and test suite generation.
fastapi
Use when building, reviewing, testing, securing or shipping a FastAPI / async Python service — routers, Pydantic v2 schemas, dependency injection, async SQLAlchemy 2.0, OAuth2/JWT, ASGITransport tests, production wiring. NOT language-level Python or packaging (that is python), NOT engine-level SQL (that is…
api-connector-builder
Use when writing a client for someone else's REST or GraphQL API: auth flow choice and token refresh, pagination to exhaustion, retry-with-jitter on transient failures only, rate-limit-aware throttling. NOT inbound callbacks (that is webhooks), NOT chaining services (that is automation-flows), NOT designing your own…
fastapi-expert
Expert-level FastAPI development for high-performance Python APIs with async support. Use when the user mentions Python, API, async, REST, OpenAPI, or Pydantic, or when the task involves FastAPI Features.
api-design
Design REST API contracts that are consistent, evolvable, and easy to consume.
api-testing
REST/GraphQL API testing with automated validation — test endpoints, validate responses, check status codes, and ensure API contracts.