CloudCodeTree LogoCloudCodeTree
AI NewsTutorialsAbout
CloudCodeTree Logo
CloudCodeTree
  • AI News
  • Tutorials
  • About
← Back to AI News
Four Commands That Rescue Any Claude Code Session: /rewind, /compact, --continue, --resume

Four Commands That Rescue Any Claude Code Session: /rewind, /compact, --continue, --resume

Chris Harper

2 min read

Jul 1, 2026 · 12:05 UTC

AI
Workflow
Claude Code
Best Practices

TL;DR: /compact when context fills, /rewind when you overshoot, claude --continue when you closed the terminal — four commands cover every session-recovery scenario in Claude Code.

Every Claude Code engineer eventually hits one of four session-ending moments. Here's the fix for each.


1. Context window is filling up — /compact

Run /compact to compress the conversation into a structured summary while keeping file and tool state intact. Add an instruction to control what's preserved:

/compact keep the migration plan, the list of failing tests, and the current file state

Check /context first to see your live token breakdown. Aim to compact at 40–50% window usage — waiting until 80% means the resulting summary is already degraded.


2. Made a mistake, or ran /clear and regretted it — /rewind

Press Esc Esc or type /rewind to open the rewind menu. As of Week 26 (v2.1.185+), you can now rewind past a /clear to recover the conversation and file state from before it ran. Choose from:

  • Restore conversation only
  • Restore files only
  • Restore both
Esc Esc  →  rewind menu  →  pick a checkpoint before /clear

Note: /rewind can't undo external effects (git pushes, npm installs, API calls). It restores Claude's state, not the outside world.


3. Closed the terminal — claude --continue

Claude Code persists every session locally. Resume the most recent session exactly where you left it:

claude --continue       # resumes the most recent session
claude --resume         # shows a list of sessions to pick from

Checkpoints survive across terminal restarts, so closing a tab mid-task isn't the end.


4. Session has lost the thread — summarize and restart

When a session has accumulated too many wrong turns, /compact it with a tight instruction, then open a fresh session with the compact summary as the opening message. Cleaner than fighting a degraded context:

# In the dying session:
/compact extract: the goal, what we've tried, current file state, next step

# In a new session:
claude --new
[paste the compact summary as your first message]

Keep /usage in your toolkit — it shows what's driving your plan limits (skills, subagents, MCP calls) so you can see when to compact before things get bad.

Sources: Claude Code best practices | Week 26 what's new | Session management