agentleFS
axrmxvaxrmxv/claude-config/skills/standards-fastapi/SKILL.md

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.

The file

Files
SKILL.md

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 in create_app(). Never a bare except:.
  • Never block the event loop inside async def — no sync requests, sync SQLAlchemy, time.sleep, or CPU-bound loops. Offload with asyncio.to_thread.
  • One AsyncSession per request from a dependency, expire_on_commit=False, transaction owned at the request boundary. Eager-load relationships with selectinload/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 with Depends — not os.getenv scattered through the codebase.

Reference files

FileCovers
coding-style.mdLayering, domain exceptions and central handlers, configuration
patterns.mdcreate_app(), async rules, async SQLAlchemy 2.0, DI, pydantic v2 schemas
security.mdResponse-model leakage, CORS, JWT validation, error responses, log redaction
testing.mdhttpx ASGITransport client, rollback-per-test DB isolation, dependency overrides

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.