Skip to content

Menu

AI Agent Rules Files Cheat Sheet: CLAUDE.md, AGENTS.md, Cursor, Copilot, Gemini and More

Checked against Agent instruction files Each vendor's docs as read on 28 Nov 2026 (Claude Code memory page, Cursor rules, GitHub Copilot custom instructions, Gemini CLI, Codex, Cline, Continue, Devin Desktop) on 28 November 2026. Each section links to the official docs it was checked against.

This sheet is for teams that use more than one coding agent and want to know which file each one actually reads. It lines up file paths, scopes and precedence rules from each vendor's own documentation as published on 28 Nov 2026. Every row comes from those pages; none of it was tested against a live agent, so each row is marked untested.

When to use what

If you only remember one thing: put shared, tool-neutral guidance in a root AGENTS.md. The agents.md site lists Codex, Cursor, Gemini CLI, Devin, Zed, Windsurf and the Copilot coding agent among its readers, and Cline and Devin Desktop pick it up too. Write build commands, test commands and conventions there once.

Then add a tool-specific file only for what that tool needs on top. Claude Code is the case to watch: per its memory docs it reads AGENTS.md only when no CLAUDE.md or CLAUDE.local.md sits in the working directory or above it. If you keep both, make CLAUDE.md import the shared file with an @AGENTS.md line so Claude still sees it. Gemini CLI reads only GEMINI.md until you list AGENTS.md under context.fileName.

Use path-scoped rules for anything that applies to part of the repo: .claude/rules/*.md with paths:, .cursor/rules/*.mdc with globs, .github/instructions/*.instructions.md with applyTo. Scoped rules keep the always-loaded context small, which matters because every line of an always-on file is sent with every request. Paste a draft into the token counter to see what it costs per turn, and test your glob patterns in the glob tester before trusting them.

For the reasoning behind a single shared file, our post on AGENTS.md and repository instructions goes further. The tool pages for Claude Code, Cursor and GitHub Copilot cover the agents themselves.

Files found up the directory tree are concatenated, not overridden, ordered from the filesystem root down to your working directory. Subdirectory files load when Claude touches files there.

/Library/Application Support/ClaudeCode/CLAUDE.md

Managed policy file on macOS (Linux and WSL: /etc/claude-code/CLAUDE.md); org-wide and cannot be excluded with claudeMdExcludes

From the docs, not run by us
~/.claude/CLAUDE.md

Your personal instructions for every project on this machine

From the docs, not run by us
./CLAUDE.md or ./.claude/CLAUDE.md

Project instructions committed for the team

From the docs, not run by us
./CLAUDE.local.md

Personal per-project notes; add it to .gitignore yourself

From the docs, not run by us
.claude/rules/*.md

Modular rule files, discovered recursively; ~/.claude/rules/ holds user-level ones that load before project rules

From the docs, not run by us
paths: - "src/api/**/*.ts"

YAML frontmatter that makes a rule load only when Claude works on matching files

Try it: glob-pattern-testerFrom the docs, not run by us
@path/to/file.md

Import another file into CLAUDE.md; relative to the importing file, up to four hops deep

From the docs, not run by us
/init

Generate a starter CLAUDE.md from the codebase, or suggest edits if one exists

From the docs, not run by us

Codex walks from the project root (usually the git root) down to the working directory and includes at most one file per directory. Closer files come later, so they win.

~/.codex/AGENTS.md

Global Codex instructions (or under CODEX_HOME); AGENTS.override.md there is checked first

From the docs, not run by us
AGENTS.override.md

Per-directory override that Codex reads before AGENTS.md in the same folder

From the docs, not run by us
project_doc_fallback_filenames = ["TEAM_GUIDE.md", ".agents.md"]

Extra filenames Codex accepts, set in ~/.codex/config.toml

From the docs, not run by us
project_doc_max_bytes = 65536

Raise the instruction size cap from its 32 KiB default; content past the cap is truncated

From the docs, not run by us
AGENTS.md (nested)

agents.md says the file closest to the edited file wins and explicit chat prompts override everything

Source: https://agents.md/

From the docs, not run by us

Cursor lists precedence as Team Rules, then Project Rules, then User Rules; all applicable rules are merged and earlier sources win on conflict.

.cursor/rules/*.mdc

Project rules, version-controlled, subfolders allowed; a plain .md there is ignored

From the docs, not run by us
alwaysApply: true

Always Apply mode: the rule goes into every chat

From the docs, not run by us
description: "..."

Apply Intelligently mode: the agent decides from the description whether to include it

From the docs, not run by us
globs: src/**/*.ts,src/**/*.tsx

Apply to Specific Files mode: included when a matching file is in context; comma-separate patterns

Try it: glob-pattern-testerFrom the docs, not run by us
@my-rule

Pull in an Apply Manually rule (no description or globs) by mentioning it

From the docs, not run by us
AGENTS.md (root or subfolder)

Plain markdown without metadata; nested files combine with parents and the more specific one takes precedence

From the docs, not run by us

GitHub says personal instructions take priority, then repository, then organization, but all relevant sets are sent, so avoid contradictions between levels. Code review reads instructions from the pull request's head branch.

.github/copilot-instructions.md

Repository-wide instructions for Copilot

