Observed in: Claude Code internal architecture
Variable: MEMORY_INSTRUCTION_PROMPT
The meta-instruction that wraps all loaded CLAUDE.md memory files in the system prompt. This single line establishes that user-provided instructions take absolute precedence over default behavior.
Codebase and user instructions are shown below. Be sure to adhere to these instructions.
IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them
exactly as written.
Files are loaded in reverse order of priority (latest = highest priority):
/etc/claude-code/CLAUDE.md) — Global instructions for all users~/.claude/CLAUDE.md) — Private global instructions for all projectsCLAUDE.md, .claude/CLAUDE.md, .claude/rules/*.md in project roots) — Checked into codebaseCLAUDE.local.md in project roots) — Private project-specific instructions~/.claude/CLAUDE.md, .claude/CLAUDE.md, and all .md files in .claude/rules/ are checked in each directoryMemory files support transitive file inclusion:
@path, @./relative/path, @~/home/path, or @/absolute/pathMemory files support YAML frontmatter with a paths field for conditional injection:
---
paths:
- src/components/**
- "*.tsx"
---
Files with paths frontmatter are only injected when the active file matches the glob patterns.
MAX_MEMORY_CHARACTER_COUNT: 40000 characters (recommended maximum per file)claudeMdExcludes setting: Glob patterns to exclude specific CLAUDE.md filesMAX_INCLUDE_DEPTH: 5 levels of transitive inclusion