---
title: "How to Write an AGENTS.md File"
url: "https://atlan.com/know/how-to-write-agents-md/"
description: "Generate a complete AGENTS.md free in one click, then tune it with this guide: commands, boundaries, data sections, and catalog-connected living updates."
author: "Emily Winks"
author_role: "Data Governance Expert"
published: "2026-04-13"
updated: "2026-09-21T00:00:00.000Z"
---

## How do you write an AGENTS.md file?

Writing an AGENTS.md file means documenting exact executable commands, three-tier boundaries, project structure, code style, and testing rules that an agent runtime loads at session start. For data agents, add certified data sources, PII constraints, ownership contacts, and business rules. The ETH Zurich study of context files found instructions are followed well while repository overviews are not helpful, so keep the file short and connect data sections to a governed metadata layer.

Core sections:

- **Commands** - exact executable commands with flags, not just tool names
- **Boundaries** - three-tier model: Always do / Ask first / Never do
- **Project Structure** - flat file map with purpose annotations
- **Code Style** - executable snippets, not prose descriptions
- **Testing** - framework, mocking strategy, coverage thresholds
- **Git Workflow** - branch naming, commit format, PR conventions
- **Data Sections** - certified sources, contracts, PII constraints, ownership, business rules

## Key takeaways

- AGENTS.md is a runtime instruction set loaded into the agent context window - not documentation for humans.
- Write instructions, not overviews: the ETH Zurich study found instructions are followed and overviews are not.
- Data sections written from memory drift within weeks; connect to a data catalog API for living, certified updates.

Atlan's Enterprise Data Graph gives data agents a versioned, governed source for certified table names, PII classifications, business rules, and ownership contacts, the same organizational knowledge that AGENTS.md files try to encode manually, delivered automatically and kept current. Writing an AGENTS\.md file -- a machine-readable context file loaded at session start by coding and data agents -- takes under an hour for a first version, but getting it right takes deliberate choices, and the evidence says an unconsidered file costs you more than it returns. This guide walks through every section: from Commands and Boundaries to the data-specific sections (Data Sources, Data Contracts, Ownership) that matter most when your agent touches production data.

---

## Why writing AGENTS\.md correctly matters

AGENTS\.md is not documentation -- it's a runtime instruction set loaded directly into the agent's context window. The ETH Zurich evaluation of context files found they do not generally improve task success, for LLM-generated and developer-committed files alike, so what goes in one has to be chosen deliberately.

Context window is finite. The same evaluation measured context files adding over 20% to inference cost on average, so every token spent on principles the agent already knows is paid for twice. More common failure: agents working with stale table names, informal column definitions written from memory, ownership entries like "Ask Priya if confused." When a harness fails in production, root cause is almost never the architecture -- it's the data inside the context file.

The AGENTS\.md standard is now stewarded by the Agentic AI Foundation under the Linux Foundation. Compatible with every major agent runtime: Cursor, Codex, Copilot, Claude Code, Devin, Windsurf, Gemini CLI. The one thing the evidence does support: instructions in a context file are followed well, while repository overviews, the section model providers recommend most, are not helpful.

Who should do this: engineers and data teams deploying agents against real production systems. If you're just getting started, read [What Is an Agent Harness?](https://atlan.com/know/what-is-an-agent-harness/) and [How to Build an AI Agent Harness](https://atlan.com/know/how-to-build-ai-agent-harness/) first.

---

## Prerequisites

**Organizational prerequisites:**

- [ ] **A deployed or in-flight agent:** AGENTS\.md only makes sense once you know what the agent will actually do.
- [ ] **Access to the project's canonical documentation:** README, schema docs, data dictionaries -- not to copy in, but to know what to exclude.

**Technical prerequisites:**

- [ ] **Agent runtime installed and configured:** one of Cursor, Codex, Claude Code, Copilot, Devin, Windsurf, or Gemini CLI.
- [ ] **Write access to repository root** (and subdirectories for per-directory overrides).
- [ ] **For data agents: certified table names and schema versions.** If not in your data catalog, flag before writing.
- [ ] **Git installed.**