From the docs, not run by us
.github/instructions/NAME.instructions.md

Path-specific instructions, in or below .github/instructions

From the docs, not run by us
applyTo: "**/*.ts,**/*.tsx"

Frontmatter globs that decide which files a path-specific file covers

Try it: glob-pattern-testerFrom the docs, not run by us
excludeAgent: "code-review"

Stop Copilot code review (or "cloud-agent") from reading this file

From the docs, not run by us
AGENTS.md (any folder)

Agent instructions; the nearest one in the directory tree takes precedence

From the docs, not run by us
CLAUDE.md or GEMINI.md (repo root)

A single root file of either name is also accepted as agent instructions

From the docs, not run by us

The CLI concatenates every file it finds and sends the result with each prompt.

~/.gemini/GEMINI.md

Global default instructions for all projects

From the docs, not run by us
GEMINI.md (workspace and parents)

Found by searching configured workspace directories and their parents

From the docs, not run by us
GEMINI.md (just in time)

When a tool touches a directory, the CLI scans it and its ancestors up to a trusted root

From the docs, not run by us
"context": { "fileName": ["AGENTS.md", "GEMINI.md"] }

settings.json entry that makes Gemini CLI read AGENTS.md as well

From the docs, not run by us
@./components/instructions.md

Import another markdown file; relative and absolute paths both work

From the docs, not run by us
/memory show

Print the full concatenated memory the model receives

From the docs, not run by us
/memory reload

Re-scan and reload every GEMINI.md after you edit one

From the docs, not run by us

Continue rows: https://docs.continue.dev/customize/deep-dives/rules. Devin Desktop rows: https://docs.devin.ai/desktop/cascade/memories.

.clinerules/ or .cline/rules/

Cline workspace rule folders at the project root; both are searched

From the docs, not run by us
~/Documents/Cline/Rules

Cline global rules on macOS and Linux (Documents\Cline\Rules on Windows)

From the docs, not run by us
paths: - "src/components/**"

Cline conditional rule frontmatter; paths: [] means the rule never fires

From the docs, not run by us
.cursorrules, .windsurfrules, AGENTS.md

Other files Cline detects automatically; ~/.agents/AGENTS.md works as a global file

From the docs, not run by us
.continue/rules/01-general.md

Continue rule file; files load in lexicographic order, so number prefixes set the order

From the docs, not run by us
globs / regex / alwaysApply / description

Continue frontmatter keys that decide when a markdown rule is included

From the docs, not run by us
.devin/rules/*.md

Devin Desktop workspace rules, one per file; ~/.devin/global_rules.md is the global file

From the docs, not run by us
trigger: always_on | glob | model_decision | manual

Devin Desktop activation modes set in rule frontmatter

From the docs, not run by us
AGENTS.md, AGENTS.local.md, AGENT.md

Read by Devin Desktop as always-on rules from the workspace root down to the working directory

From the docs, not run by us

Worked example: One AGENTS.md shared by Claude Code, Gemini CLI and Copilot

Say the repo already has a root AGENTS.md and you are adding Claude Code and Gemini CLI. You want one source of truth.

# CLAUDE.md (repo root)
@AGENTS.md

## Claude-only
- Use the /test skill before committing.
// .gemini/settings.json
{
  "context": { "fileName": ["AGENTS.md", "GEMINI.md"] }
}

What each tool ends up reading, according to its docs:

  • Claude Code finds CLAUDE.md, so it skips loading AGENTS.md on its own. The @AGENTS.md import pulls it back in, so Claude gets the shared rules plus the Claude-only line.
  • Gemini CLI now looks for both names and concatenates what it finds, so the shared file reaches it with no copy.
  • Copilot's coding agent reads the nearest AGENTS.md without any setup.
  • Codex reads AGENTS.md from the root down to your working folder.

To confirm, run /memory show in Gemini CLI and look for the shared headings. In Claude Code, ask it to list the instruction files it loaded. If a heading is missing, check the filename spelling and whether a CLAUDE.md higher up the tree is masking the shared file.

Common mistakes

  • Adding a CLAUDE.md to a repo that relies on AGENTS.md and wondering why Claude ignores the shared rules.

    Claude Code reads AGENTS.md only when no CLAUDE.md exists in or above the working directory. Add @AGENTS.md at the top of CLAUDE.md.

  • Saving Cursor project rules as .cursor/rules/style.md.

    Cursor's docs say project rules must end in .mdc; a plain .md in that folder is ignored. Rename the file.

  • Expecting Gemini CLI to read AGENTS.md out of the box.

    Set context.fileName in settings.json to a list that includes AGENTS.md, then run /memory reload.

  • Writing a rule in CLAUDE.md and treating it as a hard block, such as never touching a production config.

    The Claude Code docs say these files are context, not enforced configuration. Use a PreToolUse hook or permission rules for anything that must never happen.

  • Letting a 40 KB AGENTS.md grow in a Codex project.

    Codex truncates at project_doc_max_bytes, 32 KiB by default. Move area-specific guidance into nested AGENTS.md files or raise the limit deliberately.

  • Putting conflicting advice in personal, repo and org Copilot instructions and expecting the personal one to cleanly win.

    GitHub sends all relevant sets together. Priority only helps the model choose; remove the contradiction instead.