A working memory made of files.
A cleared session starts fresh and remembers nothing it decided, and the vendor's documentation states the fresh window in its opening sentence. Paper 001 derived why the transcript cannot be the carrier; this paper describes the carrier built to replace it: an index that points, topic files that hold one fact each, a state file that is replaced at handoff, and a knowledge store that is merged, never overwritten, with hooks at the session's start and stop so the loop is not optional. The one phase no hook enforces is the one that decayed.
§1A fresh window destroys exactly what was hardest to earn
The cheap exit from Paper 001's accumulation is one command. Claude Code's cost documentation
prices it: "When you want a fresh start instead of continuity, /clear costs
nothing".[1] And its memory documentation states what the command produces: "Each
Claude Code session begins with a fresh context window."[2] The command costs nothing
to run. What it costs the project depends entirely on what was carried out first.
What a session accumulates that is worth anything arrives late and slowly: which approach was chosen and why, which plausible path turned out to be a hole, which files are mid-change, what comes next. Cleared unextracted, each is re-derived at full price by the next session — or not re-derived, and the hole is found a second time. The instinct this produces is to never clear, so the knowledge stays loaded. Paper 001 measured where that road ends: seventeen days, 224 MB, a permanent ceiling.
The knowledge has to live somewhere cheaper than the conversation and faster than re-derivation. The idea has a literature: MemGPT pages state between the context window and external storage so an agent's memory outlives what the window holds.[3] The construction measured here is the low-technology end of that idea. The external tier is a directory of Markdown files, and the pager is a shell hook.
§2An index that points, and topic files that hold
The protocol keeps two layers with one source of truth. The machine-local layer lives outside the
repository — "Your project memory lives at ~/.claude/projects/<encoded-project-path>/memory/
(the project path with every / replaced by -)", as the protocol file puts
it — and is loaded automatically when present. The shared layer is the repository's own
memory/ directory, committed and merged like code, which the repository's instructions
declare "the shared knowledge base and the single source of truth for project facts". Durable
facts are promoted from the local layer into the shared one at consolidation; nothing durable is
allowed to end its life machine-local.
Each layer has the same shape: an index file, MEMORY.md, and topic files beside it.
The index is governed by the protocol's bluntest rule: "under 80 lines — it is an INDEX, one line
per topic … Detail lives in the topic file". Its line format is fixed, one pointer per lesson:
- [Title](file.md) — the hook, in one clause. A live line from the machine-local
index shows the shape filled in, quoted in full: - [EU region rename](eu-region-rename.md)
— 2026-07-24: eu-central = Budapest (was eu-east), eu-west = Frankfurt (was eu-central);
code+DB+workers+policies all migrated (commit ffa166a, v0.4.6). A date, the fact, and
enough of a hook to know when to open the file; nothing in the line argues or narrates. The topic
file holds one fact, with the concrete story, a stated why, and a stated
how to apply.
The 80-line ceiling is not neatness; it is the price of the read path. Whatever sits in the index is paid for at every session start; the detail must load on demand. The harness vendor states the identical tradeoff for its own always-loaded instruction files: "target under 200 lines per CLAUDE.md file. Longer files consume more context and reduce adherence", with the auto memory it writes for itself capped at the "first 200 lines or 25KB" per session.[2] Two budgets from two authors, one arithmetic: an always-loaded file is a standing tax, and only an index is cheap enough to load always.
Admission is the part that keeps the files small. The operator's writing guideline sets the bar: a memory records "something non-obvious that cost something to learn. Not what the repo already says, not what git history shows. The test: would a competent person repeating this work fall into the same hole without it?" It closes the loop on error: "Write the memory even when — especially when — the lesson is that the earlier analysis was wrong." The estate's topic files show the habit; one is titled prove your check can fail. The same guideline separates output from learning: "The paper is the artefact; the memory is the lesson." What a session produced is already saved by the repository; what it learned is saved nowhere unless the protocol saves it.
§3State is replaced; knowledge is merged
A memory that only appends is a transcript with a better filename. Two write disciplines, deliberately different, keep this one from becoming that. The first is the handoff, run before a clear. It writes a session-state file that is per-developer and gitignored: "your own session continuity, never shared or committed". And it does not append: "REPLACE the file — current state only, not history; keep under ~80 lines". Its headings are the enumeration of what §1 said a clear destroys, verbatim from the command that writes them:
# .claude/session-state.md — replaced at every handoff
## Handoff: [output of `date` command]
## Working On
## Modified Files
## Decisions Made
## Gotchas Discovered
## Next Steps
## Blocked On
The second discipline is consolidation, a command the protocol frames as "Memory consolidation pass — like REM sleep", run after the handoff at the end of a productive session. It works in four named phases: "Phase 1 — Orient", "Phase 2 — Gather recent signal" (this conversation, the state file's durables, the local layer's promotions), "Phase 3 — Consolidate", and "Phase 4 — Update index". Its write rule is the opposite of the handoff's: "Merge, never overwrite." Changes are additive and atomic so git merges stay trivial; facts are stated as facts, not "we decided"; relative dates are converted to ISO; and deletion is part of the discipline, not a violation of it: "If a fact contradicts an existing one, replace the stale fact and note the date."
The published analog of this fold-forward move is recursive summarization, where new context is repeatedly folded into a running summary and long-conversation consistency improves over keeping raw history.[4] What that literature does not say is which sentences a summary silently drops — which is exactly why the consolidation here does not summarize wholesale: it admits one fact at a time, under §2's test, with the why and the how-to-apply written out. State is replaced because only the present matters. Knowledge is merged because the past keeps mattering until a dated fact contradicts it.
§4A loop enforced by hooks, and the phase that still decayed
None of this runs on discipline alone. At session start, the repository's hook injects three things before the first turn: the last five commits with the working-tree status, the memory index in full, and the first 40 lines of the state file. One of the estate's session-start hooks states the rationale for injection in general terms: "whatever they print is already in context when the session opens", at no tool call and no turn. When the state is two or more days old, the injection carries its own warning: "Commits made since then are NOT reflected in memory or session state. Trust 'git log' over the 'Active Context'."
The write side is guarded by two different stop hooks. The workspace's blocks a closing
session once per session, with the instruction to "run /handoff to persist session state into
project memory, then /dream to consolidate long-term memory." The repository's is throttled
instead: it interrupts only when the state file is older than 45 minutes and the
repository actually changed — a new HEAD or a changed status hash against a baseline snapshotted
at session start. A session that changed nothing owes nothing, and the throttle is load-bearing:
a loop that interrupts every stop gets disabled, and a disabled loop is no loop. After a
/clear, a manual command, /catchup, rebuilds working context from the
same files — index, state, ten commits of log — and ends by asking the operator to "Confirm next
task or redirect me."
An index of one line per topic, loaded whole before the first turn; topic files holding the detail, read on demand; one command that replaces state and one that merges knowledge; a scratch layer per machine and a committed layer per repository, with promotion between them; and hooks at start and stop so the loop closes without being remembered.
The loop's weak point is the phase the hooks cannot see into. Phase 4's instruction is exact:
"Rewrite memory/MEMORY.md — keep under 80 lines. It is a pointer file, not a content
dump." Rewriting is work with no enforcing hook behind it, and on the machine measured for this
series, it decayed.
The flagship index held one pointer line for seventeen topic files, and 290 lines of session history
In the repository that originated the protocol, the index had stopped being an index. Session summaries accumulated inside it as HTML comments instead of being consolidated into topic files, and the pointer format survived in exactly one line:
# the rule (the consolidation command, Phase 4)
"Rewrite memory/MEMORY.md — keep under 80 lines.
It is a pointer file, not a content dump."
# the index, measured 2026-09-21
wc -l memory/MEMORY.md 539 lines # 97,257 bytes
grep -c '^- \[' memory/MEMORY.md 1 # pointer lines, for 17 topic files
# 290 of the 539 lines are session history filed as <!-- --> comments
The hooks around that file kept running while it grew — the session history embedded in it is their residue. The handoff replaced, the consolidation merged, the injection injected: 539 lines of it, at every session start. A loop is as durable as its least-enforced phase, and a rule with no check behind it is a preference. Two limits close this paper: the construction described is one operator's, measured on one machine, and nothing here shows it transfers; and the decay just shown is not explained by effort alone — the rule the index broke has a checker, and where that checker lives is Paper 003's subject.
The commands, hooks and memory files quoted here belong to one practitioner's workstation, a Digital One machine, and are not public: the quoted rules are printed verbatim from the installed command and hook files, and the defect's measurements, printed with their commands, are the operator's account and cannot be re-run by a reader. The hooks, commands and file format, with the estate's paths removed, are public as a reference implementation at memory-context-protocol. Vendor sentences are quoted from public documentation with the date read; no vendor is compared with another here, and none should be inferred. Deliberately absent: prices, plans and tiers, and deployment internals.
References
- Anthropic, Claude Code — Manage costs effectively, on
/clearand compaction. code.claude.com/docs/en/costs, read 21 September 2026. - Anthropic, Claude Code — How Claude remembers your project; the quotation in §1 is the page's opening sentence, and the size and load-cap quotations in §2 are from its CLAUDE.md guidance and auto-memory comparison table. code.claude.com/docs/en/memory, read 21 September 2026.
- C. Packer, S. Wooders, K. Lin, V. Fang, S. G. Patil, I. Stoica and J. E. Gonzalez, "MemGPT: Towards LLMs as Operating Systems", arXiv:2310.08560 (2023).
- Q. Wang, Y. Fu, Y. Cao, S. Wang, Z. Tian and L. Ding, "Recursively Summarizing Enables Long-Term Dialogue Memory in Large Language Models", Neurocomputing; arXiv:2308.15022.