**Team and resources:**

- **Engineer or data engineer owner (5-10% FTE):** Commands and Boundaries need someone who knows the project.
- **Data steward or governance contact (for data agents):** Needed to validate Data Sources, Data Contracts, and Ownership sections.

**Time commitment:**

- Commands + Boundaries + Structure: 30-45 minutes
- Testing + Git Workflow: 15-30 minutes
- Data-specific sections: 45-60 minutes
- Connecting to data catalog for living updates: 30-60 minutes (one-time setup)
- Total: 45 minutes (basic) to 3 hours (full data-agent file)

---

---

## What NOT to include in AGENTS\.md

The fastest way to improve an AGENTS\.md file is often to delete from it. Duplicating README content adds to the over-20% inference-cost increase the ETH Zurich evaluation measured, with no offsetting gain in task success.

| What to exclude | Why |
|---|---|
| Generic software engineering principles | Agents already know from training -- "write clean, readable code" wastes tokens |
| Content duplicating README.md | Adds to the over-20% average inference-cost increase measured by ETH Zurich, with no task-success gain |
| Architectural overviews without file pointers | "We use a microservices pattern" tells the agent nothing actionable |
| Prose descriptions of code style | A 3-line code example is more precise than a paragraph |
| Informal table names written from memory | Will drift; use certified names from data catalog |
| LLM-generated content | No general task-success improvement in the ETH Zurich evaluation, same as developer-committed files |

---

## AGENTS\.md vs CLAUDE.md vs .cursorrules

These serve different runtimes and have different precedence models.

| | AGENTS\.md | CLAUDE.md | .cursorrules |
|---|---|---|---|
| Runtime compatibility | Cursor, Codex, Claude Code, Copilot, Devin, Windsurf, Gemini CLI | Claude Code only | Cursor only |
| Standard body | Agentic AI Foundation / Linux Foundation | Anthropic | Cursor |
| Precedence model | Hierarchical: subdirectory overrides root | Single file, session-scoped | Single file |
| Max size | 32 KiB default, 150 lines recommended | No hard limit | No hard limit |
| Best for | Cross-runtime, multi-agent projects | Claude-only workflows | Cursor-primary workflows |
| Data sections support | Native (community-standardized) | Custom (no standard) | Custom (no standard) |
| Recommendation | Use as primary standard for any multi-agent setup | Add for Claude-specific overrides | Maintain only if Cursor-only team |

Teams using Claude Code can use AGENTS\.md and CLAUDE.md in parallel -- AGENTS\.md for cross-runtime shared rules, CLAUDE.md for Claude-specific overrides. They don't conflict; they layer. For broader context on harness file standards, see [What Is Harness Engineering?](https://atlan.com/know/what-is-harness-engineering/)

---

## How a governed metadata layer powers data-aware AGENTS\.md

Most AGENTS\.md data sections are written once and never updated. A governed metadata layer turns them into a living contract -- auto-populated from certified assets, data classifications, stewardship assignments, lineage graphs, and business glossary definitions. The result is an AGENTS\.md that stays accurate as schemas evolve.

Writing data sections by hand means translating a mental model of the data layer into markdown. Engineers pull table names from memory, copy constraint lists from stale Confluence pages, write business rule definitions by paraphrase. Accurate on day one. Three months later: `certified_orders_v2` becomes `orders_v3`, PII classification expands to cover a new column, a glossary term gets a corrected definition -- none of which surfaces in AGENTS\.md until an agent makes a wrong call in production.

MCP and REST APIs from a mature data catalog expose the exact metadata layers that populate every data section. Data Sources: certified table names, column definitions, and schema versions from the active metadata layer, filtered by certification status. Constraints: data classifications (PII, Restricted, Confidential) and access policies from the classification engine, written directly into the Never do tier. Ownership: programmatic stewardship assignments from the stewardship layer. Data quality thresholds: DQ scores and SLAs per asset. Lineage pointers: upstream/downstream lineage auto-resolved from the lineage graph. Business Rules: certified, versioned definitions from the business glossary. CI/CD automation queries the catalog via REST API and regenerates data sections on a schedule, committing diffs to a feature branch for engineer review.

