What to put in an AGENTS.md for a Python repo
Python tooling differs most from repo to repo, so name yours first: the package manager, linter, type checker and test runner, each as the command you run. The lockfile shows the manager: uv.lock for uv, poetry.lock for Poetry.
Which commands should it list?
uv run pytestlocks and syncs the environment first; no activation neededpoetry install && poetry run pytestthe Poetry way; installs the versions inpoetry.lockpytest tests/test_api.py::test_loginone test by node id;-kselects by nameruff check --fix && ruff formatlint with fixes, then format;ruff format --checkin CImypy srcorpyright; name the one CI runsuv sync --lockedfor CI: fails on a staleuv.lockinstead of rewriting it
Write them as your repo runs them, with its package manager and flags, plus how to run one test.
What layout should it explain?
src/or flat layout. Withsrc/, the package must be installed (editable, in dev) before tests can import it.- Which file holds each tool's config. Ruff uses the closest
.ruff.toml,ruff.tomlorpyproject.tomlwith[tool.ruff]; pyright preferspyrightconfig.jsonoverpyproject.toml. Neither merges files. - The Python versions you support (
requires-python), and where the virtualenv lives if not.venv.
What do agents get wrong?
- Run tools through the manager (
uv run,poetry run), not a globalpythonorpytest: the project environment is isolated from the shell. - Commit the lockfile with the dependency change that moved it;
uv.lockalways belongs in git,poetry.lockfor applications. - mypy reads the first of
mypy.ini,.mypy.ini,pyproject.tomlandsetup.cfgit finds; keep its settings in one.
From the official docs: docs.astral.sh/sync · docs.astral.sh/layout · python-poetry.org/basic-usage · docs.pytest.org/usage.html · docs.astral.sh/configuration · mypy.readthedocs.io/config_file.html · microsoft.github.io/pyright · packaging.python.org/src-layout-vs-flat-layout . The rest of the file is the same for any project: what goes in an AGENTS.md.
Python repos with an AGENTS.md or CLAUDE.md (29)
29 of the 56 Python repos on the leaderboard have an AGENTS.md or CLAUDE.md at the root, and 26 are long enough to pass the AGENTS.md check in full. Most-starred first; each file name links to the file.
More examples
- Every language: all 222 files, with the longest and shortest that pass
- Most agent-friendly Python repos: all 56, ranked on every check
- AGENTS.md vs CLAUDE.md: which file to write
- TypeScript (63)
- Rust (24)
- Go (23)
- Java (19)
- C++ (10)
- JavaScript (9)
- Kotlin (8)
- PHP (7)
- Ruby (6)