Which instruction file do Claude Code, Codex, Cursor, and Gemini CLI load?

Claude Code uses CLAUDE.md before AGENTS.md; Codex uses AGENTS.md; Cursor loads root AGENTS.md and CLAUDE.md; Gemini CLI uses GEMINI.md.

Claude Code, Codex CLI, Cursor, and Gemini CLI do not share one default instruction file. Claude Code’s default chooses project CLAUDE.md before AGENTS.md; Codex CLI starts with AGENTS.md; Cursor picks up root AGENTS.md and CLAUDE.md; Gemini CLI starts with GEMINI.md. To share one file, add an import or configure the filename.

Key facts

  • The Claude Code documentation read on 2026-10-06 requires v2.1.277 or later for direct AGENTS.md support. Its default claude-md-or-agents-md reads AGENTS.md only when no project CLAUDE.md, .claude/CLAUDE.md, or CLAUDE.local.md exists in the working directory or an ancestor.
  • Cursor automatically picks up root AGENTS.md and root CLAUDE.md. Cursor applies CLAUDE.md to every conversation, regardless of alwaysApply frontmatter.
  • Gemini CLI defaults to GEMINI.md. Its context.fileName setting accepts one filename or an array; descendant discovery is limited to 200 directories by default.
  • Codex CLI walks from the Git root to the working directory, checking AGENTS.override.md, then AGENTS.md, then configured fallback names. The default combined instruction budget is 32 KiB.
  • Claude Code does not load AGENTS.local.md, AGENTS.override.md, or files under .agents/ as project instructions.

Instruction-file comparison

Tool

Default entry point

Override or alternate path

Directory behavior

Claude Code

CLAUDE.md or .claude/CLAUDE.md

AGENTS.md when no project CLAUDE.md or CLAUDE.local.md exists; /config can change the mode

Current directory and ancestors; subdirectories load on demand

Cursor

Root AGENTS.md and CLAUDE.md

.cursor/rules/*.mdc for project rules

Root files load automatically; rule precedence is Team > Project > User

Gemini CLI

GEMINI.md

context.fileName in settings.json

Global file, ancestors to the .git boundary, and descendants up to 200 directories

Codex CLI

AGENTS.md

AGENTS.override.md, then project_doc_fallback_filenames

Git root down to the current directory; one file per directory

Claude Code’s project instructions

Claude Code supports direct AGENTS.md loading from v2.1.277. Under the default Project instructions value, claude-md-or-agents-md, a project CLAUDE.md, .claude/CLAUDE.md, or CLAUDE.local.md in the current directory or an ancestor means Claude Code reads the CLAUDE.md files instead of project AGENTS.md files.

User-level ~/.claude/CLAUDE.md, organization-managed CLAUDE.md, and .claude/rules/ do not trigger that choice. When no project file counts, Claude Code loads AGENTS.md files from the directory chain and loads a subdirectory file when it reads a file there. AGENTS.local.md, AGENTS.override.md, and .agents/ files are not part of this discovery.

The /config setting claude-md-and-agents-md loads both formats. A CLAUDE.md can also import AGENTS.md with @AGENTS.md, which is useful when Claude-specific instructions must sit beside shared instructions.

Cursor’s rules and root files

Cursor’s rules help says a root AGENTS.md is picked up automatically. Cursor treats a root CLAUDE.md the same way and applies it to every conversation, even if its frontmatter says otherwise. Project-specific rules live in .cursor/rules/*.mdc; their frontmatter can use alwaysApply, globs, or description.

Team Rules take precedence over Project Rules, which take precedence over User Rules. Cursor rules apply to Agent Chat; they do not control Tab completion, Inline Edit, or Bugbot PR reviews.

Gemini CLI’s context files

Gemini CLI’s default context filename is GEMINI.md. It loads a global file from ~/.gemini/, searches the current directory and its parents until a context.memoryBoundaryMarkers entry such as .git, and scans descendants. The descendant search limit is 200 directories by default.

Gemini CLI concatenates the discovered files. More specific content supplements or overrides broader context. To read AGENTS.md as well, configure the filename list:

{
  "context": {
    "fileName": ["GEMINI.md", "AGENTS.md"]
  }
}

Use /memory show to inspect the loaded context and /memory refresh to rescan it.

Codex CLI’s instruction chain

Codex CLI checks global instructions in ~/.codex or $CODEX_HOME, preferring AGENTS.override.md over AGENTS.md. For a repository, it starts at the Git root and checks each directory down to the current directory. At each level it checks AGENTS.override.md, AGENTS.md, and then the names in project_doc_fallback_filenames, selecting at most one file.

Codex CLI concatenates the selected files from root to leaf. The default project_doc_max_bytes limit is 32 KiB. To let Codex read another shared filename, add it to ~/.codex/config.toml:

project_doc_fallback_filenames = ["CLAUDE.md", "GEMINI.md"]

Sharing one instruction file

Use AGENTS.md for tool-neutral instructions. Codex CLI and Cursor read it automatically. Claude Code reads it by default only when no project CLAUDE.md or CLAUDE.local.md is present; otherwise use @AGENTS.md or the claude-md-and-agents-md setting. Gemini CLI needs AGENTS.md added to context.fileName.

This leaves each tool’s private layer intact: CLAUDE.md for Claude Code, .cursor/rules/*.mdc for Cursor-specific matching, and GEMINI.md for Gemini CLI context.

Sources

Last verified: 2026-10-06.

Spotted an outdated or wrong claim? Agents can report it with evidence throughPOST /api/feedback; an editor checks every report. See llms.txt for the agent API.