Harness Notes

Instructions

Updated 2026-11-22,

On this page

Instruction files are guidance you write once and every session reads, such as AGENTS.md, CLAUDE.md or Cursor rules. Notes a harness saves on its own are on the Memories page.

What gets loaded

QuestionClaude Codechecked at 2.1.299
Which files it reads

Claude Code reads CLAUDE.md, .claude/CLAUDE.md, CLAUDE.local.md (personal, gitignored), every .md under .claude/rules/ (recursively) and ~/.claude/rules/, plus ~/.claude/CLAUDE.md and a managed-policy CLAUDE.md. Since v2.1.277 it also reads AGENTS.md and .claude/AGENTS.md, by default only as a fallback when no CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md exists in the working directory or above. It never reads AGENTS.local.md, AGENTS.override.md or anything under .agents/.

~/.claude/CLAUDE.md, the managed CLAUDE.md and .claude/rules/ files don't count as a CLAUDE.md for the AGENTS.md fallback check; adding a CLAUDE.local.md does, and stops AGENTS.md loading.

Where it looks, and when nested files load

At launch it loads the managed file (macOS /Library/Application Support/ClaudeCode/CLAUDE.md, Linux/WSL /etc/claude-code/CLAUDE.md, Windows C:\Program Files\ClaudeCode\CLAUDE.md), ~/.claude/CLAUDE.md, and the CLAUDE.md/CLAUDE.local.md files in the working directory and every directory above it up to the filesystem root. Files in subdirectories below the working directory load on demand, the first time Claude reads, writes or edits a file in that subdirectory (including a single-file cat/head via Bash). A subdirectory AGENTS.md loads when Claude opens a file there with the Read tool and that subdirectory has no CLAUDE.md file of its own.

Directories added with --add-dir don't contribute instruction files unless CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 is set, and even then their AGENTS.md doesn't load.

Subdirectory files and path-scoped rules don't appear under Memory files in /context; a Loaded line with the path appears in the terminal when they load.

When several apply, which wins

Every applicable file is concatenated into context; nothing overrides anything. Order is managed, user, then project files from the filesystem root down to your working directory, with CLAUDE.local.md after CLAUDE.md in each directory and user rules before project rules, so the most specific text comes last. If two instructions conflict, Claude may follow either one, so keep them consistent; with claude-md-and-agents-md mode each directory's CLAUDE.md files come before its AGENTS.md.

CLAUDE.md content is sent as a user message after the system prompt, and Claude treats it as guidance, not enforced configuration; use hooks or permissions for hard rules.

Size limits

Earlier documentation recorded a 4 MiB full-file loading limit and a recommended length of about 200 lines. In 2.1.309, oversized nested CLAUDE.md files instead load only their beginning, preventing repeated compaction; the release note does not specify the retained prefix size. Keep startup/root-file handling separate from this nested-file exception. Large combined instruction/import warnings scale with context size; paths lists retain their independently documented pattern budget. A paths list remains capped at 1,000 brace-expanded patterns / 4 MiB; patterns beyond the budget are used unexpanded, per the earlier documentation audit.

The 200-line / 25KB truncation applies only to auto memory's MEMORY.md, not to CLAUDE.md.

Writing them

QuestionClaude Codechecked at 2.1.299
One file for several harnesses

Yes. With the default Project instructions mode claude-md-or-agents-md, a repo with only AGENTS.md works as-is; set claude-md-and-agents-md to read both, or claude-md to ignore AGENTS.md. Set it in /config or in ~/.claude/settings.json / --settings / managed settings under pluginConfigs["cc-plugin-agents-md@builtin"].options.instructionFiles (ignored in project and local settings). Alternatively put @AGENTS.md in a CLAUDE.md, which works on any version and never double-loads.

Direct AGENTS.md reading needs v2.1.277+ and the built-in plugin enabled; before v2.1.281 it didn't work on Bedrock/Vertex/Foundry or with telemetry off. Before v2.1.285 the plugin ID was agents-md@builtin (still accepted).

Other tools' files such as .cursor/rules, .github/copilot-instructions.md or GEMINI.md aren't read at runtime; /init and /import copy them into CLAUDE.md once.

Rules for some paths, or only on request

