Claude Code Context Window: What to Save Before Compaction
When a conversation in Claude Code approaches the limit of the context window, Claude Code compacts it: it replaces the history with a summary. Your requests and important code snippets stay in it, but detailed agreements from early in the session can get lost. The agent keeps working, but no longer remembers what you decided an hour ago.
Decisions the agent can't go without are worth writing down before compaction, somewhere Claude Code will re-read on its own. Below: what exactly survives compaction, an example of a long session and the short note worth keeping in the task. In Tascue that note becomes part of the task. The agent sees it after compaction, in a new session, and so does another agent if it picks up the task.
Example: a long session
The task is to move avatar uploads to S3. Over two hours, the session went like this:
- The agent suggested storing four image sizes. You agreed on just the original and a 256 px thumbnail.
- You clarified: old avatars aren't migrated, only new uploads.
- You picked the file key:
avatars/{user_id}/{uuid}.webp. - You reminded it that the User model is off limits; migrations in the project are done by hand.
- The upload test passed, and a 2 MB PNG was checked in the browser.
- What's left is handling the S3 timeout. That's when Claude Code compacted the context.
After compaction, the summary said "uploading avatars to S3, 256 px thumbnail". Item 2 was lost. As its next step, the agent suggested a script to migrate the old avatars.
What survives compaction
| Stays or is re-read | Turns into a summary |
|---|---|
| The project-root CLAUDE.md, re-read from disk | The whole conversation, including the first prompt with the task |
| Auto memory (MEMORY.md) | Decisions and clarifications made along the way |
| The plan from plan mode, re-read from disk | CLAUDE.md files in subfolders and rules with paths:, which load again only when needed |
| Up to five recently read or edited files | Command and check results |
The key point in the right column: the task text the session started with gets compacted along with everything else.
If compaction hasn't happened yet, you can run it by hand and say what to keep:
/compact keep the decisions: only the original and a 256 px thumbnail, old avatars aren't migrated, the User model is off limits
But you have to remember to do it in time. It's more reliable when decisions don't live in the conversation.
The note in the task
Move avatar uploads to S3.
Decisions:
- store the original and a 256 px thumbnail, no other sizes;
- old avatars aren't migrated, only new uploads;
- file key: avatars/{user_id}/{uuid}.webp.
Constraints: don't touch the User model, don't create migrations.
Checked: the upload test passes; a 2 MB PNG uploaded in the browser.
Left: handle the S3 timeout.
Five blocks, one to three lines each. The note grows as the work goes on: a decision is made, one line goes into Decisions; a check passes, one line goes into Checked.
To make the agent come back to this note after compaction, one line in CLAUDE.md is enough, since CLAUDE.md is re-read from disk after compaction:
If the context was compacted, re-read the current Tascue task over MCP and follow its Decisions section.
Over MCP the agent can also add decisions to the task itself as it works. Then the note is kept up even if you forget about it.
Where a decision survives compaction
| Where it's written | After compaction | In a new session | For another agent |
|---|---|---|---|
| Only in the conversation | As a summary | No | No |
| CLAUDE.md | Yes | Yes | If it's AGENTS.md |
| The task in Tascue | Yes, the agent re-reads it | Yes | Yes |
CLAUDE.md fits rules for the whole project, not decisions for one task: "old avatars aren't migrated" turns into a stale line in a week and gets in the way. Task decisions live in the task. In Tascue it stays in In progress with an up-to-date note, and you can continue it in any session and with any agent without retelling what you agreed on.