Harness Engineering 6 months ahead, in a few hours.

Claude Code AGENTS.md: when it's read instead of CLAUDE.md

Thomas Poulain ·

Since v2.1.277, Claude Code reads AGENTS.md as your project instructions when your repository has no CLAUDE.md. A repository already set up for other coding agents works without adding a CLAUDE.md or an import. You change that behavior with the Project instructions row in /config.

If instruction files are new to you, start with what a CLAUDE.md file is.

When does Claude Code read AGENTS.md instead of CLAUDE.md?

By default, Claude reads AGENTS.md only when there’s no CLAUDE.md in your working directory or above it.

Your repository hasClaude reads
An AGENTS.md, and no CLAUDE.md or CLAUDE.local.md in your working directory or above itYour AGENTS.md
An AGENTS.md and a CLAUDE.md or CLAUDE.local.md in your working directory or above itYour CLAUDE.md files only
A CLAUDE.md that already imports AGENTS.mdYour CLAUDE.md, with AGENTS.md included through the import

For that check, Claude Code looks for CLAUDE.md, .claude/CLAUDE.md and CLAUDE.local.md in your working directory and every parent directory. Your ~/.claude/CLAUDE.md, your organization’s managed CLAUDE.md and your .claude/rules/ files don’t count. They keep loading alongside AGENTS.md.

Which AGENTS.md files load, and when?

At session start, Claude Code loads every AGENTS.md and .claude/AGENTS.md in your working directory and the directories above it. In an interactive session, a line like this one shows up in the conversation:

no CLAUDE.md found; AGENTS.md loaded: /home/you/repo/AGENTS.md

A subdirectory’s AGENTS.md loads when Claude opens a file there with the Read tool, as long as that subdirectory has none of the three CLAUDE.md files. Inside each AGENTS.md, @path imports are expanded and claudeMdExcludes patterns apply. Claude Code never reads AGENTS.local.md, AGENTS.override.md, or anything under a .agents/ directory.

To confirm it was read, run /memory and look for your AGENTS.md path in the list.

How do I pick which files load with /config?

Open /config and set Project instructions to one of four values.

ValueWhat Claude reads
claude-md-or-agents-mdYour CLAUDE.md files, or your AGENTS.md files when there’s no CLAUDE.md or CLAUDE.local.md. This is the default
claude-md-and-agents-mdBoth, with each directory’s CLAUDE.md files first and its AGENTS.md after them. An AGENTS.md already imported or symlinked isn’t read twice
claude-mdYour CLAUDE.md files only
managed-onlyAt launch, only your organization’s managed CLAUDE.md and auto memory

You can also write the value in a settings file, under pluginConfigs, using the ID of the built-in plugin that reads AGENTS.md:

{
  "pluginConfigs": {
    "cc-plugin-agents-md@builtin": {
      "options": { "instructionFiles": "claude-md-and-agents-md" }
    }
  }
}

Claude Code reads this entry from ~/.claude/settings.json, a file passed with --settings, or managed settings. It ignores it in project and local settings, so putting it in the repository’s .claude/settings.json does nothing. Before v2.1.285 the ID was agents-md@builtin. Newer versions accept both, so keep the old ID if an older Claude Code version also reads that file. The change applies from the next message you send.

What traps should I know about?

The first one is CLAUDE.local.md. Because it counts for the check, adding one for your personal notes in a project that relies on AGENTS.md stops Claude from reading AGENTS.md for you. Set Project instructions to claude-md-and-agents-md to keep both.

An AGENTS.md read through the setting also behaves a little differently from a CLAUDE.md:

  • InstructionsLoaded hooks don’t fire for it. They do fire for an AGENTS.md that a CLAUDE.md imports or symlinks to.
  • With --add-dir and CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD, the added directory’s AGENTS.md doesn’t load.
  • An @path import that points outside your working directory loads only if you already approved external imports for the project, and no prompt appears.

Some sessions read CLAUDE.md files only, and Project instructions is then missing from /config. That happens before v2.1.277, when you disabled the built-in plugin with /plugin, and sometimes in your first session after upgrading from v2.1.276 or earlier. Before v2.1.281, sessions on Amazon Bedrock or with telemetry disabled were affected too.

Which workarounds can I delete?

If you got Claude to read AGENTS.md before v2.1.277, the docs cover each common setup.

Current setupWhat to do
A CLAUDE.md containing @AGENTS.mdKeeping it never loads the file twice. Delete it if it holds nothing else, keep it if some of your sessions can’t read AGENTS.md
A CLAUDE.md that tells Claude in words to read AGENTS.mdDelete it, or replace the sentence with an @AGENTS.md import. Otherwise Claude only sees the file if it decides to open it
A CLAUDE.md symlinked to AGENTS.mdNothing, or delete the symlink. The content is read once either way
A SessionStart hook that prints AGENTS.mdRemove it, since it adds a second copy to the context

When should I keep a CLAUDE.md next to AGENTS.md?

Keep one for Claude-specific instructions, or when one of your sessions can’t read AGENTS.md. Put the import at the top and the Claude part below it. Claude reads the imported file first, then the rest.

@AGENTS.md

## Claude Code

Use plan mode for changes under `src/billing/`.

Pick the import over a symlink if anyone clones the repository on Windows. Creating a symlink there needs Administrator rights or Developer Mode, and Git checks out a committed symlink as a plain text file unless core.symlinks is on. After the change, start a new session, run /context, and check that CLAUDE.md shows up under Memory files.


Section 3.9 of module 3, Advanced configuration covers managed settings, where you set the pluginConfigs key for a whole organization. To write one instruction file your whole team shares, see section 10.2 of module 10, Team collaboration.

To see these articles more often on Google, add Harness Engineering to your preferred sources.

You might also like