In Atlan's own analysis of the Workday deployment, shared semantic models built on a governed catalog produced a 5x improvement in AI response accuracy. The principle is the same for AGENTS\.md: the file should reference the canonical rule, not create parallel governance. An AGENTS\.md written from memory is a liability in production. An AGENTS\.md populated from your data catalog is a living contract.

For more on how governed metadata connects to AI systems, read [Data Catalog as LLM Knowledge Base](https://atlan.com/know/data-catalog-as-llm-knowledge-base/), [The Context Catalog](https://atlan.com/know/context-catalog/), [Active Metadata 101](https://atlan.com/active-metadata-101/), and [The Metadata Layer for AI](https://atlan.com/know/metadata-layer-for-ai/).

---

## Putting it all together

A well-written AGENTS\.md is the difference between an agent that operates with surgical precision and one that makes plausible-but-wrong decisions at every data join.

The 7 steps build on each other. Static sections -- Commands, Boundaries, Code Style -- are written once by engineers who know the project. Data sections are most durable when generated from a governed metadata layer, not maintained by hand. The file should be treated as an artifact with a provenance chain: who certified the table, who owns the schema, what the business rule actually means.

Start with the minimum viable file: Commands and Boundaries, correctly specified, get you 80% of the value. Add data sections for any agent that touches production tables. Connect to a catalog API when the team is ready to stop maintaining those sections manually.

Next: [How to Build an AI Agent Harness](https://atlan.com/know/how-to-build-ai-agent-harness/) covers the broader harness architecture that AGENTS\.md fits into. [What Is Harness Engineering?](https://atlan.com/know/what-is-harness-engineering/) gives strategic context on why the harness matters more than the model.

---

## What makes a great AGENTS\.md

- AGENTS\.md is a runtime instruction set, not documentation -- every token you waste on principles the agent already knows reduces inference quality and increases cost.
- Write instructions, not overviews: instructions are followed well, repository overviews are not helpful.
- The three-tier Boundaries model (Always do / Ask first / Never do) is the most battle-tested pattern in production -- the Never do tier must name specific tables and columns, not general principles.
- Data sections (Data Sources, Constraints, Ownership, Business Rules) are where most teams introduce technical debt that surfaces months later as PII exposure or hallucinated column names.
- Context files do not generally improve task success and add over 20% to inference cost, so evaluate yours before relying on it.
- The most durable data sections are generated from a governed metadata layer -- a catalog API -- not maintained by hand.
- AGENTS\.md is the cross-runtime standard. Add CLAUDE.md for Claude-specific overrides. Maintain .cursorrules only for Cursor-primary teams.

Book a Demo

---

## FAQs about AGENTS\.md file explained how to write

### 1. What is an AGENTS\.md file and what does it do?

An AGENTS\.md file is a machine-readable context file placed at the root (or in subdirectories) of a code repository. Agent runtimes -- including Cursor, Codex, Claude Code, Copilot, Devin, Windsurf, and Gemini CLI -- load it at session start and use its contents as a persistent instruction set. It documents the commands agents should run, the boundaries they must respect, the project structure they will navigate, and -- for data agents -- the certified data sources, PII constraints, ownership contacts, and business rules they must follow. Unlike a README, which is written for humans and summarized by agents, AGENTS\.md is written as direct, executable guidance for the agent itself.

### 2. How long should an AGENTS\.md file be?

The technical maximum is 32 KiB. In practice, aim for under 150 lines. The ETH Zurich evaluation found context files add over 20% to inference cost on average without generally improving task success. Start lean: Commands and Boundaries in 40-60 lines is a viable first file. Add data sections for data agents. The temptation to include everything should be resisted -- the fastest way to improve an existing AGENTS\.md is often to delete from it.

### 3. What sections should I include in my AGENTS\.md?

For any agent: Commands (exact executable commands with flags), Boundaries (three-tier Always do / Ask first / Never do), Project Structure (flat file map with purpose annotations), Code Style (snippets, not prose), Testing (framework, mocking strategy, coverage thresholds), and Git Workflow. For data agents, add: Data Sources (certified table names with schema versions), Data Contracts (active contracts and SLAs), Constraints (explicit PII column names), Ownership (named human contacts), and Business Rules (certified definitions from the glossary). The data sections are the most frequently neglected and the most commonly responsible for production failures.

### 4. What is the difference between AGENTS\.md and CLAUDE.md?

AGENTS\.md is a cross-runtime standard stewarded by the Agentic AI Foundation under the Linux Foundation. It is compatible with Cursor, Codex, Claude Code, Copilot, Devin, Windsurf, and Gemini CLI. CLAUDE.md is a file recognized only by Claude Code. AGENTS\.md uses a hierarchical precedence model where subdirectory files override the root. CLAUDE.md is session-scoped to a single file. Teams using Claude Code can use both: AGENTS\.md for shared cross-runtime rules, CLAUDE.md for Claude-specific overrides. They layer without conflicting.

### 5. What is the difference between AGENTS\.md and .cursorrules?

.cursorrules is recognized only by Cursor. AGENTS\.md is compatible with all major agent runtimes. Both are placed at the repository root and loaded at session start, but AGENTS\.md supports a hierarchical precedence model (subdirectory files override root), while .cursorrules does not. For Cursor-only teams, .cursorrules is a reasonable choice. For any team using more than one agent runtime -- or planning to -- AGENTS\.md is the correct primary standard. .cursorrules can be maintained as a Cursor-specific supplement if needed.

### 6. Can I auto-generate AGENTS\.md using an LLM?

Technically yes, but the ETH Zurich evaluation found no general task-success gain from context files, LLM-generated or developer-committed. The problem is that LLMs filling in AGENTS\.md from general knowledge duplicate information agents already have, add to the over-20% inference-cost increase, and often produce vague directives that don't translate to actionable behavior. The exception is auto-generating data sections from a governed catalog API -- that approach produces certified, versioned content that no human should maintain by hand. The Commands, Boundaries, and Code Style sections must be written by engineers who know the project.

### 7. Does an AGENTS\.md file actually improve AI agent performance?

Not automatically. The ETH Zurich evaluation of AGENTS\.md found context files do not generally improve task success rates and add over 20% to inference cost, and that this held for developer-committed and LLM-generated files alike. What it did find: instructions in a context file are followed well, while repository overviews, the section model providers recommend most, are not helpful. So the quality of the file -- specificity, correctness, absence of bloat -- matters more than the presence of the file, and any performance claim you make about your own file should be measured, not assumed.

### 8. What should I never put in an AGENTS\.md file?

Never include generic software engineering principles the agent already knows from training -- "write clean, readable code," "follow best practices." Never duplicate content from README.md; it increases inference costs without improving performance. Avoid architectural overviews without concrete file pointers. Avoid prose descriptions of code style -- use executable snippets instead. For data agents, never include informal table names written from memory; they drift. Never use an LLM to generate the full file. The goal is specificity: instructions the agent could not infer from training, written in the most concise form possible.

---

## Sources

1. "Evaluating AGENTS\.md: Are Repository-Level Context Files Helpful for Coding Agents?", ETH Zurich, arXiv: https://arxiv.org/abs/2602.11988
2. Agentic AI Foundation, Linux Foundation: https://www.linuxfoundation.org/

## Next steps

- To see Atlan's context layer in action first, watch a recorded demo: [Atlan context layer demos](https://atlan.com/context-layer-demo/)
- To see Atlan working on your own data stack, book a demo: [Book a demo with Atlan](https://atlan.com/forms/talk-to-sales-contact/)
