Guide
Claude Code /compact vs /clear: keep work across sessions
Long Claude Code sessions get slower and vaguer as the context fills. You have four ways out: compact, clear, resume, or start fresh with a handover. Here is when to use each, and how to carry the important parts across.
Commands checked against Claude Code’s command reference on October 21, 2026.
Which one to use
| Situation | Use | What you keep |
|---|---|---|
| Same task, context getting full | /compact with focus | A summary, plus CLAUDE.md and memory |
| Task done, starting something unrelated | /clear | CLAUDE.md and memory; old chat in /resume |
| Picking up where you stopped | claude --continue or /resume | The whole earlier conversation |
| Session went in circles, or a new day | New session plus a handoff | What you wrote down, checked |
/context shows how full the context is before you decide.
/compact
/compact replaces the conversation with a summary and carries on. Claude Code also does this on its own when the window fills. Pass instructions to steer it:
/compact keep the schema decisions, the two failing test names, and why we dropped the cache layer What gets lost is detail: exact error text, the reason an approach was rejected, the file you were about to edit. If any of that matters, say so in the instructions, or write it down first.
/clear
/clear (also /new) starts a new conversation with empty context. Your CLAUDE.md files and auto memory load again, because they load at the start of every conversation. The previous conversation isn’t deleted: /clear name labels it so you can find it later in /resume.
Use it between tasks. Context from a finished task is noise for the next one, and it costs tokens on every turn.
Resume and continue
claude --continue reopens the most recent conversation in the current folder; claude --resume or /resume lets you pick one by name or from a list. You get the whole conversation back, including whatever made it slow, so resume a recent session and hand off from an old one.
A handoff for a fresh start
When a session went in circles, or it’s the next morning, a new session with a short written handoff beats both compacting and resuming. Ask for it before you leave:
Write a handoff for a new session, under 250 words:
- Goal and definition of done
- Decided (with the reason)
- Ruled out (and why)
- Current state: what works, what's failing, exact test names
- Next step, and the files involved
Facts from this session only. Check it, then start the new session with it. Keep it out of CLAUDE.md: that file is for rules that stay true, and today’s state won’t (see what goes in CLAUDE.md).
Handing off to another agent
The same handoff works for Codex or Cursor. Codex has the same moves: it compacts long conversations, and codex resume reopens an earlier one. The hard part is where the handoff lives so the other agent can find it. A file in the repo works for one person; see share context between AI agents for the options.
Making the handoff automatic
Handoffs only work if you remember to write them. The alternative is an outside memory the agent reports to as it works, and the next session reads before asking you anything.
That’s how Cachejay works with Claude Code and Codex. When an agent finishes a piece of work, it reports what’s done, decided and next; Cachejay files it under the project, rewrites the project’s status, and ticks the to-dos it finished. A new session, in either agent, can ask for the project brief and what you were last doing. Cachejay also reads both agents’ session logs on your Mac, so the conversation itself is searchable later. It doesn’t change how /compact works; it makes what’s lost there recoverable. Setup is on the Claude and Codex pages, and habits for AI agents has more on the routine.