Egor Urvanov

What are AGENTS.md and CLAUDE.md and how they differ from spec.mdAn example file and where to keep specs, rules and skills

AGENTS.md gives an AI agent rules for the whole project and enters every session, while spec.md describes one task: requirements and done criteria. Cursor reads both AGENTS.md and its own rules in .cursor/rules; Claude Code reads AGENTS.md when the project has no CLAUDE.md. Below: which agent reads which file, an example file and what goes where.

Specwhat to build in one taskfor one task
Biblewhat the product isat task start
Ruleshow to work in the projectevery session
Skillhow to run a procedureon call

A model does not remember a project between sessions. Four kinds of files give that context back.

Four layers of context

LayerWhat goes inWhen in contextFiles
Specrequirements, plan, steps of one taskfor one taskspec.md · plan.md · tasks.md
Bibleproduct goal, users, decisionsat task startprojectbrief.md · productContext.md
Rulescommands, style, prohibitionsevery sessionCLAUDE.md · AGENTS.md · .cursor/rules
Skillprocedure with examples and scriptsdescription always, body on callSKILL.md
Takeaway
In this exampleThe layers differ in lifetime and in when they enter the context.
In generalRules load into every session, so they are kept short: Anthropic recommends under 200 lines per file. Long and rarely used content moves into skills, whose body loads only on call.
Next stepGo through your instructions file: keep facts in the rules, move procedures into skills and the product description into the bible.

Spec: one task before the code

A spec describes the task before work starts: first what and why, then how.

1Principlesonce per project
→
2Specwhat and why
→
3Planhow
→
4Taskssteps
→
5Implementcode step by step

Main steps of GitHub Spec Kit. How to split a large spec into parts: Specs by aggregates

Takeaway
In this exampleSpec Kit takes a task from project principles through the spec and plan to steps and code.
In generalRequirements are written before the code, and the review checks the result against that text. How a spec fits into the harness is covered in HDD and specs.
Next stepFor a task longer than a day, write a spec: what, why and how you will know it is done.

Project bible: what the product is

The bible is a standing description of the product: why it exists, who it serves, how it works and what has been decided. The term comes from practice; the closest documented analogue is Cline’s Memory Bank.

projectbrief.mdgoals and requirements
productContext.mdwhy it exists, what it solves
systemPatterns.mdarchitecture and patterns
techContext.mdstack and constraints
activeContext.mdcurrent focus and next steps
progress.mdwhat works, what is left
Takeaway
In this exampleSix Memory Bank files: from the product goal to current progress.
In generalThe bible answers the questions otherwise asked in every new chat: what the product is, which decisions were made, what is in progress. The current-context file changes most often.
Next stepStart with one file: product goal, users, key terms and recent decisions with dates.

Rules: in every session

Rules are instructions the harness puts at the start of every session.

Claude Code, path-scoped rules in .claude/rules/
“A README for agents”: Codex, Cursor, Copilot, Windsurf, OpenCode and others; Claude Code when there is no CLAUDE.md
.cursor/rules
Cursor, four ways to apply

An AGENTS.md example for a web project. The file holds only what the agent cannot learn from the code: commands, style and prohibitions. CLAUDE.md for Claude Code works the same way.

AGENTS.md example

# AGENTS.md
## Commands
- Install: npm ci
- Tests: npm test
- Type check: npx tsc --noEmit
## Style
- Strict TypeScript, no any
- kebab-case file names
## Don't
- Don't change migrations/ without a task for it
- Don't commit .env or keys
## Before finishing
- Run the tests and the type check
≤ 200lines per CLAUDE.md file
Takeaway
In this exampleThree formats of one idea: an instructions file the harness reads at the start.
In generalRules stay context, and the model can break them; an action that must never happen is blocked with a hook. The more specific and concise a rule, the more consistently it is followed.
Next stepCreate AGENTS.md or CLAUDE.md: build and test commands, code style, prohibitions. Move folder-specific rules into path-scoped rules.

Which agent reads which file

The table was checked against vendor docs on 15.11.2026. A cell marked “not confirmed” means the docs do not describe it.

