Get back what Claude Code's compaction dropped
When a Claude Code session compacts, the summary keeps the shape of the work and drops the details: the port staging listens on, who owns the deploy key, which ticket a task is blocked on. The full conversation is still on disk as a JSONL transcript, but it’s a large raw file with tool output and subagents mixed in, and agents have no targeted way to search it.
backread is a Claude Code plugin that gives them one. After a compaction, the agent can search earlier turns by keyword and pull back the exact lines it needs.
/plugin marketplace add afterimaginary/backread
/plugin install backread@backread
What it adds
The plugin has three parts:
- The
backreadcommand.backread search <words>returns up to 3 excerpts (500 characters max), each with a handle, andbackread get <handle>prints a record, up to 4,000 characters at a time. It searches everything before the last compaction, including tool output and subagents. - A hook that runs after each compaction and adds one line to the agent’s context, naming the command and the session’s transcript. The line only describes the tool.
- A short skill that tells the agent when a search is worth it.
- Long sessionClaude Code works until the context fills up.
- CompactionThe conversation is replaced by a summary. The transcript stays on disk.
- Summary + hook lineThe hook adds one line naming the search command and this session's transcript.
backread searchWhen the summary doesn't have something, the agent searches by keyword.- ExcerptsUp to 3 short excerpts from before the compaction, each with a handle.
- AnswerThe agent answers from the original lines, and can say where they came from.
This is from a real session where the user asked Claude Code to drop some notes when compacting, then asked for them afterwards (trimmed):
❯ Before I set up the deploy script: which port does staging listen on, and who owns the deploy key?
⏺ Bash(backread search staging port deploy key owner --transcript ~/.claude/projects/-work-scratch/<session>.jsonl)
⎿ …
[L3] user message, 2026-11-27 08:06 UTC
I'm starting a small static site here. A few things to keep in mind, no need to write them down
anywhere: the staging server listens on port 8437, the deploy key belongs to Ines Okafor, …
⏺ Staging listens on port 8437, and the deploy key belongs to Ines Okafor. I didn't have either in my
summary, because you asked me to drop those notes when compacting. I found them by searching the
earlier part of the session.
That scenario ran three times. The agent searched and answered correctly in two. In the third it said it could search but asked first, since the user had told it to drop those details.
Testing it before building it
I tested the idea before writing the plugin. The public practice suite of CompactBench has 48 long synthetic working conversations, each compacted five times, with exact-answer questions about what was said earlier. One compactor wrote every summary. A reader model answered each question on its own, seeing only what its setup allowed: nothing, a 1,024-token summary, a 4,096-token summary, the small summary plus search, the small summary plus search with a nudge saying the summary may be out of date, or the whole conversation.
The search was capped tight: at most 3 searches per question, each returning 3 excerpts of up to 500 characters. That’s about 1,200 tokens of the original at most, less than the 3,072 extra tokens the bigger summary gets.
Search helped on every reader I tried. Haiku 5.5, Sonnet 5.5 and Opus 5.5 all answered the same 384 questions after the fifth compaction. The summary alone scored about the same on each: 0.42 on Haiku and 0.43 on Opus. With search they spread out, to 0.72 on Haiku and 0.85 on Opus, and the strongest model gained the most.
The numbers
| Reader sees | Haiku 5.5 | Sonnet 5.5 | Opus 5.5 |
|---|---|---|---|
| summary | 0.42 | 0.42 | 0.43 |
| 4× summary | 0.56 | 0.62 | 0.62 |
| summary + search | 0.72 | 0.81 | 0.85 |
| search + nudge | 0.77 | 0.80 | 0.86 |
A better reader can’t recover what the summary lost without looking. What it does is search more often (Opus on 85% of questions, Haiku on 60%) and make better use of what comes back. Search isn’t cheaper on Opus, though. There it used more tokens per question than the bigger summary and cost about the same per correct answer ($49 against $50 per 1,000 correct answers), while scoring 0.23 higher.
The main run
The main run used Haiku 5.5 with every setup, after the first and the fifth compaction, and asked 1,802 questions per setup.
The numbers
| Reader sees | Score | 95% interval | Tokens per question |
|---|---|---|---|
| nothing | 0.00 | 0.00 to 0.00 | 597 |
| summary | 0.53 | 0.50 to 0.55 | 2,381 |
| 4× summary | 0.72 | 0.70 to 0.75 | 6,980 |
| summary + search | 0.80 | 0.78 to 0.82 | 5,588 |
| search + nudge | 0.83 | 0.81 to 0.85 | 9,344 |
| whole conversation | 0.95 | 0.94 to 0.96 | 75,846 |
The small summary plus search scored 0.80. The summary alone scored 0.53, and a summary four times the size scored 0.72. Search also used fewer tokens per question than the bigger summary and cost less per correct answer: $0.91 per 1,000 correct answers against $1.08.
The gap grows with each compaction. Each summary is written from the one before, so losses pile up, while the search always reads the original turns. After the first compaction, search and the bigger summary both scored 0.89. After the fifth, search scored 0.72 and the bigger summary 0.56.
Where it doesn’t help
The agent searches when the summary is missing something. It searches much less when the summary is confidently wrong.
The numbers
| When | searched | answered right |
|---|---|---|
| summary left it out (706 questions) | 91.6% | 63.5% |
| summary gave a wrong answer (126 questions) | 39.7% | 15.9% |
When the summary had left the answer out, the reader searched on 91.6% of those questions and got 63.5% right. When the summary gave a wrong answer, it searched on only 39.7% and got 15.9% right. A summary that states an outdated value gives no hint that anything needs checking, and when the agent did search, a short excerpt could surface the old value as easily as its replacement.
The obvious fix is to tell the agent the summary may be out of date. That was one of the test’s hypotheses, and it failed. With the nudge, the agent searched on every question and used about two-thirds more tokens (9,344 per question against 5,588), but still gave stale answers 12.5% of the time, against 11.4% without it, a difference within noise. That’s why the hook line only describes the tool.
How it was run
The four hypotheses, prompts, seeds and pass conditions were written into PLAN.md and tagged plan-frozen before the first paid call, and CI fails if that part of the file changes. Three of the four passed. Answers are graded by CompactBench’s own scorer, with no model judging another model. Every trace is committed, so make report rebuilds every number in the report from the saved runs without an API key. The whole project, including the Sonnet and Opus runs, cost $94.16.
Limits
- The conversations are synthetic and the questions are direct. A real agent in the middle of a task has to notice on its own that it needs something the summary lost, which is harder than being asked.
- The summaries are small, 1,024 and 4,096 tokens from one compactor, and nearly all were cut to fit their budget. A better summary might narrow the gap.
- The test didn’t compare against reading the raw transcript. Claude Code’s summary already points to the transcript file near its end, so an agent can read it without the plugin. How often it does that, and what it costs next to
backread, is the next experiment.
The plugin, the experiment and every trace are in the backread repo. REPORT.md has the full write-up, with every interval, results by question family and five example traces, failures included.