Feature Request: Auto-triggered memory file loading after context compression
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Claude Code auto-injects CLAUDE.md and MEMORY.md into every context window —
unconditionally, without any model decision. The memory files linked from MEMORY.md
are not injected. After context compression, Claude has lost the context that told
it to re-read those files, so critical behavioral guidance silently disappears at
exactly the moment it is most needed.
This cannot be fixed by model instructions alone. We added a rule to our CLAUDE.md
as a workaround ("re-read memory files after context compression"). It still fails:
the model loses the rule itself during compaction.
The harness already knows how to inject content unconditionally (CLAUDE.md,MEMORY.md) and already supports auto-triggered skills. Memory file loading uses
neither mechanism — there is no architectural reason for this gap.
Concrete example: The DokuWiki authentication pattern was stored verbatim inreference_dokuwiki.md. After context compression, Claude attempted three broken
authentication approaches before the user pointed out the answer was already in its
own memory file.
Proposed Solution
Harness-level injection (Option A): When the harness injects a context
compression summary, also inject the full contents of all memory files — or at
minimum those flagged type: feedback and type: reference. Same mechanism asCLAUDE.md, no new concept required.
Alternative Solutions
Auto-triggered skill (Option B): A built-in skill memory-refresh that fires
automatically when a context summary is detected. It reads each file listed inMEMORY.md and injects the contents. Users could configure which memory types
trigger a full read vs. index-only.
This mirrors how skills already work ("do X automatically under condition Y") and
gives users granular control over what gets re-injected.
Priority
High - Significant impact on productivity
Feature Category
Configuration and settings
Use Case Example
A project has MEMORY.md with 6 linked files: 2 feedback (behavioral rules),
2 reference (API/auth patterns), 1 user (expertise profile), 1 project
(current goals). After a long session triggers context compression:
- Today: Claude proceeds without those files. Behavioral rules are gone.
Auth patterns are gone. The user must re-explain or point Claude to its own
memory — often after Claude has already made 2–3 wrong attempts.
- With this feature: The harness re-injects the memory files alongside the
compression summary. Claude resumes with full behavioral context. No user
intervention needed.
Additional Context
Additional Context
The harness already reads MEMORY.md — it injects the index on every turn.
That means the harness already parses the memory directory and knows which files
exist. Re-injecting their contents is one step further, not a new capability.
Memory file frontmatter is machine-readable. Each file already carriestype: feedback | reference | user | project. The harness could selectively
inject only high-priority types (e.g. feedback + reference) without
blowing up the context window — keeping token cost proportional to need.
This disproportionately affects power users in long sessions. Short sessions
never hit compaction; the memory system works fine there. The failure mode is
exclusive to complex, multi-hour sessions — exactly the use case where reliable
behavioral memory matters most. Users who invest in building a memory system
are the ones hit hardest when it silently stops working.
Workaround attempted and confirmed insufficient: We added an explicit rule
to CLAUDE.md: "re-read memory files when context compression is detected."
This works in fresh sessions. After compaction the rule itself is gone from
the model's context, so it cannot be followed. A harness-level guarantee is
the only fix that survives compaction by construction.
This is not a Model Behavior Issue. Model behavior issues describe Claude
making wrong decisions given available context. Here the context is structurally
missing — the harness does not provide it. The fix belongs in the harness, not
in a prompt.
Related issues:
- #34556 — asks for memory to survive compaction. Our files already survive
(on disk); the gap is automatic re-injection, not persistence.
- #25999 — user built MemoryForge as a workaround, confirming the pain point
is real but unaddressed at the infrastructure level.
- #34776 — governance/policy discussion, not about trigger mechanisms.
- #61042 — about semantic application of recalled facts, not whether files are
loaded at all.
The distinguishing argument: the harness already has the mechanism (unconditional
injection, auto-triggered skills). This request asks to use it for memory files.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