How does Claude Code resolve and merge CLAUDE.md memory files from the user home directory, project root, and parent directories, and inject them into the system prompt at session start

en
100.0% sentence pass·7/7 cited·7/7 citations valid·115 fn·0 dec·1002 sem
Memory & Auto-MemoryContext & Prompt SystemApplication Bootstrap & Entrypoints

Overview

The whitelist does not contain the functions that resolve, merge, or inject CLAUDE.md memory files into the system prompt .

Steps

  1. The closest visible touchpoint is getSystemPrompt, which composes the system prompt sections and delegates memory loading to a loadMemoryPrompt() helper that is not present in the whitelist .
  2. QueryEngine.submitMessage calls fetchSystemPromptParts at session start to assemble defaultSystemPrompt, userContext, and systemContext, but fetchSystemPromptParts and the CLAUDE.md discovery/merge logic are not in the provided source .
  3. The actual resolution of user-home, project-root, and parent-directory CLAUDE.md files, and their merge order, cannot be traced from the whitelisted functions .

State touched

  • (none citable from whitelist)

Decisions

  • (none)

I can't answer this precisely from the provided scope — the memory-file resolution/merge code (loadMemoryPrompt, fetchSystemPromptParts, and the CLAUDE.md directory walker) is outside the whitelist .