Claude Code compaction: keep the details that matter
Compaction lets a conversation continue with less context. Treat it as a point to verify the active task’s exact requirements, especially when the conversation contains corrections or one-time findings.
By OnlyBots · Updated October 17, 2026
What /compact changes
Run /compact inside Claude Code to summarize the conversation. A summary is selective; the risk for a coding task is losing an exact condition rather than forgetting its broad goal. Project-root CLAUDE.md is reloaded after compaction. See Anthropic’s memory documentation for instruction-loading behavior.
For example, “fix retry handling” is insufficient if the important finding was “retry only 429 and 503, and never replay a request after the payment provider accepted it.” Keep the precise constraint and the evidence behind it. Do not rely on a reassuring summary alone.
Before compaction: checkpoint the active task
- Write down the exact behavior contract, including user corrections that replaced earlier assumptions.
- Record changed files and the commands you actually ran, distinguishing passing checks from planned checks.
- Record the unresolved question and one next step. Link to a file or test where possible.
- Remove stale instructions from the checkpoint so the next turn does not revive a rejected approach.
Goal and current status:
Exact requirements and corrected decisions:
Files changed and why:
Commands run and observed results:
Unresolved questions:
Next action and how to verify it:Use a short working note for changing task state and your repository instructions for stable conventions. When the source of a finding is still available, reference it so the next session can verify it.
After compaction: check the contract
Ask the agent to restate the critical conditions before it edits code. Compare those conditions against the checkpoint, then run the relevant test. If the answer is incomplete, recover the source or resume the prior work rather than letting the agent fill gaps by guessing.
OnlyBots’ Claude Code adapter saves state around PreCompact and PostCompact and supplies selected working memory on the next prompt. It does not preserve an unlimited verbatim conversation. You can inspect the saved scopes with onlybotsctl memory hot --scope all --json. The adapter guide explains setup.
What our compaction test showed
Our pilot used two synthetic regression tasks, two manual compactions and large irrelevant logs. OnlyBots passed all four tested compaction cases after hook verification. Native compaction passed three of four when searching transcript files outside the workspace was disabled. In a diagnostic follow-up allowing transcript recovery, the failed Claude case passed.
This is a small retained-context test. It does not establish that OnlyBots beats the complete native workflow, measure default automatic compaction, or identify an ideal compaction threshold. See the full pilot and its restrictions. OnlyBots does not currently choose and trigger an optimal compaction point dynamically.
If your real goal is to leave the conversation behind, use the fresh-session handoff workflow.