CLAUDE.md vs AGENTS.md vs .cursor/rules: What Each Does, and What None of Them Remember
CLAUDE.md, AGENTS.md and .cursor/rules compared: who reads what, how they scope instructions, and the gap none of them fill: what happened last session.
On this page
- Quick answers
- What is the difference between CLAUDE.md, AGENTS.md and .cursor/rules?
- What does CLAUDE.md do?
- What does AGENTS.md do, and does Claude Code read it?
- What does .cursor/rules do?
- Which file should I use?
- How do I avoid the common mistakes?
- What do these files not remember?
- How do you cover that gap?
- FAQ
- What is the difference between CLAUDE.md and AGENTS.md?
- Does Claude Code read AGENTS.md?
- Does Cursor read AGENTS.md?
- Is .cursorrules deprecated?
- Do I need both CLAUDE.md and AGENTS.md?
- Does Claude Code have to follow CLAUDE.md?
- How long should these files be?
- Do these files remember what happened in the previous session?
- Where do my personal instructions go?
- What happens to CLAUDE.md after /compact?
- Sources
CLAUDE.md is Claude Code's instruction file. AGENTS.md is a plain-markdown file several tools read, including Cursor, and Claude Code v2.1.277+ when no CLAUDE.md exists. .cursor/rules holds Cursor's scoped rules. All three store instructions you wrote. None records what happened last session, what is tested, or what is half-done.
Last verified against the official docs on November 24, 2026 · Written by Kumar, founder of Causly. These tools change quickly, so check the linked docs. Disclosure: I build PCSKit, which appears in one section near the end.
Quick answers#
CLAUDE.md | AGENTS.md | .cursor/rules | |
|---|---|---|---|
| Read by | Claude Code | Cursor. Claude Code v2.1.277+, only when no CLAUDE.md is found | Cursor |
| Format | Plain markdown | Plain markdown, no frontmatter | .mdc files with frontmatter |
| Scoping | By directory. Path-scoped rules via .claude/rules/ | By directory (nested files) | globs, a description, always-on, or manual |
| Best for | Claude-specific instructions | One shared file for several tools | Conditional, file-type-specific rules in Cursor |
| Remembers last session? | No | No | No |
What is the difference between CLAUDE.md, AGENTS.md and .cursor/rules?#
They solve the same problem: a model starts each conversation knowing nothing about your project, so you write down what it should know. Claude Code's docs say it plainly: each session begins with a fresh context window, and CLAUDE.md is one of the ways knowledge carries across sessions. Cursor's docs make the same point from the other side: large language models don't retain memory between completions, so rules give the agent persistent context at the prompt level.
The three files differ in who reads them and how they scope instructions:
CLAUDE.mdis Claude Code's own format.AGENTS.mdis a plain markdown file meant to be shared across tools..cursor/rulesis Cursor's richer format, with conditions for when a rule applies.
What does CLAUDE.md do?#
CLAUDE.md gives Claude Code persistent instructions for a project, for you personally, or for a whole organization. According to the Claude Code docs, the locations are:
| Scope | Location |
|---|---|
| Managed policy | An OS-level path set by your organization |
| User | ~/.claude/CLAUDE.md |
| Project | ./CLAUDE.md or ./.claude/CLAUDE.md |
| Local | ./CLAUDE.local.md (add it to .gitignore) |
A few behaviours are worth knowing:
- Files are concatenated, not overridden. Claude walks up from the working directory and loads each
CLAUDE.mdit finds. More specific files appear later in context. - Subdirectory files load on demand. A
CLAUDE.mdbelow your working directory is included when Claude reads files in that subdirectory. - Path-scoped rules live in
.claude/rules/. A rule file withpathsfrontmatter loads only when Claude reads a matching file:
---
paths:
- "src/api/**/*.ts"
---
- All API endpoints must validate input
- Imports.
@path/to/filepulls another file in, up to four hops deep. - It is context, not enforcement. The docs say Claude treats these files as context, delivered as a user message after the system prompt, so there is no guarantee of strict compliance. For something that must always happen or never happen, use a hook (such as a PreToolUse hook), not a sentence in CLAUDE.md.
- Keep it short. The docs recommend under 200 lines per file, because longer files use more context and reduce adherence.
- It survives compaction. After
/compact, the project-rootCLAUDE.mdis re-read from disk. Nested files are not re-injected automatically (see the context window docs).
What does AGENTS.md do, and does Claude Code read it?#
AGENTS.md is a plain markdown file with no metadata, meant to be one place for instructions that several coding tools can read. Cursor reads it from the project root and from subdirectories, and nested files combine with their parents, with the more specific one taking precedence.
Claude Code reads it too, since v2.1.277. Anthropic released that version on September 18, 2026, according to DevOps.com. Older articles that say Claude Code ignores AGENTS.md describe the behaviour before that release. The current docs describe a fallback, not a merge:
| What is in your repo | What Claude Code reads by default |
|---|---|
AGENTS.md, and no CLAUDE.md or CLAUDE.local.md in the working directory or above | AGENTS.md |
AGENTS.md and a CLAUDE.md or CLAUDE.local.md in the working directory or above | CLAUDE.md files only |
A CLAUDE.md that imports AGENTS.md | CLAUDE.md, with AGENTS.md included through the import |
Things that catch people out:
CLAUDE.local.mdcounts as aCLAUDE.md. If you add one for your personal notes in a repo that relies onAGENTS.md, Claude stops readingAGENTS.mdfor you. The fix is to set Project instructions (in/config) toclaude-md-and-agents-md, which loads both.- It is a setting. The default is
claude-md-or-agents-md. Other values includeclaude-md-and-agents-md,claude-mdandmanaged-only. - Some sessions cannot read it. The docs say that before v2.1.281, sessions on Amazon Bedrock or with telemetry disabled read
CLAUDE.mdfiles only, and the first session after upgrading from v2.1.276 or earlier does not read it either. In those cases, import it from aCLAUDE.md. - Small differences from a real
CLAUDE.md. AnAGENTS.mdloaded through the setting does not fireInstructionsLoadedhooks, and one in a directory added with--add-dirdoes not load. - You can check what loaded. In an interactive session, Claude Code prints a line such as
no CLAUDE.md found; AGENTS.md loaded: /home/you/repo/AGENTS.md.
What does .cursor/rules do?#
Cursor's rules docs describe four kinds of rule, set in the frontmatter of an .mdc file inside .cursor/rules:
| Rule type | When it applies |
|---|---|
| Always Apply | In every chat session |
| Apply Intelligently | When the agent decides it is relevant, based on the description |
| Apply to Specific Files | When a file matches a globs pattern |
| Apply Manually | When you @-mention it in chat |
An example:
---
description: API conventions for backend routes
globs: src/api/**/*.ts
alwaysApply: false
---
- All endpoints validate input
- Return errors in the shared ErrorResponse shape
Details from the docs:
- A plain
.mdfile in.cursor/rulesis ignored, because it has no frontmatter. It needs to be.mdc. - Rules can sit in subfolders and are version-controlled with the repo.
- User Rules are global preferences set in Cursor's settings and used by the Agent. Team Rules are managed from the dashboard on Team and Enterprise plans, and admins can enforce them.
- Precedence when guidance conflicts: Team Rules, then Project Rules, then User Rules.
- Size: the docs suggest keeping rules under 500 lines and splitting large ones.
- Scope: rules apply to the Agent, not to Cursor Tab or other AI features.
.cursorrules: the current rules docs do not mention this older single-file format. Treat it as legacy and move its contents toAGENTS.mdor.cursor/rules.
Which file should I use?#
This is my suggestion, based on the docs above, not an official recommendation.
You use only Claude Code: write CLAUDE.md, and use .claude/rules/ for path-scoped rules.
You use only Cursor: put the shared baseline in AGENTS.md, and put conditional rules in .cursor/rules.
You use both:
- Put the shared instructions in
AGENTS.md. Both tools read it. - If you have Claude-specific instructions, add a short
CLAUDE.mdthat imports it:
@AGENTS.md
## Claude Code
Use plan mode for changes under `src/billing/`.
- Keep Cursor's conditional rules in
.cursor/rules, and Claude's in.claude/rules/.
With that CLAUDE.md present, Claude reads AGENTS.md through the import. Without any CLAUDE.md, a current version of Claude Code reads AGENTS.md on its own. Keeping the one-line import also helps teammates whose sessions cannot read AGENTS.md directly.
The common mistake is having both files with different content. Claude Code then reads CLAUDE.md only, and Cursor reads AGENTS.md, so the two tools quietly follow different rules.
How do I avoid the common mistakes?#
- One source of truth. If two tools need the same rule, write it once and import it.
- Do not rely on prose for must-happen rules. CLAUDE.md is context, not enforcement. Use a hook.
- Check the file type in Cursor. If a rule never fires, check that it is
.mdcwith frontmatter. - Watch
CLAUDE.local.md. It can silently stopAGENTS.mdfrom loading. - Keep files short. Both tools' docs suggest limits (about 200 lines for CLAUDE.md, 500 for a Cursor rule).
- Put stable facts in them. Commands, conventions and constraints belong here. "What I am working on this week" does not, because it goes stale and nobody updates it.
What do these files not remember?#
This is the part the comparison posts usually skip. These files hold instructions. They do not hold state.
Take a real example of the difference. Your AGENTS.md says: "Run npm test before committing. Do not change the CSV column order." That is useful in every session. But at the end of today's session, none of these is written anywhere in it:
| Question the next agent needs answered | Is it in CLAUDE.md / AGENTS.md / .cursor/rules? |
|---|---|
| What task were we in the middle of? | No |
| What is finished, and did the tests actually pass? | No |
| Which files are half-edited, and what was the plan for them? | No |
| What did we try that failed? | No |
| What is the exact next step? | No |
Claude Code does have a second memory system, auto memory: notes Claude writes itself from your corrections and preferences, stored per project on your machine. At the start of each conversation it loads the first 200 lines of MEMORY.md (or 25KB). The docs describe it as learnings and patterns, and note that Claude decides what is worth saving, so it does not save something every session. It is a place for "this project uses pnpm," not a log of what you did this afternoon. It is also machine-local, so it does not follow you to another machine. Cursor's docs, as noted above, describe rules as prompt-level context, not a record of past work.
So when a session ends, whether it hits the context limit or you switch tools, the instruction files carry over and the progress does not.
How do you cover that gap?#
You need a second layer, one that records state instead of instructions. Two ways to do it:
- By hand: a handoff note with the task, what is done and how you know, what is in progress, what failed, what must not change and the next step. I wrote out a template and a prompt for the next agent in my post "How to Switch Between Cursor and Claude Code Mid-Task Without Losing Context".
- Automatically: PCSKit is an open-source command line tool and MCP server I built for this. It records tasks, notes, git state and test runs while agents work, then builds a handoff from that evidence. It sits next to your instruction files rather than replacing them:
pcs agents installadds a marked block toCLAUDE.md,AGENTS.mdand.cursor/rulesthat tells each agent how to use it.
The two layers fit together. Instruction files say how to work in this project. A state record says where the work stands.
FAQ#
What is the difference between CLAUDE.md and AGENTS.md?#
CLAUDE.md is Claude Code's own instruction file, with imports and a directory hierarchy. AGENTS.md is a plain markdown file several tools can read. They hold the same kind of content: instructions you wrote.
Does Claude Code read AGENTS.md?#
Yes, since v2.1.277. By default it reads AGENTS.md only when there is no CLAUDE.md or CLAUDE.local.md in the working directory or above. If a CLAUDE.md exists, Claude reads that, and you can import AGENTS.md into it.
Does Cursor read AGENTS.md?#
Yes. Cursor supports it in the project root and in subdirectories. Nested files combine with their parents, and the more specific one takes precedence.
Is .cursorrules deprecated?#
The current Cursor rules docs do not mention .cursorrules. Treat it as legacy and move its contents to AGENTS.md or .cursor/rules.
Do I need both CLAUDE.md and AGENTS.md?#
Not always. If you only need shared instructions, a current Claude Code reads AGENTS.md by itself. Add a CLAUDE.md when you have Claude-specific instructions, and import AGENTS.md into it.
Does Claude Code have to follow CLAUDE.md?#
No. The docs call it context rather than enforced configuration. Use a hook for anything that must be guaranteed.
How long should these files be?#
The Claude Code docs recommend under 200 lines per CLAUDE.md. Cursor's docs suggest under 500 lines per rule.
Do these files remember what happened in the previous session?#
No. They hold instructions, not state. Claude Code's auto memory keeps learnings, but not a record of task progress, and its files are local to your machine.
Where do my personal instructions go?#
In Claude Code: ~/.claude/CLAUDE.md for all projects, or CLAUDE.local.md for one project. In Cursor: User Rules in the settings.
What happens to CLAUDE.md after /compact?#
The project-root CLAUDE.md is re-read from disk. Nested files are loaded again when Claude reads files in those directories.
Sources#
Get new posts by email
High-signal notes on AI, automation and building systems. No spam.