Prompt caching is about what context costs. The question you’ll face more often is what to do with that context once a session gets long, or starts going sideways.
A session is one conversation with the agent, and its context is everything the model can see in it. Both get heavier with every turn (one response to a message you send, however many files it reads or commands it runs). Here are your options.
Four moves
You’ve basically got four, and each is a slash command (a command you type that starts with /) except the first:
- Continue: Do nothing. The harness summarizes the conversation for you when it needs to.
/compact: Summarize now, at a moment you choose./clear: Start over with an empty conversation./rewind: Truncate back to an earlier turn and, optionally, restore the files to match. That restore only covers edits the agent made with its file tools. Recovering a Failing Session covers what it misses.
The short version: undo is for wrong; condense is for long.
If something was wrong, you want to undo it. If something is merely long, you want to shrink it without losing the thread. Mixing those up is how people end up compacting a mistake into a summary where it looks like a decision.
| Situation | Reach for |
|---|---|
| Work is continuous, going well, and context is filling up | Continue |
| You’ve hit a natural phase boundary and the work continues | /compact, deliberately |
| The next task is unrelated to this one | /clear |
| The original attempt and two corrections have failed, and you’re patching patches | /clear, after you salvage what you learned |
| One specific edit was wrong | /rewind |
| You’re in the middle of verification | None of them. Finish the check first. |
That last row matters more than it looks. After a compaction, “the tests passed” is a sentence in a summary. It’s no longer an observation. If you were about to trust a result, check it before you shrink the evidence away.
For the /clear row in particular, the next lesson, Recovering a Failing Session, covers how to salvage what you learned first.
Tasting notes
A few things worth knowing about how these behave:
- Compaction is cheap while the cache is warm: The summarization request is a separate request that carries your whole conversation, so it reads your main conversation’s prompt cache. That cache lasts an hour of inactivity on a Claude subscription (within your plan’s usage) and five minutes with an API key. Come back after it has expired and compact, and you pay to reprocess the entire history. (The five-minute rule for compaction in Prompt Caching and Cost is about the cache entries the summarization request itself writes. It doesn’t shorten the cache it reads.)
/rewindis the cheapest move of the bunch: It truncates back to a prefix that’s already cached, as long as that cache hasn’t expired.- What reloads after
/clearor/compact: Your project-rootCLAUDE.md(the instruction file the harness loads at the start of a session;AGENTS.mdin Codex) is re-read from disk. NestedCLAUDE.mdfiles in subdirectories, and rules scoped to certain paths, don’t come back until the agent reads a matching file again. Claude Code’s documentation names only the project-root file as re-read, so put anything critical there rather than assuming your other instruction files return. - Editing
CLAUDE.mdmid-session does nothing yet: The change takes effect at the next/clear,/compact, or restart. - Summaries compound: Compact three times, and you’re working from a summary of a summary of a summary.
- Rules can fall out of the summary: In one benchmark, an agent violated a constraint 0% of the time while the constraint survived compaction, and 38% of the time once it got summarized away.
That last one is the practical takeaway. If a rule has to survive, it belongs in a file that reloads or, better yet, in a permission rule (a setting that allows or denies specific tool calls) that doesn’t depend on the model remembering anything. User and Project Instructions covers where rules live, and The Enforcement Ladder covers which ones need more than a sentence.
The cheapest long session is the one where nothing important lives only in the conversation.