PortalAgentic AI Prompt Researchprompts/24_memory_instruction.md

Memory Instruction (CLAUDE.md System)

Observed in: Claude Code internal architecture Variable: MEMORY_INSTRUCTION_PROMPT

Purpose

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.

Prompt

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.

Memory File Loading Order

Files are loaded in reverse order of priority (latest = highest priority):

  1. Managed memory (/etc/claude-code/CLAUDE.md) — Global instructions for all users
  2. User memory (~/.claude/CLAUDE.md) — Private global instructions for all projects
  3. Project memory (CLAUDE.md, .claude/CLAUDE.md, .claude/rules/*.md in project roots) — Checked into codebase
  4. Local memory (CLAUDE.local.md in project roots) — Private project-specific instructions

File Discovery

@include Directive

Memory files support transitive file inclusion:

Frontmatter Support

Memory 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.

Configuration