# Cursor rules vs CLAUDE.md vs AGENTS.md: shipping consistent code with AI

> How the three instruction-file formats differ, when to use which, and how mixed teams keep one source of truth for every coding agent.

- URL: https://provencart.com/blog/cursor-rules-vs-claude-md-vs-agents-md
- Published: 24 November 2026 · 6 min read
- Tags: cursor, claude-code, agents-md, developer-workflow
- Related products: [Ship Rules](https://provencart.com/products/ship-rules), [Claude Code Agency Kit](https://provencart.com/products/claude-code-agency-kit), [Prompt Linter](https://provencart.com/products/prompt-linter), [Developer Bundle](https://provencart.com/products/developer-bundle)

**Cursor rules, CLAUDE.md and AGENTS.md all do the same job: they give an AI coding agent persistent instructions about your project. They differ in who reads them and how they are scoped.** `.cursor/rules/*.mdc` files are read by Cursor and can be scoped to file patterns. `CLAUDE.md` is read by Claude Code at session start and from subfolders as it works. `AGENTS.md` is an open, tool-neutral convention read by a growing list of agents. If your team uses more than one tool, keep a single source of truth (usually `AGENTS.md`) and make the tool-specific files thin pointers or generated copies. This guide compares the formats and shows a setup that keeps them in sync.

## Why instruction files matter

Coding agents start every session without memory of your project. Without written instructions they guess your package manager, test command, folder conventions and style, and they guess differently each time. Instruction files turn tribal knowledge into something every agent reads before it writes code. The result is fewer review comments, fewer "we don't do it that way here" rewrites, and more predictable diffs.

## The three formats at a glance

| | Cursor rules | CLAUDE.md | AGENTS.md |
|---|---|---|---|
| **Read by** | Cursor | Claude Code | Many agents (e.g. OpenAI Codex, Cursor, GitHub Copilot's coding agent and others) |
| **Location** | `.cursor/rules/*.mdc` (legacy: `.cursorrules`) | Project root, subfolders, `~/.claude/CLAUDE.md` | Project root, optionally nested per package |
| **Format** | Markdown with frontmatter (`description`, `globs`, `alwaysApply`) | Plain Markdown, `@file` imports | Plain Markdown, no required structure |
| **Scoping** | Per rule: always, by glob, by description, or manual | By directory (nested files load when working there) | By directory (nearest file wins) |
| **Best for** | Fine-grained rules per file type in Cursor | Claude Code projects, with hooks and subagents alongside | Teams using several tools |

Tool support changes quickly; check each tool's documentation for the current behaviour before you standardise.

## Cursor rules in detail

Cursor's project rules live in `.cursor/rules/` as `.mdc` files. The frontmatter controls when a rule is attached:

```markdown
---
description: Conventions for React components
globs: src/components/**/*.tsx
alwaysApply: false
---

- Function components only, named exports.
- Props type named `<Component>Props`, defined above the component.
- Styling with Tailwind utility classes; no inline style objects.
```

Rule types in practice:

- **Always**: `alwaysApply: true`, included in every request. Keep these few and short.
- **Auto-attached**: attached when files matching `globs` are in context.
- **Agent-requested**: Cursor reads the `description` and decides whether to pull it in.
- **Manual**: included only when you reference it.

The older single `.cursorrules` file still works in many setups but is considered legacy.

## CLAUDE.md in detail

Claude Code reads `CLAUDE.md` from the project root when a session starts, plus `CLAUDE.md` files in subdirectories when it works there, plus your personal `~/.claude/CLAUDE.md`. It supports imports, which is the key to avoiding duplication:

```markdown
# CLAUDE.md
@AGENTS.md

## Claude Code specifics
- Use the `code-reviewer` subagent before proposing a commit.
- Hooks in .claude/settings.json format files automatically; do not run Prettier manually.
```

`CLAUDE.md` is only one part of Claude Code's configuration. Hooks, permissions, subagents, commands and skills live in `.claude/`. That makes Claude Code the most enforceable of the three: rules in Markdown are guidance, a hook that blocks an edit is a guarantee. We cover that side in [A Claude Code setup for agencies](https://provencart.com/blog/claude-code-setup-for-agencies).

## AGENTS.md in detail

`AGENTS.md` was introduced in 2025 as a shared, vendor-neutral place for agent instructions, "a README for agents". It has no required schema, which is its strength: any agent can read Markdown. A good one looks like a concise onboarding document:

```markdown
# AGENTS.md

## Setup
pnpm install · pnpm dev (http://localhost:3000)

## Checks (run before every commit)
pnpm typecheck && pnpm lint && pnpm test

## Conventions
- TypeScript strict, no `any`. Zod for all external input.
- Server-only modules start with `import "server-only"`.
- Money is integer cents.

## Don't
- Don't edit generated files in src/gen/.
- Don't add dependencies without asking.
```

In monorepos, place additional `AGENTS.md` files in packages; agents use the nearest one.

## What about GitHub Copilot and other tools?

GitHub Copilot has its own files: a repository-wide `.github/copilot-instructions.md` and path-specific `.github/instructions/*.instructions.md` files with an `applyTo` glob in the frontmatter. Its coding agent also reads `AGENTS.md`. Other agents (Windsurf, Zed, Gemini CLI and more) each have a preferred file name, and most either support `AGENTS.md` directly or can be pointed at it. The pattern stays the same: one source, thin tool-specific wrappers.

## Choosing: a decision guide

- **Only Cursor?** Use `.cursor/rules/` with globs. You get the finest control.
- **Only Claude Code?** Use `CLAUDE.md` plus `.claude/` for hooks and subagents.
- **Mixed team, or you expect tools to change?** Write `AGENTS.md` as the source of truth. Make `CLAUDE.md` a one-line import (`@AGENTS.md`) plus Claude-specific notes. For Cursor, either rely on its `AGENTS.md` support or keep a small always-on rule that points to it, and add glob-scoped rules only for file-type specifics.

## Keeping them in sync

The failure mode is drift: someone updates the Cursor rule, nobody updates `CLAUDE.md`, and two agents follow two different conventions. Three habits prevent it:

1. **One source, generated targets.** Edit `AGENTS.md` (and optional topic files). Generate or import everything else. Never hand-edit a generated file; add a header that says so.
2. **Review rules like code.** Changes to instruction files go through pull requests, with a reviewer who checks for contradictions.
3. **Test the instructions.** Periodically ask each agent "What are this project's test and lint commands, and what must you never edit?" If an answer is wrong, the instructions are unclear.

## What to write (and what to leave out)

Good instruction files are short and operational.

**Include**: exact commands; folder ownership; naming conventions; error-handling and validation patterns; "never do" rules; where to find examples of good code.

**Leave out**: general advice the model already follows ("write clean code"), long architecture essays (link to docs instead), secrets, and anything that changes weekly.

A useful length check: if a rule file would take a human more than five minutes to read, the agent will weigh its rules less reliably too. Split by directory or topic.

## Ready-made rule sets

[Ship Rules](https://provencart.com/products/ship-rules) is our kit for exactly this problem: a curated `AGENTS.md` base with stack-specific rule sets, matching Cursor rules and CLAUDE.md wrappers, and a sync script that generates the tool-specific files from one source. For teams that run on Claude Code, combine it with the [Claude Code Agency Kit](https://provencart.com/products/claude-code-agency-kit). Both are part of the [Developer Bundle](https://provencart.com/products/developer-bundle). Before you write prompts or rules, the free [Prompt Linter](https://provencart.com/products/prompt-linter) catches vague or contradictory instructions.

## FAQ

### Does Claude Code read AGENTS.md?

Claude Code's native instruction file is `CLAUDE.md`. The reliable way to share one source is a `CLAUDE.md` that imports `AGENTS.md` with `@AGENTS.md`. Check the current Claude Code documentation, as tool support for shared formats keeps expanding.

### Should instruction files be committed?

Yes, shared project rules belong in version control. Personal preferences go into user-level files such as `~/.claude/CLAUDE.md` or Cursor's user rules.

### How long should AGENTS.md be?

As short as possible while still covering commands, conventions and prohibitions. A few hundred words is typical for a single app; large monorepos split instructions per package.
