What to put in an AGENTS.md for FastAPI

FastAPI is often one service in a larger repo, so say where it lives and how to start it alone. Then the two choices an agent can't infer: how handlers reach the database, and whether they may block.

Which commands should it list?

  • uv add "fastapi[standard]"installs the CLI, Uvicorn and httpx for tests
  • fastapi devauto-reload, listens on 127.0.0.1
  • fastapi runno reload, listens on 0.0.0.0; how it runs in a container
  • uv run pytesttests use TestClient from fastapi.testclient

Write them as your repo runs them, with its package manager and flags, plus how to run one test.

What layout should it explain?

  • Where the app object is created and where routers are included with include_router.
  • One APIRouter per module under routers/, shared dependencies in one file.
  • Where request and response models live, if not beside their routes.

What do agents get wrong?

  • Use plain def for handlers that call a blocking library (most database drivers); async def only when everything inside is awaited.
  • Inject shared resources with Annotated[..., Depends(fn)], passing the function uncalled.
  • Test functions are plain def, even for async endpoints, when they use TestClient.

From the official docs: fastapi.tiangolo.com/fastapi-cli · fastapi.tiangolo.com/testing · fastapi.tiangolo.com/async · fastapi.tiangolo.com/dependencies · fastapi.tiangolo.com/bigger-applications . The rest of the file is the same for any project: what goes in an AGENTS.md.

FastAPI repos with an AGENTS.md or CLAUDE.md (7)

Built on FastAPI; 7 pass the AGENTS.md check in full.

FastAPI repos with an AGENTS.md or CLAUDE.md
RepoFileLength
Significant-Gravitas/AutoGPTAGENTS.md 12,045
langflow-ai/langflowAGENTS.md 11,708
BerriAI/litellmAGENTS.md 19,742
apache/airflowAGENTS.md 23,068
gradio-app/gradioAGENTS.md 3,776
immich-app/immichAGENTS.md 2,449
getnao/naoAGENTS.md 3,028

More examples: Next.js · Django · Rails · all examples