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.

Kumar NihalNovember 24, 202610 min read
On this page

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.mdAGENTS.md.cursor/rules
Read byClaude CodeCursor. Claude Code v2.1.277+, only when no CLAUDE.md is foundCursor
FormatPlain markdownPlain markdown, no frontmatter.mdc files with frontmatter
ScopingBy directory. Path-scoped rules via .claude/rules/By directory (nested files)globs, a description, always-on, or manual
Best forClaude-specific instructionsOne shared file for several toolsConditional, file-type-specific rules in Cursor
Remembers last session?NoNoNo

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.md is Claude Code's own format.
  • AGENTS.md is a plain markdown file meant to be shared across tools.
  • .cursor/rules is 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:

ScopeLocation
Managed policyAn 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.md it finds. More specific files appear later in context.
  • Subdirectory files load on demand. A CLAUDE.md below your working directory is included when Claude reads files in that subdirectory.
  • Path-scoped rules live in .claude/rules/. A rule file with paths frontmatter loads only when Claude reads a matching file:
markdown
---
paths:
  - "src/api/**/*.ts"
---

- All API endpoints must validate input
  • Imports. @path/to/file pulls 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-root CLAUDE.md is 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 repoWhat Claude Code reads by default
AGENTS.md, and no CLAUDE.md or CLAUDE.local.md in the working directory or aboveAGENTS.md
AGENTS.md and a CLAUDE.md or CLAUDE.local.md in the working directory or aboveCLAUDE.md files only
A CLAUDE.md that imports AGENTS.mdCLAUDE.md, with AGENTS.md included through the import

Things that catch people out:

  • CLAUDE.local.md counts as a CLAUDE.md. If you add one for your personal notes in a repo that relies on AGENTS.md, Claude stops reading AGENTS.md for you. The fix is to set Project instructions (in /config) to claude-md-and-agents-md, which loads both.
  • It is a setting. The default is claude-md-or-agents-md. Other values include claude-md-and-agents-md, claude-md and managed-only.
  • Some sessions cannot read it. The docs say that before v2.1.281, sessions on Amazon Bedrock or with telemetry disabled read CLAUDE.md files only, and the first session after upgrading from v2.1.276 or earlier does not read it either. In those cases, import it from a CLAUDE.md.
  • Small differences from a real CLAUDE.md. An AGENTS.md loaded through the setting does not fire InstructionsLoaded hooks, and one in a directory added with --add-dir does 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 typeWhen it applies
Always ApplyIn every chat session
Apply IntelligentlyWhen the agent decides it is relevant, based on the description
Apply to Specific FilesWhen a file matches a globs pattern
Apply ManuallyWhen you @-mention it in chat

An example:

markdown
---
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 .md file in .cursor/rules is 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 to AGENTS.md or .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:

  1. Put the shared instructions in AGENTS.md. Both tools read it.
  2. If you have Claude-specific instructions, add a short CLAUDE.md that imports it:
markdown
@AGENTS.md

## Claude Code

Use plan mode for changes under `src/billing/`.
  1. 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 .mdc with frontmatter.
  • Watch CLAUDE.local.md. It can silently stop AGENTS.md from 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 answeredIs 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 install adds a marked block to CLAUDE.md, AGENTS.md and .cursor/rules that 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#

Share
Kumar Nihal

Written by

Kumar Nihal

AI-first software engineer and founder of Causly. I build software, SaaS and AI systems, and write about it here. More about me

Get new posts by email

High-signal notes on AI, automation and building systems. No spam.

Keep reading

Insight

Why I Built PCSKit: Solving Context Loss in AI Coding Sessions

AI coding agents are productive, but their work can lose continuity when a context window fills up, a session gets interrupted, or developers switch between tools. I built PCSKit to solve this problem with local-first project continuity, evidence-based handoffs, and verifiable development history—so the next AI agent can continue from the actual project state instead of relying on an unreliable summary.

Nov 24, 2026
Insight

AI Coding Agent Handoffs: Why HANDOFF.md Needs Verifiable Evidence

Learn how to preserve context across AI coding agent sessions with reliable handoffs. Explore the limitations of traditional HANDOFF.md files, why task summaries aren't enough, and how Git state, test results, file changes, and verifiable evidence help agents resume development work with greater confidence.

Nov 24, 2026
Insight

MCP Tool Annotations Explained: Practical Examples, Defaults, and Security Best Practices

Understand MCP Tool Annotations and how they influence AI agent interactions with tools. Learn the four core annotations — readOnlyHint, destructiveHint, idempotentHint, and openWorldHint — with practical JSON examples, default behaviors, security considerations, common mistakes, and testing strategies for building reliable Model Context Protocol servers.

Nov 24, 2026