How to structure an AGENTS.md for a corporate repository
AGENTS.md started from a simple premise: "a simple, open format for guiding coding agents" - one predictable place where a coding agent looks for instructions before touching a repository. The real question engineering teams face isn't whether to have one, but what to put inside it so it actually works.
What 2,500+ repositories teach us
A GitHub analysis of more than 2,500 repositories with an agents.md reached a clear conclusion: "the successful agents aren't just vague helpers; they are specialists." Generic descriptions like "helpful coding assistant" don't produce better results - what works is specific instruction with clear boundaries. The study identified six blocks that consistently show up in the most effective AGENTS.md files:
- Executable commands -
npm test,npm run build, and equivalents, ready to copy and paste - Project structure - where everything lives, without forcing the agent to explore
- Tech stack with versions - not "React," but "React 18," "TypeScript 5," and so on
- Real code examples - show the expected pattern, don't just describe it
- Style patterns - naming and formatting conventions
- Clear boundaries - what the agent can do alone, what needs approval, what it should never do
Among the identified restrictions, the most common and most useful was simply "never commit secrets" - a short line that prevents one of the costliest mistakes an agent can make.
Why structure matters at scale: the Codex case
How much this matters becomes clear in an experiment OpenAI documented itself: a repository that started empty in August 2025, with the initial scaffold generated by Codex CLI (GPT-5) - even the initial AGENTS.md itself was written by an agent. Five months later, the repository held roughly a million lines of code, with more than 1,500 pull requests merged, produced by just three engineers driving agents - an average of 3.5 PRs per engineer per day. No line was written manually by a human.
The central lesson from that experiment is what OpenAI calls "legibility": the repository needs to be optimized so an agent can understand the entire business domain from the code and documentation itself - without relying on tacit context. When architecture decisions lived only in Slack conversations, they were as invisible to the agent as they would be to a new hire on day one. The fix was bringing that context into the repository itself, where the agent actually looks.
A reference structure
Combining the 2,500-repository research with the agents.md open format, a consistent corporate AGENTS.md covers, in practice:
- Project goal and business domain
- Architecture and adopted patterns
- Local setup (step by step, assuming no prior knowledge)
- Allowed commands (build, test, lint, deploy)
- Required tests before any PR
- Code style and naming conventions
- Security rules (starting with "never commit secrets")
- Explicit restrictions - what the agent should never do on its own
- Expected pull request flow
- Acceptance criteria for considering a task done
The practical point
An AGENTS.md isn't documentation you write once and forget - it's a living artifact, versioned as tightly as the code it governs. Teams that treat this file as part of the architecture, not a footnote, are the same ones that manage to scale from "one agent helping with a task" to "agents driving real delivery," as in the case OpenAI documented.
Sources
- GitHub - How to write a great AGENTS.md - https://github.blog/ai-and-ml/github-copilot/how-to-write-a-great-agents-md-lessons-from-over-2500-repositories/
- AGENTS.md - https://github.com/agentsmd/agents.md
- OpenAI - Harness engineering: leveraging Codex in an agent-first world - https://openai.com/index/harness-engineering/