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 testsfastapi devauto-reload, listens on 127.0.0.1fastapi runno reload, listens on 0.0.0.0; how it runs in a containeruv run pytesttests useTestClientfromfastapi.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
APIRouterper module underrouters/, shared dependencies in one file. - Where request and response models live, if not beside their routes.
What do agents get wrong?
- Use plain
deffor handlers that call a blocking library (most database drivers);async defonly 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 useTestClient.
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.
| Repo | File | Length | Language |
|---|---|---|---|
| Significant-Gravitas/AutoGPT | AGENTS.md | 12,045 chars | |
| langflow-ai/langflow | AGENTS.md | 11,708 chars | |
| BerriAI/litellm | AGENTS.md | 19,742 chars | |
| apache/airflow | AGENTS.md | 23,068 chars | |
| gradio-app/gradio | AGENTS.md | 3,776 chars | |
| immich-app/immich | AGENTS.md | 2,449 chars | |
| getnao/nao | AGENTS.md | 3,028 chars |
More examples: Next.js · Django · Rails · all examples