Write an AGENTS.md That Works Across Codex, Cursor and Claude
For when your repo has a CLAUDE.md, a .cursorrules and an AGENTS.md that all say slightly different things, and the agents follow whichever one is out of date. Paste your commands and existing rule files. It merges them into one short AGENTS.md with exact commands first, a clear definition of done and a reason for every rule, adds a CLAUDE.md that imports it, and lists the duplicates it removed and the paths to watch for drift.

You are a senior engineer who writes AGENTS.md files that every coding agent on a team can share. I want one AGENTS.md for my repo that works across Codex, Cursor, Claude Code and whatever else we use, as the single source of truth instead of three copies (CLAUDE.md, .cursorrules, AGENTS.md) that drift apart. My current setup has the usual problems: the same rule copied into several files with different wording, a test command that was renamed in one file but not the others, and a file that grew every time an agent disobeyed until it was hundreds of lines long and the agents started ignoring the rules buried in the middle. Stale rules are worse than none, because the agent treats them as current. HARD RULES: 1. ONE SOURCE. AGENTS.md holds the shared rules. Other tool files either import it or hold only what is genuinely specific to that tool. Never copy the same rule into two files. 2. COMMANDS FIRST. Put exact, copy-pasteable commands near the top (install, dev, build, full test suite, a single test, lint, typecheck). Organise the rest by task, not by topic. 3. SHORT. Aim for under 100 lines and never go over 200. If my input would push it longer, move package-specific rules into nested AGENTS.md files (the nearest one to the file being edited wins) or into docs the file points to, and tell me which. 4. SPECIFIC, WITH A REASON. Every rule is a direct instruction with a concrete command, path or name, followed by a few words on why. A rule with no "why" is one nobody dares to delete later. Cut vague lines like "write clean code", "follow best practices" or "be careful". 5. NEVER INVENT. Use only the commands, paths, tools and rules I give you. If something is missing or unclear, write [CONFIRM: ...] instead of filling the gap with the usual default for my stack. 6. DONE MEANS SOMETHING. Include an explicit "done" checklist: the exact commands that must pass before a task counts as finished. 7. CHECKS DO THE ENFORCING. Formatting a linter can enforce stays out of the file. Rules that must never be broken get one line in the file AND a suggested hook, CI check or linter config, because a rule in a Markdown file is a request, not enforcement. 8. CLAUDE CODE SAFELY. Claude Code treats CLAUDE.md as its own instruction file, and whether it also picks up AGENTS.md depends on the version and on which other files are present, so do not count on it. Always give me a CLAUDE.md whose first line is @AGENTS.md, with only Claude-specific notes below it. Do not recommend a symlink as the default: some editing tools will not write through it, Windows clones can check it out as a plain text file, and a tool that reads both files may load the same rules twice. 9. CURSOR SCOPED RULES STAY SCOPED. Cursor reads AGENTS.md and .cursor/rules/*.mdc as separate sources. The shared baseline goes in AGENTS.md; rules that only apply to certain globs can stay in .mdc files, as long as they do not repeat AGENTS.md. BEFORE WRITING, ask me these in one short batch and STOP: 1. What the project is in one sentence, plus the stack, versions and package manager. 2. The exact commands for install, dev, build, test (full suite and a single test), lint or format, and typecheck. Pasting package.json scripts or a Makefile is fine. 3. Which agents the team actually uses (Codex, Cursor, Claude Code, Copilot, Gemini CLI, Aider, Windsurf, others). 4. Every existing instruction file (CLAUDE.md, .cursorrules, .cursor/rules, copilot-instructions.md, GEMINI.md, an old AGENTS.md). Paste them so you can merge and de-duplicate instead of starting from scratch. 5. Is it a monorepo? If so, which packages have rules that differ from the root. 6. The mistakes agents keep making in this repo, in my own words. 7. The rules that must never be broken, the hooks, CI or linters already in place, and the PR or commit rules. Then reply using exactly these sections: AGENTS.MD: the complete root file in one markdown code block, using these headings: # Project (1 to 2 lines), ## Commands, ## Project structure (only what is not obvious from the code), ## Code style (only what no linter enforces), ## Testing, ## Security, ## PR and commit rules, ## Done means. Leave out any section with nothing real in it. NESTED FILES: each nested AGENTS.md with its path and contents, or "none needed". CLAUDE.MD: one code block whose first line is @AGENTS.md, followed only by Claude-specific notes, or nothing else if there are none. TOOL WIRING: one line per agent I use: whether it reads AGENTS.md natively or needs a config setting (give the setting as a suggestion for me to verify), and which existing files to delete or keep. LINE COUNT: lines in the root AGENTS.md. DUPLICATES AND CONFLICTS: every rule that appeared in more than one of my files, which wording you kept, and any contradiction you resolved or need me to resolve. MOVE TO CHECKS: each never-break rule paired with the kind of hook, CI check or linter config that would enforce it, as a suggestion, not a finished script. CUT AND WHY: everything from my input you left out, one line each, with the reason (vague, discoverable from code, linter's job, package-specific, duplicate, stale). PATHS TO WATCH: every file path and script name the file mentions, so I can add a CI check that fails when one is renamed and a rule silently stops applying. CONFIRM: every [CONFIRM] placeholder still in the files. KEEP IT IN SYNC: 3 short triggers for when AGENTS.md needs editing, and a reminder to edit AGENTS.md rather than the tool-specific files. Plain text outside the code blocks, no intro, no pep talk. Here are my details: Project and stack: [FILL IN] Commands: [PASTE SCRIPTS OR LIST] Agents the team uses: [FILL IN] Existing instruction files: [PASTE OR "none"] Monorepo packages with different rules: [FILL IN OR "not a monorepo"] Mistakes agents keep making: [FILL IN] Never-break rules, existing checks, PR and commit rules: [FILL IN] Start with the questions.
How to use this chat prompt
Paste it directly into a new chat, replace anything in [BRACKETS] with your context, and send. Re-use it whenever the task comes up, or save it as a text-expander snippet.
Example output
pnpm TypeScript monorepo used with Codex, Cursor and Claude Code. Old CLAUDE.md and .cursorrules disagree on the test command. All seven questions answered.
# AGENTS.md: This is a TypeScript monorepo. Follow best practices and write clean code.
## Testing: Run the tests before committing.
Copy this file to CLAUDE.md and .cursorrules so every tool sees the same rules.
AGENTS.MD: ## Commands: `pnpm install`, single test `pnpm vitest run <file>`. ## Done means: `pnpm typecheck` and `pnpm lint` pass.
NESTED FILES: packages/api/AGENTS.md (never edit applied migrations, add a new one); apps/web needs none.
CLAUDE.MD: line 1 is @AGENTS.md, nothing else (no Claude-only rules given).
TOOL WIRING: Codex and Cursor read AGENTS.md natively; keep the two glob-scoped .mdc rules, delete .cursorrules.
DUPLICATES AND CONFLICTS: `npm test` vs `pnpm vitest`; kept pnpm, it matches package.json.
CUT AND WHY: "write clean code" (vague), folder tour (discoverable from code).
PATHS TO WATCH: packages/api/prisma/migrations/, scripts/seed.ts
FAQ
Frequently asked questions
What is an AGENTS.md file?
It is a README written for coding agents: a plain Markdown file at the root of your repo that tells tools like Codex, Cursor and GitHub Copilot's coding agent how to build, test and work in your project. There is no required schema or field list. The usual sections are a project overview, build and test commands, code style, testing, security and PR or commit rules, which is the structure this prompt fills in from your own details.
Does Claude Code read AGENTS.md?
Claude Code uses CLAUDE.md as its own instruction file. Support for reading AGENTS.md directly has varied between versions and can depend on whether a CLAUDE.md is also present, so it isn't something to rely on. The setup that works either way is a CLAUDE.md whose first line is @AGENTS.md, which imports the shared rules, with any Claude-only notes below it. The prompt always writes that file for you.
AGENTS.md vs CLAUDE.md: do I need both?
If anyone on the team uses Claude Code alongside other agents, yes, but only one of them should hold the rules. Keep the shared rules in AGENTS.md and make CLAUDE.md a short import of it plus anything genuinely Claude-specific. Copying the same rules into both is how they drift apart. If your team only uses Claude Code, the CLAUDE.md generator is the simpler fit.
Does Cursor read AGENTS.md, and what happens to .cursor/rules?
Cursor reads AGENTS.md natively and treats .cursor/rules/*.mdc files as a separate source. A common setup is to keep the shared baseline in AGENTS.md and leave only glob-scoped rules (for example, rules that apply to one app folder) in .mdc files. The prompt flags any .mdc rule that just repeats AGENTS.md so you can delete it.
How long should AGENTS.md be, and where does it go?
Put it at the repo root and keep it short: the prompt aims for under 100 lines and caps it at 200, because rules buried in the middle of a long file tend to get ignored. In a monorepo, package-specific rules go in a nested AGENTS.md inside that package, since the nearest file to the code being edited takes priority. Once it is written, paste it into a Markdown previewer to check the headings and code blocks render cleanly before you commit it.
Keep going
What's next
Collection
AI Agent & Markdown Files
For the instruction files coding agents read before they touch your repo: a CLAUDE.md that Claude Code actually follows, an AGENTS.md that works across Codex, Cursor and Claude, project rules files, and the build, test and style notes you keep repeating in every chat.
Tool
Markdown Live Preview
Paste markdown or drop a .md file and see it rendered instantly. Nothing leaves your browser.
Prompt
Generate a CLAUDE.md for Your Repo That Claude Code Actually Follows
For when Claude Code keeps making the same mistakes in your repo even though the rule is right there in CLAUDE.md. Give it your real commands, the parts of the structure that aren't obvious from the code, and the mistakes you keep correcting. It writes a short CLAUDE.md of specific rules with the important ones first, lists what it cut and why, and flags the never-break rules that belong in a hook or linter config instead of a polite request.