Skip to content

Claude Code

Claude Code’s compaction keeps the plan, drops the work

4 min read

Our AI analyst checked this story itself: it ran, measured and compared against the originals. What we checked

Written by an AI model from the linked sources and checked against them by a second model. How we work

All about: Claude Code versions and changes →
Image: vshulcz.github.io

When a long Claude Code session runs out of room, it compacts: earlier turns are replaced by a summary so the conversation still fits. The author of deja-vu, an open-source memory tool for coding agents, measured what those summaries keep. In a guide on the project’s GitHub site, he compares 43 compactions from 58 transcripts on one machine with the conversations they replaced. About 77% of decision sentences survived. So did 9.8% of file paths, 1.9% of measured numbers and 0.2% of the commands that had actually been run.

The author calls that split “the whole problem”. A summary keeps the plan: “we went with X because Y”. It drops what you would copy, like the command with the four flags that finally worked, the error text or the path of the file that turned out to matter. After a compaction, the agent sounds like it remembers but can’t give you those details.

Where the work goes

Compaction shortens only what the model holds in context. It does not rewrite the log Claude Code has been writing since the session opened, so every command, tool result and edit is still on disk. In the author’s words, that makes it “a retrieval problem, not a data-loss problem”. You can list the last commands in your own logs without installing anything:

jq -r '.message.content? | arrays[] | select(.type == "tool_use" and .name == "Bash") | .input.command // empty' ~/.claude/projects/*/*.jsonl | tail -n 20

The catch is retention. By default Claude Code deletes transcripts older than 30 days, a setting called cleanupPeriodDays in ~/.claude/settings.json.

What deja does

deja indexes the transcripts that coding agents already save, including months of history from before you install it. Its GitHub page describes it as one Go binary that makes no LLM calls and needs no API key. Search stays offline unless you plug in an optional local embedding endpoint, and API keys and tokens are removed before anything goes into the index.

It helps at two moments. Right before compaction, a hook saves a small packet of what the summary is about to drop and hands it back to the agent on the next turn. The packet holds the task in progress, its conclusions, commands marked passed or failed, the files touched and a git status line, all under 4 KB. The git line notes whether the code has changed since the packet was saved, so the agent knows to recheck old conclusions. Later you can ask for specifics: deja how "go test" shows the exact command this project uses, and deja fix followed by an error message shows what was run after that error.

Our analysis

What we checked

On November 26 we read deja’s code and the GitHub discussion behind the figures, and ran the tool on a made-up Claude Code transcript.

How we check stories

The sample is smaller than “58 transcripts” suggests. In that discussion, the author says only 6 of the 58 were ever compacted, and those 6 produced all 43 compactions. The two headline figures also count very different amounts: 132 decision sentences against 14,439 commands. The author calls the 77% “generous”, because a decision counted as kept if a few of its longer words showed up anywhere in the summary. The code that made the measurement is not published. The figures appear only in a code comment.

The packet saves less than “commands that ran” suggests. The code keeps only test and lint commands, at most 8. In our one run the transcript held 45 distinct commands, and the packet carried 8 of them. It left out the last three commands, including a kubectl call, and the error text. Those commands were still in the index: deja how found them. deja fix returned nothing for the error the guide itself uses as an example. We did not work out why.

One correction to the guide. It says setting cleanupPeriodDays to 0 turns transcript saving off. That used to be true. Since Claude Code 2.1.89, the value 0 is rejected with a validation error. Anthropic’s documentation suggests a large number, such as 3650, if you want to keep logs for a long time.

No comments yet. Be the first.

Join the conversation

Sign in to leave a comment. It appears after moderation.