What to put in an AGENTS.md for a Go repo
Agents know the go tool. What they can't see is which files are generated, which linters you run, and whether the repo is one module or a workspace. Say those, and how to run one test.
Which commands should it list?
go build ./...every package;./...skipstestdata/,vendor/and dot or underscore directoriesgo test -race ./...all tests with the race detector;-count=1bypasses the test cachego test ./pkg/foo -run '^TestBar$'one test;-runis a regex,X/Ymatches subtestsgo vet ./...go testruns only a high-confidence subset of vet's checksgolangci-lint runreads.golangci.yml(or.yaml,.toml,.json); pin the versiongofmt -l .lists unformatted files; orgoimports, which also fixes importsgo generate ./...never run bygo buildorgo test; rerun after changing its inputsgo mod tidyafter adding or removing an import; syncsgo.modandgo.sum
Write them as your repo runs them, with its package manager and flags, plus how to run one test.
What layout should it explain?
- The module path in
go.mod, and whether ago.workties several modules together (go env GOWORKshows the one in use). - Where commands live, usually
cmd/<name>/, and what is underinternal/: only code below its parent can import it. - Which files are generated, and the
//go:generateline or tool that makes each.
What do agents get wrong?
- A file that starts with
// Code generated … DO NOT EDIT.is overwritten by the nextgo generate; edit its input instead. - Commit generated files: clients build without running
go generate. go.workis usually left out of git, so CI tests each module as others will use it; say so if yours is committed.
From the official docs: pkg.go.dev/go (new tab) · go.dev/layout (new tab) · go.dev/mod (new tab) · go.dev/generate (new tab) · golangci-lint.run/file (new tab) · pkg.go.dev/goimports (new tab). The rest of the file is the same for any project: what goes in an AGENTS.md.
Go repos with an AGENTS.md or CLAUDE.md (23)
23 of the 40 Go repos on the leaderboard have an AGENTS.md or CLAUDE.md at the root, and 21 are long enough to pass the AGENTS.md check in full. Most-starred first; each file name links to the file.
| Repo | File | Length |
|---|---|---|
| ollama/ollama | AGENTS.md | 357 chars |
| kubernetes/kubernetes | AGENTS.md | 1,884 chars |
| gohugoio/hugo | AGENTS.md | 1,711 chars |
| caddyserver/caddy | AGENTS.md | 9,429 chars |
| moby/moby | AGENTS.md | 553 chars |
| prometheus/prometheus | AGENTS.md | 6,664 chars |
| traefik/traefik | AGENTS.md | 14,368 chars |
| go-gitea/gitea | AGENTS.md | 3,435 chars |
| cli/cli | AGENTS.md | 5,858 chars |
| milvus-io/milvus | AGENTS.md | 11,250 chars |
| pingcap/tidb | AGENTS.md | 14,515 chars |
| labstack/echo | CLAUDE.md | 3,132 chars |
| cockroachdb/cockroach | CLAUDE.md | 5,664 chars |
| charmbracelet/crush | AGENTS.md | 10,951 chars |
| vitessio/vitess | AGENTS.md | 1,237 chars |
| nats-io/nats-server | AGENTS.md | 2,185 chars |
| weaviate/weaviate | CLAUDE.md | 5,912 chars |
| google/osv-scanner | AGENTS.md | 4,648 chars |
| inngest/inngest | AGENTS.md | 2,782 chars |
| gitlab-org/gitlab-runner | AGENTS.md | 12,818 chars |
| gitlab-org/cli | AGENTS.md | 7,602 chars |
| gitlab-org/gitaly | AGENTS.md | 2,362 chars |
| privy-io/go-sdk | AGENTS.md | 3,533 chars |
More examples
- Every language: all 226 files, with the longest and shortest that pass
- Most agent-friendly Go repos: all 40, ranked on every check
- AGENTS.md vs CLAUDE.md: which file to write
- TypeScript (64)
- Python (29)
- Rust (24)
- Java (19)
- C++ (11)
- JavaScript (9)
- Kotlin (8)
- PHP (7)
- Ruby (6)