AGENTS.md vs CLAUDE.md vs Cursor Rules: One Project Instructions Setup
All three are plain-text instructions for AI coding agents: how to build, test and style your project. AGENTS.md is an open format read by many tools (OpenAI Codex, GitHub Copilot’s coding agent, Cursor and others). CLAUDE.md is Claude Code’s project memory file; Claude Code (v2.1.277+) can also read AGENTS.md directly when there is no CLAUDE.md. Cursor rules live in .cursor/rules/ as .mdc files with options for when they apply. Easiest setup: write one AGENTS.md, and make CLAUDE.md a one-line pointer to it.
Suppose Ishaan’s college team in Pune uses Codex, Cursor and Claude Code on one repo, and each tool kept guessing the test command. They write one AGENTS.md with build, test and style rules, add a tiny CLAUDE.md that imports it, and the agents stop guessing.
Related pages
See also Codex vs Claude Code, and Claude Code Skills Examples.
What you will learn in this guide
- What each file is
- Which tool reads which
- A starter AGENTS.md
- One source of truth
- What not to put inside
1. Why: agents guess when you do not tell them
Without instructions an agent guesses your test command and code style. A short instructions file gives better first attempts and fewer broken changes.
2. What: who reads what
| File | Read by |
|---|---|
| AGENTS.md (repo root) | Codex, GitHub Copilot coding agent, Cursor and many other agents |
| CLAUDE.md | Claude Code (project memory); Claude Code also reads AGENTS.md if no CLAUDE.md |
| .cursor/rules/*.mdc | Cursor, with always/auto/manual options |
| .github/copilot-instructions.md | GitHub Copilot custom instructions |
Figure 1. One instructions setup in five steps: write AGENTS.md, keep it short, point CLAUDE.md to it, add Cursor rules if needed, keep it updated.
3. How: set it up
- Create AGENTS.md at the repo root.
- Add sections: project, setup, test, style, do-not-touch.
- Create CLAUDE.md containing @AGENTS.md so Claude Code imports it.
- Use .cursor/rules only for extra, folder-specific rules.
- Commit and update whenever commands change.
4. Notes
- AGENTS.md is documented at agents.md as an open format supported by many agents.
- Claude Code docs (memory page): CLAUDE.md supports @path imports; AGENTS.md is read directly when no CLAUDE.md exists (v2.1.277+).
- Tool support changes; check each tool’s docs.
5. Worked example 1: starter AGENTS.md (start here)
Save at the repo root:
# AGENTS.md
## Project
Small Flask app for a library catalogue.
## Setup
- python -m venv .venv && source .venv/bin/activate
- pip install -r requirements.txt
## Test
- pytest -q (must pass before you finish)
## Style
- Python 3.11, black formatting, type hints on new functions
## Do not
- Do not edit migrations/ or .env
- Do not add new dependencies without asking
6. Worked example 2: CLAUDE.md pointer
Save as CLAUDE.md:
@AGENTS.md
# Claude-only notes
- Ask before running database commands.
Expected output (yours will be similar, not the same):
Claude Code loads AGENTS.md through the import, plus the extra note.
7. Worked example 3: a Cursor rule for one folder
Save as .cursor/rules/frontend.mdc:
---
description: Rules for the React frontend
globs: frontend/**/*.tsx
alwaysApply: false
---
- Use function components and hooks.
- Use Tailwind classes, no inline styles.
Expected output (yours will be similar, not the same):
When you edit a frontend .tsx file in Cursor, this rule is attached automatically.
Names, amounts and companies in the examples are made up for practice.
8. Common mistakes
| Mistake | Risk | Fix |
|---|---|---|
| Three different files saying different things | Agents disagree | One source of truth |
| Very long files | Ignored details | Keep it short |
| Secrets or keys inside | Leak via git | Never |
| Stale test command | Broken runs | Update with code |
| Vague rules like “write good code” | No effect | Be specific |
9. Try at home
Try at home
- Write a 15-line AGENTS.md.
- Add CLAUDE.md with @AGENTS.md.
- Ask an agent to run the tests.
Recap
In short
- All three are instructions for agents.
- AGENTS.md is the shared open format.
- CLAUDE.md is Claude Code’s file; import AGENTS.md.
- Cursor rules add folder-specific rules.
- Short, specific, updated, no secrets.
One clear file beats three confused ones.
Frequently asked questions
Do I need all three?
No. Start with AGENTS.md; add CLAUDE.md as a pointer if you use Claude Code.
Does Cursor read AGENTS.md?
Cursor documents AGENTS.md support alongside its rules. Check Cursor docs for the latest.
Can I have AGENTS.md in subfolders?
Many tools read the nearest AGENTS.md to the file being edited.
Is .cursorrules still used?
Cursor now prefers .cursor/rules; older .cursorrules may still work but is legacy.