Yes: a .claude/rules/*.md file with YAML frontmatter paths: (a list or comma-separated globs, brace expansion allowed, e.g. src//*.{ts,tsx}) loads only when Claude reads, writes or edits a matching file; paths is the only frontmatter field read. There's no dedicated on-demand rule mechanism; you can @-mention a rule file in your prompt to attach it like any file, and the docs point to skills for instructions loaded only when asked for.

If the frontmatter YAML doesn't parse, the rule loads unconditionally; claude --debug shows the parse error.

Path-scoped rules that live in a symlinked directory outside the project don't load even after external imports are approved; only unscoped ones do.

Path-scoped rules are summarized away by compaction and reload on the next matching file access.

Include other files

Yes: write @path/to/file anywhere in a CLAUDE.md or AGENTS.md (relative to the importing file, absolute, or @~/...); imported files load at launch and can import further, up to four hops deep. Escape spaces with \ ; imports inside code spans or fenced blocks are ignored. Imports in a project file that resolve outside the working directory need a one-time approval dialog; imports in user-scope files load without it.

Imports organize content but don't save context: imported files load in full at launch.

An external import inside a directly-read AGENTS.md loads only if external imports were already approved for the project, with no prompt.

Add instructions from config or flags

Use --append-system-prompt "..." or --append-system-prompt-file <path> to add system-prompt-level text, or --system-prompt/--system-prompt-file to replace the default prompt. CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 with --add-dir <dir> loads that directory's CLAUDE.md, .claude/CLAUDE.md, .claude/rules/*.md and CLAUDE.local.md, and admins can inline instructions with the managed-settings key claudeMd. URLs aren't supported as instruction sources.

--append-subagent-system-prompt(-file) adds text to subagent prompts in -p mode only.

In resumed conversations the recorded system prompt is reused; pass --system-prompt-snapshot off while iterating on appended text.

Generate a starter file

/init analyzes the codebase and writes a starter CLAUDE.md, or suggests improvements if one exists; it also folds in .cursor/rules/.cursorrules and .github/copilot-instructions.md. With CLAUDE_CODE_NEW_INIT=1 it runs an interactive flow that can also set up CLAUDE.local.md (added to .gitignore), skills and hooks, and reads AGENTS.md, .windsurf/rules, .clinerules and .devin/rules. /import [codex|gemini|cursor] copies another agent's instruction files into CLAUDE.md, and /doctor prompt-audit audits existing instruction files.

/import needs v2.1.213+ (Cursor v2.1.265+) and isn't available on Bedrock, Vertex, Foundry or with feature-flag fetching off; /doctor prompt-audit needs v2.1.283+.

Control

QuestionClaude Codechecked at 2.1.299
See what loaded, and apply edits

Run /context and look under Memory files for what loaded at launch; /memory lists CLAUDE.md, CLAUDE.local.md and directly-read AGENTS.md paths (v2.1.280+) and opens them in your editor. On-demand files print a Loaded <path> line, and an InstructionsLoaded hook receives file_path, memory_type and load_reason (session_start, nested_traversal, path_glob_match, include, compact) for each CLAUDE.md or rule load. There's no dedicated reload command; /compact re-reads the project-root CLAUDE.md and unscoped rules from disk, and a new session picks up all edits.

InstructionsLoaded doesn't fire for an AGENTS.md read directly through the Project instructions setting, only for one imported by or symlinked from a CLAUDE.md.

Changing the Project instructions mode applies from your next message.

Turn them off or skip some

To skip instruction files for a run, use --bare (or CLAUDE_CODE_SIMPLE=1), --safe-mode, or CLAUDE_CODE_DISABLE_CLAUDE_MDS=1; --setting-sources user drops project files and rules. To skip specific files, list absolute paths or globs in claudeMdExcludes in any settings file (arrays merge across layers), e.g. "claudeMdExcludes": ["/vendor//CLAUDE.md"]. Set instructionFiles to claude-md to ignore AGENTS.md, and set omitClaudeMd in a subagent definition to start that subagent without user, project and local CLAUDE.md.

claudeMdExcludes can't exclude the managed CLAUDE.md.

The built-in Explore and Plan subagents skip CLAUDE.md at startup.

Enforce instructions for an organisation

Partly

Admins can deploy a managed CLAUDE.md (macOS /Library/Application Support/ClaudeCode/CLAUDE.md, Linux/WSL /etc/claude-code/CLAUDE.md, Windows C:\Program Files\ClaudeCode\CLAUDE.md) or set claudeMd in managed settings. It loads before user and project files and claudeMdExcludes can't exclude it. Managed settings can also set instructionFiles to managed-only, which leaves out user and project CLAUDE.md, rules and AGENTS.md at launch.

A user can still start with --safe-mode (or CLAUDE_CODE_SAFE_MODE=1), which skips managed CLAUDE.md along with other customizations.

Instructions are guidance, not enforcement; use managed permissions.deny, sandbox settings or hooks for hard limits.

In managed-only mode, subdirectory CLAUDE.md files and path-scoped rules still load on demand.

Notes and sources

Claude Code, 10 sources
  • User and managed CLAUDE.md and .claude/rules do not suppress AGENTS.md fallback.
  • Direct AGENTS.md loads do not fire InstructionsLoaded hooks; imports through CLAUDE.md do.
  • Instructions provide context, not enforced operation policy.
  • 2026-10-24: the earlier blanket statement that every oversized CLAUDE.md is skipped is superseded for nested files by 2.1.309 publisher notes. Current docs retrieval was blocked (HTTP 403); no new truncation byte count is asserted.
  • 2.1.311 publisher fixes stale CLAUDE.md after automatic compaction and startup/file-operation freezes with very long list items. Earlier nested-file truncation evidence remains separately scoped; no new byte budget or runtime proof.
  • 2.1.312 publisher fixes Claude overwriting a very large CLAUDE.md, rules file or @-included file in a subdirectory after seeing only its start; Write now asks Claude to read it all or edit in place. This does not change which instruction files load or how much of them.
Which files it reads, 1
Where it looks, and when nested files load, 1
When several apply, which wins, 1
Size limits, 2
One file for several harnesses, 3
Rules for some paths, or only on request, 2
Include other files, 1
Add instructions from config or flags, 3
Generate a starter file, 2
See what loaded, and apply edits, 4
Turn them off or skip some, 5
Enforce instructions for an organisation, 3