Skip to content

Clear, Compact, and Rewind

Context is the resource you manage in Claude Code.

Use session tools deliberately instead of letting every question, correction, and failed attempt stay in the same working memory.

Use /clear between unrelated tasks.

Terminal window
/clear

This starts a fresh context. The previous conversation is saved, and you can reopen it with /resume. It is often better than dragging a previous task’s assumptions into a new one.

Use /compact during long-running work when you want to preserve the important parts and reduce noise.

Terminal window
/compact Focus on modified files, decisions made, failing tests, and next steps.

Add compaction preferences to CLAUDE.md if you want the same information preserved every time.

Use /rewind, or press Esc twice with an empty prompt, when a session goes down the wrong path. If the prompt contains text, double Esc clears it instead.

The rewind menu offers up to five actions for the message you pick. The two code restore options only appear when that checkpoint has tracked file edits to revert:

  • Restore code and conversation
  • Restore conversation
  • Restore code
  • Summarize from here
  • Summarize up to here

The last two make compaction partial instead of all-or-nothing. “Summarize up to here” compacts everything before the chosen point and keeps the recent turns verbatim, which is useful when the early exploration is noise but the last stretch of work is exactly what you need intact.

Rewind is not a replacement for git. It restores edits made through Claude’s file editing tools, not changes made by Bash commands, and in most cases not edits made by subagents. It is still useful while exploring.

If you have corrected the same issue more than twice, clear or rewind. Start again with a sharper prompt that includes what you learned.