# AGENTS.md: what it is and how to write one

Ahmet Karaca · 17 October 2026 · Updated 8 November 2026 · https://coredence.com/guides/agents-md

AGENTS.md is an open format: a Markdown file in a repository that tells coding agents how to work on it. Codex, Cursor and Copilot read it; Claude Code and Gemini CLI can. It can be thought of as a README for agents.

## What is AGENTS.md?

AGENTS.md is a Markdown file at the root of a repository that tells coding agents how to build and test the project, which conventions to keep and what not to touch. It is stewarded by the Agentic AI Foundation under the Linux Foundation. agents.md lists more than twenty agents that read it, among them OpenAI Codex, GitHub Copilot's coding agent, Cursor, Gemini CLI and Jules, and says over 60,000 open-source projects use the format.

There is no required structure. Plain headings and short lists work best, because the agent reads the whole file every time.

## How do nested and personal files work?

- In a monorepo, each package can have its own AGENTS.md. The file closest to what is being edited wins, and what you type in the chat overrides all of them.
- Codex reads files from the repository root down to the current folder and joins them in that order, so a closer file has the last word. It stops adding files at 32 KiB by default. A file named `AGENTS.override.md` is read in place of `AGENTS.md` in the same folder.
- Codex also reads a personal file before any project one: `~/.codex/AGENTS.md` in your home folder. That is the place for how you work, as opposed to how the project works.

Claude Code reads AGENTS.md too, since v2.1.277, but only when there is no `CLAUDE.md` or `CLAUDE.local.md` in your working folder or above it; your personal `~/.claude/CLAUDE.md` does not count against it. If both exist, it reads `CLAUDE.md` alone. To share one file, put an `@AGENTS.md` line in your [`CLAUDE.md`](https://coredence.com/guides/claude-md), or change Project instructions in `/config`.

## AGENTS.md or CLAUDE.md: which tool reads which file?

| Tool | Reads AGENTS.md | Its own file | Personal file |
| --- | --- | --- | --- |
| Codex | Yes, from the repository root down to the current folder | AGENTS.md is its file | `~/.codex/AGENTS.md` |
| Claude Code | Only when no `CLAUDE.md` is found, or through `@AGENTS.md` | `CLAUDE.md` | `~/.claude/CLAUDE.md` |
| Cursor | Yes, at the root and in subfolders | `.cursor/rules/` | User Rules in settings |
| Copilot in VS Code | Yes, at the root and in nested folders | `.github/copilot-instructions.md` | `~/.copilot/copilot-instructions.md` |
| Gemini CLI | When `context.fileName` lists it | `GEMINI.md` | `~/.gemini/GEMINI.md` |

So the choice is rarely one or the other. A repository used with several agents can keep AGENTS.md as the single shared file and give Claude Code a one-line `CLAUDE.md` that says `@AGENTS.md`. A repository used only with Claude Code needs only `CLAUDE.md`. The [instruction files guide](https://coredence.com/guides/instruction-files) compares all five in more detail.

## Why is AGENTS.md not being read?

- Claude Code: a `CLAUDE.md` or `CLAUDE.local.md` exists in your folder or above it, so Claude reads that instead. Add `@AGENTS.md` to it.
- Codex: an `AGENTS.override.md` in the same folder takes its place, an empty file is skipped, and nothing is added once the files together pass 32 KiB.
- Cursor: rules in `.cursor/rules` are separate; a plain `.md` file placed there is ignored, while AGENTS.md at the root is read.
- VS Code: the agent picked in the chat decides which files are read. Run Chat: Open Customizations to see what the current session found.
- Gemini CLI: it reads `GEMINI.md` unless `context.fileName` in `settings.json` names AGENTS.md as well.

## What is worth writing in it?

Commands the agent cannot guess, conventions it would otherwise break, and the things you keep correcting. A sentence earns its place when it changes what the agent does; a sentence that restates good practice in general costs reading time on every request and changes nothing.

```
# Project

## Commands
- Install: pnpm install
- Test: pnpm test
- Lint before every commit: pnpm lint

## Conventions
- TypeScript strict mode
- Do not edit generated files under dist/
```

Preferences about yourself belong in your personal file instead. A preference committed to a shared repository becomes everyone's rule.

```
# How I work

- Ask before deleting files or running destructive commands.
- Plan in a few lines before touching more than three files.
- Write commit messages in the language the repository already uses.
```

## Where Coredence fits

The personal part is the hard part to write, because it comes from months of corrections spread across every assistant you use. Coredence measures it instead: it reads your own sessions, commits and notes, consolidates them into memories about how you work, and keeps each one tied to the traces it grew from. If you turn it on, it writes your mind into `~/.codex/AGENTS.md` and refreshes it every cycle, in its own marked section, leaving what you wrote there yourself untouched. Claude Code, Copilot and Gemini get the same mind in their own files.

Coredence runs on macOS 14 or later (Apple silicon) and Windows 10 or later, with no Coredence account. Consolidation needs a model, and you choose it: your Claude Code subscription, your own API key, or a local model through Ollama. On those paths Coredence itself is free to use. It is not open source. If you would rather not bring a key, its own [paid plans](https://coredence.com/pricing) include the model.

## Sources, checked on 8 November 2026

- [agents.md](https://agents.md/)
- [OpenAI: Custom instructions with AGENTS.md](https://learn.chatgpt.com/docs/agent-configuration/agents-md)
- [Cursor docs: Rules](https://cursor.com/docs/context/rules)
- [Claude Code docs: AGENTS.md](https://code.claude.com/docs/en/memory#agents-md)
