Engram Blog · Published August 9, 2026

After the Compaction: Getting Your Decisions Back on Purpose

When Claude Code compacts, it replaces your conversation with a lossy summary — and the agent trusts it, confidently rebuilding decisions it half-remembers wrong. Here's how to recover the exact words, and the CLAUDE.md rule that makes it automatic.

If you use Claude Code seriously, you know the moment. Not the slow fog as the context meter climbs — the sharp one a little later, when the meter hits the ceiling and the harness compacts. A notice slides by. The session keeps going. The agent still sounds sure of itself. But something you settled two hours ago is now a sentence in a summary you never wrote and never approved.

Most of the time you don't notice, because most of what got compressed didn't matter. The time it bites is when the thing that got dropped was a decision. Here's one we've seen play out, described generically because the shape is what matters: a team had agreed, in detail, that a service should send email one specific way — a particular path, chosen for particular reasons, with the obvious alternative ruled out on purpose. The agent understood it at the time. It even restated the constraint back before everyone moved on. Then, hours later, a compaction quietly condensed that stretch of conversation. The agent lost the details, kept a vague shape of “handle email,” and confidently built a differentdelivery path — the one that had been rejected — cleanly, with a tidy explanation of why it made sense. Nobody caught it until a human re-read the code and said: wait, that's not what we agreed.

That's the part worth sitting with. The agent didn't forget out loud. It forgot silently, and kept its confidence. From the inside, a compacted summary feels exactly like memory — so there was no signal that the ground had shifted, and nothing to check the new version against. The fix isn't a bigger context window; you'll always find the ceiling on a long enough session. The fix is to stop treating the agent's recollection as the source of truth for what you decided, and give it somewhere to look up the exact words instead.

This post is that playbook: what compaction actually does, why the failure is quiet, the two habits that beat it, and the one CLAUDE.md block that turns both into standing behavior. Plus the honest edges — what this gets back for you, and what no stored memory can.

What a compaction actually does

When the context window fills, Claude Code auto-compacts. It doesn't just drop the oldest turns — it condenses the earlier ones into a shorter summary it generates itself, to free up room, and typically keeps the most recent messages and your working file and tool state intact. That summary is lossy compression: it keeps the gist and throws away the specifics. You didn't write it. You didn't approve its contents. And from that point on, for everything that got condensed, the summary isthe agent's memory of what came before.

Normally that's a fair trade. The specifics it drops usually are noise. But “which specifics are safe to drop” is a judgment call made by the summarizer under length pressure — and the detail that matters three hours later is very often exactly the detail that reads as skippable in the moment. The reasoning behind a decision compresses beautifully right up until you need it back.

Why the failure is quiet, not loud

The failure mode here is not the one you'd expect. It isn't the agent saying “I don't remember — can you remind me?” That would be trivial to catch. It's the agent continuing, confidently, from a version of the decision that's subtly or completely wrong.

The reason is structural. Once the summary replaces the earlier turns, there's nothing left in context to notice the loss against. The compression became the source. So confidence stays high while accuracy quietly drops, and the only thing standing between that and a shipped mistake is a human who happens to re-check against what was actually agreed. Take the human out of that loop — which is the direction all of this is heading — and the wrong thing just gets built.

You can't fix a lossy summary by asking for a better summary. The only real antidote is going back to the exact words.

Rule one: save decisions verbatim, in the same turn

When you agree on an architecture, a plan, or a constraint, write it down as you decide it— not a cleaned-up version reconstructed later. Capture the actual wording, the reasoning, and what you rejected and why. The rejected alternative is the highest-value thing you can store, because it's the exact thing a later compaction is most likely to quietly reintroduce.

This is where Engram fits. Engram stores conversations verbatim — the exact words, chunked and embedded for semantic search — rather than summarizing them. So a decision you save stays on record word-for-word through a compaction, instead of surviving only as the summary's paraphrase. Recall is sharpest when a decision was saved deliberately, as a note that carries its reasoning, rather than as a raw scrap of transcript — so the same-turn save habit is what makes later retrieval actually dependable.

Rule two: search after every compaction (and at session start)

Saving is half of it. The other half is making retrieval the first move on the other side of a compaction — pull back the original decision text before the agent writes another line — and doing the same thing at session start, before any new work builds on a half-remembered foundation.