AgentAGENTS.mdCLAUDE.mdOwn filesSource · checked 15.11.2026
Claude Codeyes when there is no CLAUDE.md (v2.1.277+); otherwise via an @AGENTS.md line inside CLAUDE.mdthe main file.claude/rules/code.claude.com/docs/en/memory
Codexyes; in each folder AGENTS.override.md goes first; 32 KiB limit by defaultonly if the name is added to project_doc_fallback_filenamesAGENTS.override.mdlearn.chatgpt.com · agents-md
Cursoryes, in the root and in subfoldersyes, applied in every chat.cursor/rules/*.mdccursor.com/help/customization/rules · docs/context/rules
GitHub Copilotyes, the nearest file in the directory treeyes, repository root only (together with GEMINI.md).github/copilot-instructions.md, .github/instructions/*.instructions.mddocs.github.com · repository instructions
Gemini CLIonly if the name is added to the context.fileName settingnot confirmedGEMINI.mdgeminicli.com/docs/cli/gemini-md
Windsurfyes, in the root and every folder down to the working one; always onnot confirmed.windsurf/rules/, .devin/rules/docs.devin.ai · cascade/agents-md
OpenCodeyes, checked firstfallback when there is no AGENTS.mdglobal ~/.config/opencode/AGENTS.mdopencode.ai/docs/rules
Takeaway
In this exampleAlmost every agent reads AGENTS.md; CLAUDE.md is read by Claude Code, Cursor, Copilot and OpenCode.
In generalGemini CLI reads AGENTS.md only after a setting change, and Codex reads CLAUDE.md only after a setting change. If a project has both files, Claude Code takes only CLAUDE.md: shared rules are pulled in with an @AGENTS.md line.
Next stepKeep shared rules in AGENTS.md; leave an @AGENTS.md line in CLAUDE.md plus whatever only Claude Code needs.

Cursor rules and AGENTS.md

Cursor accepts two formats: AGENTS.md is plain markdown with no metadata, and rules in .cursor/rules have apply modes.

When a rule enters the context · .cursor/rules
Alwaysevery chat
By descriptionthe agent decides
By filespath pattern matches
Manually@rule

Four modes per the Cursor docs.

AGENTS.md.cursor/rules/*.mdc
Formatplain markdowna file with the .mdc extension; a .md in this folder is ignored
When it appliesalwaysalways, by description, by file pattern or manually
Foldersroot and nested; the nearest file takes precedence.cursor/rules
Sizeno number in the docsunder 500 lines per rule
Moving off legacy .cursorrules · per Cursor docs
1Createa new rule via the command palette: “New Cursor Rule”
→
2Copythe .cursorrules text
→
3ModeAlways Apply
→
4Delete.cursorrules from the root

Cursor docs call the root .cursorrules legacy and to be deprecated. The Always Apply mode matches the old behavior of the file.

Takeaway
In this exampleOne rule for the whole project goes in AGENTS.md; a conditional rule goes in .mdc.
In generalAGENTS.md and CLAUDE.md in Cursor apply in every chat; for conditional rules Cursor points to .cursor/rules.
Next stepMove shared content to AGENTS.md and keep rules for specific file types in .cursor/rules.

Example: a real CLAUDE.md

An excerpt from the CLAUDE.md of this site’s repository: only what the agent cannot learn from the code, such as where the game version comes from and a rule about dates. For Cursor, Codex and Copilot the same text moves to AGENTS.md.

CLAUDE.md

## Games: version pinned in games.lock
- The site is built from the commit recorded in games.lock
- For a new game version: push to games main and wait
## Creation and update dates
- On any edit of an article, set updated to today, in ru and en
- The build fails if the text changed after updated
Takeaway
In this exampleA rule backed by a build check holds better than one without it.
In generalRules remain context, so a prohibition that must never be broken is closed with a check. Requirements with a model work the same way: see Quint vs tests and TLA+.
Next stepFor every rule the agent broke twice, add a build check or a hook.

Skills: a procedure on call

A skill is a folder with a SKILL.md instruction, examples and scripts for a recurring procedure.

Session start
reportPR reviewreleaseclient email
name + description
↓ the agent picked “PR review”
On call
SKILL.mdinstructions, examples, scripts
full body
Takeaway
In this exampleDescriptions of all skills are always in context; the body loads once one is picked.
In generalSo a long reference inside a skill costs almost nothing until it is used. A skill is worth creating when the same instruction or checklist keeps being pasted into chat, or when a section of the rules has grown into a procedure.
Next stepFind a section of your rules that describes a procedure and move it into a skill with a precise description of when to use it.

The same in a chat: projects and skills

Project instructions ≈ rules
Role and format once, for every chat in the project
Project files ≈ bible
Sample replies, policies and templates live in the project
Skills = skills
A repeatable workflow with instructions and examples
Takeaway
In this exampleThree places where a prompt outlives a single chat: instructions, files and skills.
In generalA role, examples and format moved into a project work in every new chat without copying. A shared project gives the whole team one set of examples.
Next stepCreate a project for your most frequent weekly task and move the role and format from your best prompt into its instructions.

What goes where

If it is…Where
a command, style or prohibition needed in every taskRules
a multi-step procedure needed now and thenSkill
requirements for one taskSpec
product knowledge and decisions madeBible
an agent error that keeps coming backrule or check · HDD
Takeaway
In this exampleFive situations and five places.
In generalFrequency and lifetime decide the place. What is always needed is kept short; what is rarely needed can be detailed.
Next stepReview the rules once a week: move procedures into skills and decisions into the bible with a date.

Frequently asked questions

Does Claude Code read AGENTS.md?

Yes, when the project has no CLAUDE.md (version 2.1.277 and newer). With both files present, Claude Code reads only CLAUDE.md; to include AGENTS.md, add an @AGENTS.md line to CLAUDE.md. Source: code.claude.com/docs/en/memory, checked 15.11.2026.

Do I still need .cursorrules?

No. Cursor docs call the root .cursorrules legacy and describe the move: create a new rule in Always Apply mode, then delete the file. Shared rules can live in AGENTS.md. Source: cursor.com/help/customization/rules, checked 15.11.2026.

How many lines should a rules file have?

Anthropic recommends under 200 lines per CLAUDE.md, Cursor under 500 lines per rule; Codex reads up to 32 KiB in total by default. AGENTS.md has no general number. Sources: Anthropic, Cursor and OpenAI docs, checked 15.11.2026.

Where does spec.md live and who creates it?

A spec is created at the start of a task: in GitHub Spec Kit the /speckit-specify command in the agent chat starts it from a task description. The docs name no required folder; the file usually sits in the repository next to the task code and is closed together with the task.
© 2026 Egor Urvanov