Per-subagent control over auto-memory (MEMORY.md) injection

Open 💬 0 comments Opened Jul 13, 2026 by brianmeyers007

What I'm trying to do

Keep the full project auto-memory (MEMORY.md) loaded in the main interactive session, but have Agent-tool subagents receive only a lean CLAUDE.md primer — not the full project auto-memory.

Why

Auto-memory can grow to a meaningful size (e.g. ~10k tokens). Today every custom and general-purpose subagent inherits the entire memory hierarchy at startup, so that cost is paid on every delegated subagent — even when the subagent only needs a short, task-scoped primer. For workflows that fan out many subagents this is a recurring per-subagent context tax, and it also hands delegates project/context they don't need for their narrow task (which can distract as much as it costs).

Current behavior (v2.1.207)

  • Custom and general-purpose subagents load the full memory hierarchy (~/.claude/CLAUDE.md, project rules, CLAUDE.local.md, managed policy) plus the project auto-memory MEMORY.md.
  • Only the built-in Explore and Plan agents skip this — and they skip CLAUDE.md too, so there is no way to express "skip auto-memory but keep CLAUDE.md / preloaded skills."
  • The memory frontmatter field is a separate per-agent persistent store, not a toggle for the project auto-memory.
  • --bare / CLAUDE_CODE_DISABLE_AUTO_MEMORY are session-wide, not per-subagent.

So there is no supported way to say: "this subagent should skip the project auto-memory injection but still load CLAUDE.md and its preloaded skills."

Proposed

A per-subagent control — for example a frontmatter field such as autoMemory: false (or projectMemory: false) on custom agent definitions, and/or a settings key — that lets a subagent skip the project auto-memory injection while still loading CLAUDE.md and any preloaded skills. That would let users put a lean primer in CLAUDE.md (inherited by delegates) and keep the heavy auto-memory scoped to the main session.

Alternatives considered

  • SessionStart hook to re-inject the memory index into the main session only (SessionStart fires main-session-only), combined with disabling auto-memory session-wide — works in theory, but requires disabling auto-memory globally and hand-rolling the main-session memory load through a hook, which is fragile and can silently fail.
  • Keeping the index small — helps, but the content is load-bearing for the main session, so there is a floor.

Environment

Claude Code v2.1.207, macOS.

View original on GitHub ↗