Because Engram keeps the decision's exact words on record, an agent connected to it can search and recover the original text instead of relying on the lossy summary — as long as the decision was actually captured, and the search surfaces the right chunk. That's a real capability, not a guarantee: retrieval runs through semantic search, so it can rank the wrong chunk or return an adjacent fragment. Verbatim storage is what makes exact recovery possible; a good query and a well-saved decision are what make it likely. In practice, a decision saved deliberately with its reasoning comes back cleanly.

The CLAUDE.md block that makes it automatic

You don't want to remember to do any of this by hand, and the good news is you mostly don't have to. CLAUDE.md content persists across a compaction — it's re-injected as instruction context, unlike the conversation summary that just erased your decision. So a rule you write here survives the very event it's meant to defend against.

Drop this into your project's CLAUDE.md:

## Memory (Engram)
- On session start, and ALWAYS immediately after a context compaction:
  search Engram for this project's agreed decisions before continuing.
- When we agree on an architecture, plan, or constraint, save it to Engram
  verbatim in the same turn — with the reasoning and what we rejected.
- Treat Engram's stored record as ground truth over your own recollection
  of earlier context. If they conflict, the stored decision wins.

Be clear-eyed about what this buys you. A CLAUDE.md instruction is a strong, repeatable nudge, not a deterministic hook — the model has to notice that a compaction happened and self-trigger the search, and instruction-following is best-effort, not guaranteed on every turn. What makes the pattern work at all is that the rule outlivesthe compaction while the summary doesn't, so it biases the agent back toward the real decision every time it fires. You harden the nudge with the two habits above — and with the safety net below.

Belt and suspenders: auto-capture for the decisions nobody saved

The save-verbatim habit is the best case, but people forget. So the Engram CLI (v0.4.2+) runs an auto-capture daemon that mirrors your Claude Code transcripts, on by default after login on macOS and Linux. Even a decision nobody explicitly saved is still on record, and still recoverable after a compaction — it just comes back as transcript rather than as a curated note, so it's a floor under the failure, not a replacement for deliberate saves.

Together the three layers stack: auto-capture guarantees something is on record, the save-verbatim habit makes the important things recall cleanly, and the CLAUDE.md rule makes the agent actually go look.

When this won't save you

No memory layer is a substitute for attention, and it's worth being precise about the boundary.

Engram brings back what was recorded— decisions, facts, and any reasoning that was actually written down, including tool calls and intermediate messages the auto-capture daemon mirrored. What it can't restore is the model's live working memory: the synthesis it was holding in context but hadn't yet committed to text. If you /clearin the middle of an investigation, the un-written state you were mid-thought on is simply gone — retrieval gets you the conclusions that made it onto the page, not the half-formed reasoning that didn't.

Two more honest caveats. Recall quality is best when decisions were saved as curated notes with their reasoning, not scraped from raw transcript fragments — the deliberate save path is meaningfully more reliable than pure-transcript recovery. And this is a tool for decisions and facts, not a way to keep the model's attention where you want it; it corrects what was decided, it doesn't do the thinking. Used for what it's for, though, it turns a silent, confident, wrong rebuild back into the thing you actually agreed on.

Set it up in a few minutes

The free tier is enough to try this properly — no credit card. Connect Claude Code by pasting an MCP config with an API key from your dashboard, then install the CLI so auto-capture is running:

npm install -g @getengram/cli
# or: brew install get-engram/engram/engram

Add the CLAUDE.md block above, agree on your next real decision, and save it in the same turn. The next time a compaction slides by, the agent looks it up instead of guessing.

Further reading

Compaction has two costs, and this post is about the first one: correctness — getting the decision righton the other side of the squeeze. The other is money. If you're carrying a full context window just so nothing gets forgotten, you're paying for tokens you could be retrieving on demand instead. We wrote about the token-cost side of this in Stop Paying for Context You Aren't Using — the same habit, seen from the bill. Retrieve instead of carry, and you get both back: a cheaper session and a decision that survives it.

A decision that survives the squeeze

Free tier, no credit card. Connect Claude Code, save what you decide, and recall the exact words after any compaction.