standards-fastapi
Skill1 starsChanged 4 months agoMITView on GitHub
FastAPI service standards — router/service/repository layering, domain exceptions mapped centrally, pydantic-settings config, async SQLAlchemy 2.0 session-per-request, separate request/response schemas, CORS and JWT rules, ASGI test client. Use when writing or reviewing FastAPI endpoints, routers, services, or dependencies.
In this repository14 other files it gives its agents.
- .claude/rules/common/agents.mdAGENTS.md
- docs/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- standards-<layer>Skill
- add-agentSkill
- add-standards-layerSkill
- audit-configSkill
- plan-featureSkill
- research-reuseSkill
- review-changesSkill
- shipSkill
- standards-pythonSkill
- standards-typescriptSkill
- tddSkill
The file
Files
FastAPI Standards
The FastAPI delta over standards-python, which in turn extends
.claude/rules/common/. Load this only for FastAPI work — it does not apply to Python generally.
What applies immediately
- Three layers, no leakage. Router validates and calls one service; service holds business rules and no HTTP types; repository does database access and returns no HTTP responses.
- Domain exceptions, not
HTTPException, in services. Map them to responses in one place with@app.exception_handler(...)registered increate_app(). Never a bareexcept:. - Never block the event loop inside
async def— no syncrequests, sync SQLAlchemy,time.sleep, or CPU-bound loops. Offload withasyncio.to_thread. - One
AsyncSessionper request from a dependency,expire_on_commit=False, transaction owned at the request boundary. Eager-load relationships withselectinload/joinedload. - Separate request, update, and response schemas. Input must not accept server-owned fields; output must never expose password hashes, tokens, or internal auth state. Never return an ORM instance directly.
- Typed settings via
pydantic-settings, validated at startup, injected withDepends— notos.getenvscattered through the codebase.
Reference files
| File | Covers |
| coding-style.md | Layering, domain exceptions and central handlers, configuration |
| patterns.md | create_app(), async rules, async SQLAlchemy 2.0, DI, pydantic v2 schemas |
| security.md | Response-model leakage, CORS, JWT validation, error responses, log redaction |
| testing.md | httpx ASGITransport client, rollback-per-test DB isolation, dependency overrides |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

