# Claude Code /compact vs /clear and what survives compaction

Canonical: https://cwyn.com/pages/claude-code-guide-compact-vs-clear.html
Last updated: 2026-11-26T23:08:43-05:00

Claude Code context guide

Use `/compact` to continue the same conversation from a summary when context runs low. Use `/clear` to start an empty conversation at no cost when you switch tasks. Both commands reload project memory from the root `CLAUDE.md`. To go back to an earlier turn, use `/rewind`.

Last updated November 26, 2026 · Published November 22, 2026

By CWYN · Published Nov 22, 2026 · Checked against docs, not run · [Command reference](https://code.claude.com/docs/en/commands), [costs](https://code.claude.com/docs/en/costs), [project memory](https://code.claude.com/docs/en/memory) and [prompt caching](https://code.claude.com/docs/en/prompt-caching) (as of Nov 26, 2026)

## 1. Choose the command for your next step

| Your next step | Command | Where you pick up |
| --- | --- | --- |
| Keep debugging the same failure | `/compact [instructions]` | Continue from a summary. The optional instructions tell Claude what to keep, such as the failing test and the fixes you ruled out. |
| Start an unrelated task | `/clear [name]` | Begin a new conversation. The old one is available through `/resume` . The aliases for `/clear` are `/reset` and `/new` . |
| Try a different approach | `/rewind` | Choose the turn before the detour. Later messages drop out of context, leaving the earlier cached part of the conversation. See [which file edits a checkpoint can restore](https://cwyn.com/pages/claude-code-guide-rewind-checkpoints.html) . |

For shortcuts to inspect context or reopen a conversation, see the [commands for managing a session](https://cwyn.com/pages/claude-code-guide-commands-cheat-sheet.html).

If you need to keep both tasks open and edit files in parallel, [give each Claude Code session its own worktree](https://cwyn.com/pages/claude-code-guide-worktrees.html).

[Command arguments and aliases](https://code.claude.com/docs/en/commands) and [rewinding to a cached turn](https://code.claude.com/docs/en/prompt-caching) (as of Nov 22, 2026).

## 2. Check what is filling the context window

Run `/context` at the Claude Code prompt. The colored grid shows what is using space and suggests ways to free it. If the conversation is already over the context limit, the readout shows how far over you are and which command frees space. [Command reference for /context](https://code.claude.com/docs/en/commands) and [context windows by model](https://code.claude.com/docs/en/context-window) (as of Nov 22, 2026).

If CPU or memory use is high during a long conversation, run `/compact` regularly to reduce the context size. [Troubleshooting resource use](https://code.claude.com/docs/en/troubleshooting) (as of Nov 22, 2026).

## 3. What survives compaction?

| Part of the session | After compaction |
| --- | --- |
| System prompt and output style | Both still apply. |
| Project instructions | Claude Code rereads the project-root `CLAUDE.md` and unscoped rules from disk. Nested `CLAUDE.md` files reload when Claude reads a file in their directory. Rules with `paths:` reload when a file matches. |
| Auto memory and plan | Claude Code restores auto memory and the plan from plan mode. |
| Recent files | Claude Code rereads up to five recently modified files that it read or edited. A file over 5,000 tokens comes back as a path reference. |
| Skills | Claude Code rebuilds skill descriptions in v2.1.304 or later. It restores the bodies of invoked skills, up to 5,000 tokens per skill and 25,000 tokens total. |
| Background work | Background commands and subagents keep running. |
| Hooks | Context supplied by hooks goes into the summary. `SessionStart` hooks that match the `compact` source run again. |

[Claude Code’s table of what survives compaction](https://code.claude.com/docs/en/context-window) (as of Nov 22, 2026).

## 4. When does compacting a conversation cost more?

Compaction sends a separate request to read the conversation and write the summary. During an active session, that request can read the earlier messages from a warm prompt cache for a fraction of the cost of processing them again. Once the summary replaces those messages, the conversation cache is invalidated. [Compaction costs](https://code.claude.com/docs/en/costs) and [how the summary uses the cache](https://code.claude.com/docs/en/prompt-caching) (as of Nov 22, 2026).

If you resume a long session after the cache has expired, the summary request has to process the history uncached. That is when `/compact` costs the most. For a fresh start, `/clear` costs nothing and resets the session totals shown by `/usage`. [Cache lifetime and when to compact](https://code.claude.com/docs/en/prompt-caching) and [session usage totals](https://code.claude.com/docs/en/costs) (as of Nov 22, 2026).

## 5. How to stop automatic compaction while idle

In v2.1.290 or later, set `idleCompaction` to `false` to stop Claude Code from compacting a long conversation while it is idle. This setting applies to idle compaction with the one-hour cache lifetime. During an active task, you can run `/compact` at a natural break while the cache is warm and tell Claude which decisions to keep. [Idle compaction setting](https://code.claude.com/docs/en/prompt-caching) (as of Nov 22, 2026).

## 6. Fix compaction messages

### “Not enough messages to compact.”

There are too few turns to summarize. A single large paste can fill the window even in a short conversation. If the paste is all you need, save the relevant excerpt, run `/clear` and bring just that excerpt into the new conversation. [Compaction troubleshooting](https://code.claude.com/docs/en/troubleshooting) and [starting a new conversation](https://code.claude.com/docs/en/commands) (as of Nov 22, 2026).

### “Autocompact is thrashing”

A file or tool output has repeatedly filled the window again after compaction. Read the file in smaller chunks. To drop the large output while keeping the work in progress, try `/compact keep only the plan and the diff`. You can also [move the large-file work to a subagent](https://cwyn.com/pages/claude-code-guide-skills-vs-subagents-hooks.html), or use `/clear` if the earlier conversation is no longer needed. [Fixing repeated auto-compaction](https://code.claude.com/docs/en/troubleshooting) (as of Nov 22, 2026).

## 7. Keep project instructions across compaction

If you told Claude which test command to run and where to run it, write both in the project-root `CLAUDE.md`. Claude Code rereads that file after compaction. A rule given only in conversation can drop out of the summary. [How Claude Code reloads project instructions](https://code.claude.com/docs/en/memory) (as of Nov 22, 2026).

## 8. Claude Code compaction FAQ

### Does `/clear` delete CLAUDE.md?

No. It clears the conversation history from the active context. Your project-root `CLAUDE.md` stays on disk and its instructions load in the new conversation. [The /clear command](https://code.claude.com/docs/en/commands) and [project memory](https://code.claude.com/docs/en/memory) (as of Nov 22, 2026).

### Can I get a cleared conversation back?

Yes. Run `/resume` and choose the previous conversation. See [how to resume a local Claude Code session](https://cwyn.com/pages/claude-code-guide-resume-local-session.html) for the steps. [Resuming after /clear](https://code.claude.com/docs/en/commands) (as of Nov 22, 2026).

### Why did Claude forget an instruction after compacting?

Check where the instruction lives. A chat-only rule may have been left out of the summary. For a nested `CLAUDE.md`, ask Claude to read a file in that directory. For a path-scoped rule, have it read a matching file. Put instructions that apply throughout the project in the root `CLAUDE.md`. [Diagnosing missing instructions](https://code.claude.com/docs/en/memory) (as of Nov 22, 2026).

### Does compacting count toward my usage?

Yes. The summary is a request that reads the conversation. A warm cache lowers its cost. If you use an API key, see [how API usage is billed](https://cwyn.com/pages/claude-code-guide-subscription-vs-api.html). On a subscription, use the [Claude Code usage limits guide](https://cwyn.com/pages/claude-code-guide-usage-limits.html) to check your shared allowance. [Claude Code costs](https://code.claude.com/docs/en/costs) and [cached summary requests](https://code.claude.com/docs/en/prompt-caching) (as of Nov 22, 2026).

## Next steps

- [All 34 Claude Code guides](https://cwyn.com/guides/claude-code/)
- [Claude Code setup walkthrough](https://cwyn.com/setup/claude-code/)
- [Free AI instruction builder](https://cwyn.com/build/ai-instructions/)
- [Free AI cost calculator](https://cwyn.com/score/ai-cost-calculator/?tool=claude)
- [Claude Code Complete Setup Pack ($12.95)](https://cwyn.com/pages/pack-claude-code-complete-setup-pack.html)

### Write instructions for your project

[Open the free AI instruction builder](https://cwyn.com/build/ai-instructions/)

## Email me the CLAUDE.md + settings starter

Get the editable CLAUDE.md template and a project setting you can merge into .claude/settings.json.

Email address

Email me this file. Also send up to 4 short follow-up emails with tips and one related CWYN product. Unsubscribe any time. [Privacy policy](https://cwyn.com/pages/privacy.html)

### Set up your Claude Code project

Put your test command in the starter `CLAUDE.md` from the [Claude Code Complete Setup Pack ($12.95)](https://cwyn.com/pages/pack-claude-code-complete-setup-pack.html) and save it at the project root so Claude can reload it after compaction.

Claude Code Complete Setup Pack $12.95

Set up project instructions, permission rules, hooks, a reviewer skill and subagent, and MCP connections for Claude Code.
