# Agent instruction file

> Canonical: https://skillalmanac.com/glossary/agent-instruction-file | Last verified: 2026-11-24 | Index status: not offered to search engines

An agent instruction file is a plain text file kept in a project, such as CLAUDE.md, AGENTS.md or a Cursor rule, that a coding agent reads at the start of work to learn the project's commands and conventions.

Also called: instruction file, agent instruction files, coding agent instructions.

## In plain language

An agent instruction file is a note you leave for an AI coding tool, like the sheet of house rules you would hand a new contractor on day one. It says how to build and test the project and which style to follow. The tool reads it when a session starts, so you do not retype the rules in every message. Different tools look for different names: Claude Code reads CLAUDE.md, many others read AGENTS.md, and Cursor has its own rule files. The main limit is that the file is advice, not enforcement. The agent can still miss a line, and a long file makes that more likely. It also takes space in every session, which costs tokens, the units of text AI services charge for.

## Technical definition

These files are Markdown text that the agent harness (the program that runs the model and its tools) inserts into the model's context at session start or when work reaches a matching folder or file. Claude Code loads CLAUDE.md files from the working directory and the directories above it, and reads AGENTS.md directly only when no CLAUDE.md applies, from version 2.1.277 as its memory page documents. AGENTS.md is an open format with no required fields, where the nearest file in the directory tree takes priority. Cursor project rules are .mdc files in .cursor/rules. None of these is enforced configuration: the model receives the text as context, so hard blocks need other controls such as hooks or permission settings.

## How it shows up when you use agents

Each Claude Code session begins with a fresh [context window](/glossary/context-window), according to its memory page. The instruction file is how a [coding agent](/glossary/coding-agent) learns your build command, your test command and your conventions without being told again. In Claude Code the file is CLAUDE.md. Codex, Cursor and many other tools read AGENTS.md, and Cursor also has its own rule files. The guide [CLAUDE.md vs AGENTS.md](/learn/agents-md-vs-claude-md) shows how the two fit together.

What breaks when this is misunderstood: people treat the file as a guarantee. The Claude Code memory page says the agent treats these files as context, not enforced configuration, and that shorter, more specific instructions are followed more consistently. A long file of generic advice is read every session and can bury the one line that matters. Copies of the same rule in two files drift apart, and a stray CLAUDE.local.md can stop AGENTS.md from loading at all.

Next action: open your instruction file and delete every line the code already shows. Keep the commands and the rules a newcomer could not guess. Move step-by-step procedures into an [agent skill](/glossary/agent-skill), which loads only when needed. Then start a fresh session and ask a question whose answer exists only in the file, to confirm it loaded.

## Common confusions

- **CLAUDE.md versus AGENTS.md.** CLAUDE.md is the file Claude Code reads first. AGENTS.md is an open format that many other agents read. According to the Claude Code docs, Claude reads a root AGENTS.md only when no CLAUDE.md applies, so a one-line CLAUDE.md that imports it is the usual way to share rules.
- **Instruction file versus system prompt.** The [system prompt](/glossary/system-prompt) is set by the tool's maker. The instruction file is added by you, in your project.
- **Instruction file versus skill.** An instruction file loads in every session. A skill loads when the task calls for it, so it suits long procedures.
- **Myth.** The agent obeys the file every time. The file is text the model reads, and the Claude Code docs say it is not enforced configuration.

## Worked examples in this catalogue

### [CLAUDE.md vs AGENTS.md: Which Agents Read Which File](https://skillalmanac.com/learn/agents-md-vs-claude-md)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A table of how Claude Code and Codex each find their instruction file, the one-line CLAUDE.md containing @AGENTS.md so both tools share one set of rules, and a list of pitfalls such as a CLAUDE.local.md stopping AGENTS.md from being read.

Why it exercises the concept: It shows one idea, a file of standing instructions, implemented by two tools with different loading rules, which is where most confusion about these files comes from.

### [Cursor Rules Explained: Rule Types and When to Use a Skill](https://skillalmanac.com/learn/cursor-rules-explained)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: The four places Cursor takes instructions from, the .mdc frontmatter keys description, globs and alwaysApply, and a decision rule for choosing AGENTS.md or a Cursor rule.

Why it exercises the concept: It covers the third common variant, rule files that load for every chat or only for matching files, so the reader sees that scope is part of the design.

### [agent-instruction-files](https://skillalmanac.com/skills/skill-almanac/agent-instruction-files)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: An instruction file in which each line is specific to the project, checked against the repository, and short enough to be worth loading in every session.

Why it exercises the concept: It targets a common failure of these files: lines that restate what the code already shows add tokens without changing the agent's behaviour.

### [rules-to-skills-migration](https://skillalmanac.com/skills/skill-almanac/rules-to-skills-migration)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Editor rule files moved into AGENTS.md plus portable skills, with a record of how each rule was switched on.

Why it exercises the concept: It handles the next step when an instruction file grows: procedures that matter only sometimes move out into skills, which load on demand.

## Related terms

- [Agent skill](https://skillalmanac.com/glossary/agent-skill.md)
- [Coding agent](https://skillalmanac.com/glossary/coding-agent.md)
- [System prompt](https://skillalmanac.com/glossary/system-prompt.md)
- [Context window](https://skillalmanac.com/glossary/context-window.md)
- [Agent memory](https://skillalmanac.com/glossary/agent-memory.md)
- [Prompt engineering](https://skillalmanac.com/glossary/prompt-engineering.md)
- [Cursor rules](https://skillalmanac.com/glossary/cursor-rules.md)
- [CLAUDE.md](https://skillalmanac.com/glossary/claude-md.md)
- [AGENTS.md](https://skillalmanac.com/glossary/agents-md.md)

## Sources

- [How Claude remembers your project](https://code.claude.com/docs/en/memory), Anthropic (Claude Code Docs) (accessed 2026-11-23)
- [AGENTS.md](https://agents.md/), agents.md (accessed 2026-11-23)
- [Rules](https://cursor.com/docs/context/rules), Cursor Docs (accessed 2026-11-23)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-24. [Glossary index](https://skillalmanac.com/glossary.md).
