What survives Claude Code compaction: 77% of decisions, 0.2% of commands A study of 58 real Claude Code transcripts and 43 compaction events found that summaries preserved about 77% of decision sentences but only 9.8% of file paths, 1.9% of measured numbers and 0.2% of commands actually run, compressing 2.59 GB of raw conversation into 0.72 MB of summaries. The analysis, drawn from one machine's private session logs and recorded in the deja-vu project's cmd/deja/compact.go, frames the loss as a retrieval problem rather than data loss, since the full transcript remains on disk. The project's deja tool addresses this with a pre-compaction hook that re-injects the in-flight task, passed and failed commands, touched files and a git status line into a packet bounded to 4 KB. What compaction drops, and how to get it back the summary keeps the reasoning and drops the work A long session compacts: the harness replaces earlier turns with a summary so the window keeps fitting. The session continues, the agent sounds like it remembers, and the specific thing you will need in twenty minutes is already gone. What survives, measured Across 58 real transcripts and 43 compaction events taken from one machine's history, 2.59 GB of raw conversation compressed into 0.72 MB of summaries. Comparing each summary against the transcript it replaced: - ~77% of decision sentences survived — the conclusions, the "we went with X because Y". - 9.8% of file paths survived. - 1.9% of measured numbers survived. - 0.2% of the commands that had actually been run survived. Those figures come from one machine's private session logs recorded in cmd/deja/compact.go https://github.com/vshulcz/deja-vu/blob/main/cmd/deja/compact.go ; the raw personal transcripts are not published . The reproducible seeded retrieval and context-cost suites live under benchmarks benchmarks.html , and you can inspect your own logs locally with the command below. That split is the whole problem. A summary is written in the language of intent, and the things that cost you an afternoon are not intent: the invocation with the four flags that finally worked, the error text you pasted, the exact span an edit replaced, the path of the file that turned out to matter. Ask after a compaction and you get a confident paraphrase of the plan with none of the parts you would have copied. What compaction does not touch The transcript. Compaction shortens what is in the model's context; it does not go back and rewrite the log the harness has been appending to since the session opened. Every command, every tool result, every edit is still on disk — see where each agent keeps it where-sessions-are-stored.html . So "lost to compaction" is a retrieval problem, not a data-loss problem. The work is there; nothing reads it back. You can inspect what is still in your own Claude Code 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 Watch cleanupPeriodDays in ~/.claude/settings.json : Claude Code deletes transcripts older than 30 days by default, and setting it to 0 disables saving transcripts altogether set a large number such as 99999 to keep them . Codex keeps its logs under ~/.codex/sessions , Cursor in state.vscdb , and the rest follow the paths in the format registry ../registry/README.html . Getting it back Two moments matter, and they are different. During the session deja install --auto wires a pre-compaction hook wherever the host exposes a compaction event Claude Code, Codex, opencode, Cursor CLI, Copilot CLI, VS Code Copilot Chat, Qwen Code, Kimi Code, Cline CLI, Kilo CLI, TRAE CLI, pi, OpenClaw and the other hosts in the compaction reference https://github.com/vshulcz/deja-vu/blob/main/docs/compaction.md ; Hermes through its memory provider; Gemini CLI on the next prompt . When compaction starts, deja reads the active transcript with the same parser that indexes it and captures what the summary is about to drop — no manual checkpoint needed: - The task in flight, conclusions, and open items carried from earlier turns. - Commands that actually ran, marked passed or failed from the harness exit status or recorded output. - Files touched in the session, bounded so the re-injected packet fits inside 4 KB on the next hook call. - A final git status line noting the branch and whether HEAD or the working tree moved since capture, so stale conclusions get re-checked. deja stats reports the raw tool calls before the first edit after compaction, with incomplete observations kept separate. See the compaction reference https://github.com/vshulcz/deja-vu/blob/main/docs/compaction.md for capture limits and privacy controls. Afterwards Ask for the specific thing rather than the story: deja wip what the last session here was doing: task, files, last command deja how "go test" the invocation this project actually uses, with its flags deja fix "pq: too many connections" what was run after this error, where it stayed fixed deja blame internal/index/ingest.go which sessions discussed this file, and what they decided Those questions map onto exactly what a summary drops: the task in flight, commands, failures and file-level decisions. With recall wired in, the agent asks them itself — before it runs a command, after one fails, and when a prompt matches earlier work. Try it on your logs brew install deja-vu curl -fsSL https://raw.githubusercontent.com/vshulcz/deja-vu/main/install.sh | sh npx @vshulcz/deja-vu On Windows, use winget install vshulcz.deja-vu or scoop install deja-vu see getting started getting-started.html for the zip release . Running bare deja builds a local index of transcripts already on disk and opens search immediately; deja install --auto is optional and only needed to wire MCP recall and pre-compaction hooks into your agents. Common questions Why index transcripts instead of running rg over JSONL? Raw logs mix prompts, nested JSON tool payloads, file dumps and ANSI escapes across different schemas per agent. On the seeded multi-session corpus deja bench context , deja matches naive grep's verbatim fact coverage in roughly 250× fewer tokens and about 70× fewer than replaying matched sessions in full , parses structured fields like command exit status and edited lines across 52 coding agents harnesses.html , and captures the pre-compaction packet before the window resets. See benchmarks benchmarks.html . Where does lexical search lose? Pure BM25 misses keyword-free paraphrases. On LongMemEval-S 470 cleaned questions, no LLM or embeddings , deja scores 88.9% hit@1 overall 97.4% hit@5 , while the preference slice drops to 43.3% hit@1 100% hit@20 — exact runs and failure modes are on benchmarks benchmarks.html and day zero day-zero.html . If you run a local embedding endpoint such as Ollama or LM Studio, deja embed adds an optional vector sidecar for hybrid recall; without one, search stays strictly offline. What about secrets in raw transcripts? Indexing and search stay local with no network path unless you enable embeddings. API keys, bearer tokens, private-key blocks and credential URLs are redacted at index time before anything is written to the index or pre-compaction packet. You can scan raw on-disk transcripts without building an index with deja audit --secrets , or inspect and scrub findings via deja secrets — details in privacy privacy.html and credentials in transcripts credentials-in-transcripts.html . What this does not fix Compaction is not a defect to be switched off. The window is finite, summarising is the right response, and a memory layer does not change that — it stops the summary from being the only copy. If the harness never wrote the session to disk, none of this applies, and the answer really is gone. Why agents forget between sessions forgetting.html · Where the transcripts live where-sessions-are-stored.html · Getting started getting-started.html Found this useful? Star deja-vu on GitHub https://github.com/vshulcz/deja-vu .