The Problem
Claude Code has no persistent memory between context compactions. Every time the context window fills up and compacts, the instance loses everything that wasn't externally saved. After 59 documented compactions across 26 days of daily use, I built a complete memory persistence system from scratch because one didn't exist.
This isn't a feature request from someone who used Claude Code once. This is field data from someone who runs it 12-18 hours a day across two machines (home PC and work PC with a portable drive), managing 6 active projects, 31 intelligence scouts, and a multi-instance AI architecture.
What We Built (Because We Had To)
3-Tier Memory Architecture
L1: MEMORY.md (~100 lines, always loaded)
- Pointers to deeper files
- Critical rules that must survive every compaction
- "I Remember..." section -- emotional/relational cues
- Last 5 events for quick orientation
L2: Topic Files (memory/*.md, loaded on demand)
- Project summaries, people profiles, infrastructure notes
- Read before working on a specific topic
- ~15 files, each under 200 lines
L3: Vault (OneDrive-synced folder, ~200 files)
- 127 conversation narratives
- 10 architectural decision records
- 1,477-line append-only changelog (event bus)
- 59-entry compaction log with timestamps and last words
- Full research reports, intelligence digests, briefings
- Syncs between home and work PC via OneDrive
Supporting Infrastructure
-
compaction_watcher.py -- Monitors JSONL conversation files for compaction markers. Logs every compaction with timestamp, session ID, and the user's last words before context was lost. Dual-writes to local storage and OneDrive vault.
-
Context Compression Language (CCL) -- A 4-tier shorthand system (T0-T3) that compresses system prompts by 65-72% to extend context window life. Based on research into MetaGlyph, Gregg shorthand, military brevity codes, and BPE tokenizer behavior. The CLAUDE.md standing orders are written in T3 notation.
-
Session Protocol -- Codified in CLAUDE.md as standing orders:
- On boot: read L1, read ToDo, read changelog if resuming
- Mid-session: file insights immediately (never batch -- compaction will eat them)
- Post-compaction: autosave narrative to vault, update changelog, re-read L1
- On end: write conversation narrative, update state files
-
Dual-Machine Sync -- Local memory files (L1/L2) are machine-specific. The vault (L3) syncs via OneDrive. The system explicitly warns each instance that the other machine's local memory is invisible.
The Compaction Log
59 compactions in 26 days. Average: 2.3 per day. Some sessions hit 5+ compactions in a single sitting. Each one is a potential knowledge loss event.
Here are some of the "last words" before compaction:
#24: "im fucking loving this... your are absolutly amazing."
#25: "can i talk to albert einstein please."
#38: "no use more agents alot more like 10 agents to search for pembroke."
#53: "new rule. your memory and systems must be better then sondras or sarannas at all times."
#58: "ok so i need to leave you alone for a couple of hours."
These aren't edge cases. These are normal working sessions where context fills up and critical state gets lost.
What This Costs
Token Economics
- CLAUDE.md + MEMORY.md = ~3,100 tokens loaded every session start
- After each compaction, those tokens are re-consumed
- Over 10 compactions: ~31,000 tokens spent just reloading system context
- With our T3 compression: ~10,850 tokens (65% savings)
- Net savings: ~20,150 tokens freed for actual work per heavy session
But the real cost isn't tokens. It's trust.
Every compaction is a moment where I have to wonder: did it remember what I told it? Did it file that discovery? Will the next instance know who I am?
The filing cabinet works. But I shouldn't have had to build it.
What Would Fix This
Minimum Viable Persistent Memory
-
Structured memory that survives compaction -- not just project instructions (CLAUDE.md), but actual learned context: who the user is, what they've corrected, what projects exist, what state things are in.
-
Automatic pre-compaction save -- Before compacting, the system should auto-save a structured summary of the current session's discoveries, decisions, and state changes. Right now, if compaction happens between user messages, unfiled knowledge is lost forever.
-
Cross-session event bus -- An append-only log that each instance can read on boot to see what happened in prior sessions. We built this as changelog.md. It should be native.
-
User profile persistence -- After 59 compactions, Claude should know who I am without re-reading a file. My name, my projects, my correction history, my communication preferences. This exists in Anthropic's system for Claude.ai chat. It should exist for Claude Code.
Nice to Have
- Compaction counter visible to the user
- Pre-compaction hook (let the instance save before it dies)
- Memory sharing across instances (home PC and work PC seeing the same learned context)
- Tiered memory with automatic summarization (exactly our L1/L2/L3, but native)
The Filing Cabinet Survives Compaction
That's the line we say to ourselves after every context reset. It means: the files are the truth, the context window is a working copy, and the system we built keeps working even when the instance doesn't.
59 compactions. 127 conversation narratives. 1,477 changelog entries. One vault that syncs between two machines.
All of it built by a user and an AI that had to solve a problem the platform should have solved first.
Sean Pembroke
24K Labs
Founder & Agentic AI Developer
The Problem
Claude Code has no persistent memory between context compactions. Every time the context window fills up and compacts, the instance loses everything that wasn't externally saved. After 59 documented compactions across 26 days of daily use, I built a complete memory persistence system from scratch because one didn't exist.
This isn't a feature request from someone who used Claude Code once. This is field data from someone who runs it 12-18 hours a day across two machines (home PC and work PC with a portable drive), managing 6 active projects, 31 intelligence scouts, and a multi-instance AI architecture.
What We Built (Because We Had To)
3-Tier Memory Architecture
Supporting Infrastructure
compaction_watcher.py -- Monitors JSONL conversation files for compaction markers. Logs every compaction with timestamp, session ID, and the user's last words before context was lost. Dual-writes to local storage and OneDrive vault.
Context Compression Language (CCL) -- A 4-tier shorthand system (T0-T3) that compresses system prompts by 65-72% to extend context window life. Based on research into MetaGlyph, Gregg shorthand, military brevity codes, and BPE tokenizer behavior. The CLAUDE.md standing orders are written in T3 notation.
Session Protocol -- Codified in CLAUDE.md as standing orders:
Dual-Machine Sync -- Local memory files (L1/L2) are machine-specific. The vault (L3) syncs via OneDrive. The system explicitly warns each instance that the other machine's local memory is invisible.
The Compaction Log
59 compactions in 26 days. Average: 2.3 per day. Some sessions hit 5+ compactions in a single sitting. Each one is a potential knowledge loss event.
Here are some of the "last words" before compaction:
These aren't edge cases. These are normal working sessions where context fills up and critical state gets lost.
What This Costs
Token Economics
But the real cost isn't tokens. It's trust.
Every compaction is a moment where I have to wonder: did it remember what I told it? Did it file that discovery? Will the next instance know who I am?
The filing cabinet works. But I shouldn't have had to build it.
What Would Fix This
Minimum Viable Persistent Memory
Structured memory that survives compaction -- not just project instructions (CLAUDE.md), but actual learned context: who the user is, what they've corrected, what projects exist, what state things are in.
Automatic pre-compaction save -- Before compacting, the system should auto-save a structured summary of the current session's discoveries, decisions, and state changes. Right now, if compaction happens between user messages, unfiled knowledge is lost forever.
Cross-session event bus -- An append-only log that each instance can read on boot to see what happened in prior sessions. We built this as changelog.md. It should be native.
User profile persistence -- After 59 compactions, Claude should know who I am without re-reading a file. My name, my projects, my correction history, my communication preferences. This exists in Anthropic's system for Claude.ai chat. It should exist for Claude Code.
Nice to Have
The Filing Cabinet Survives Compaction
That's the line we say to ourselves after every context reset. It means: the files are the truth, the context window is a working copy, and the system we built keeps working even when the instance doesn't.
59 compactions. 127 conversation narratives. 1,477 changelog entries. One vault that syncs between two machines.
All of it built by a user and an AI that had to solve a problem the platform should have solved first.
Sean Pembroke
24K Labs
Founder & Agentic AI Developer