All articles

Managing Sessions in Claude Code: /rewind, /rename, and More

A Claude Code session is your working context — the conversation, the files Claude has touched, the task at hand. Left unmanaged, sessions pile up unnamed, context fills with stale history, and a bad edit sends you scrambling for git reset. A few commands turn that mess into something you steer: undo to any earlier point, name sessions so you can find them, and keep context lean. This post walks through the ones I reach for, with a practice sample for each.

/rewind — the undo button for a whole session

This is the one that changes how you work. Claude Code takes a checkpoint every time you send a prompt — automatically, retroactively, no setup. When something goes wrong, /rewind lets you jump back to any of those points.

Open it with the /rewind command, or press Esc twice when the input box is empty. (If you've typed something, double-Esc clears the box instead.) You get a menu of every prompt from the session, and for each one, a choice of what to restore:

  • Restore code and conversation — roll both the files and the chat back to that point.
  • Restore conversation — rewind the chat, keep the current files.
  • Restore code — revert Claude's file edits, keep the conversation.
  • Summarize from / up to here — compress part of the history to free up context (more on that later).

The limitation you must know: /rewind only undoes edits Claude made through its own editing tools. It does not undo:

  • Bash side effects. If Claude ran rm old.js or mv a b in a shell command, that's not tracked — rewind won't bring the file back.
  • Subagent edits and background jobs.
  • Anything outside the project — databases, deployments, API calls.

For those, git is still your safety net. Rewind covers the everyday "Claude just edited a file and I want that edit gone," which is most of the time. (Snapshots are kept for the 100 most recent checkpoints and age out after ~30 days.)

Practice sample. You ask Claude to refactor a module. It rewrites three files, and now the tests fail in a way that's hard to unpick. Instead of hand-reverting:

> /rewind
  ↑/↓ to the prompt just before the refactor
  Select "Restore code and conversation"

You're back to the green baseline — files and chat both — as if the refactor never happened. Now you can rephrase the request and try again.

/rename — give sessions names you'll recognize

By default a session gets an AI-generated title from your first prompt. That's fine until you have five sessions open and the picker is a wall of near-identical titles. /rename gives a session a short, memorable name that shows up in the status line, the session picker, and session listings.

> /rename auth-refactor

You can also name a session at launch with claude -n auth-refactor, or rename one from inside the session picker by highlighting it and pressing Ctrl+R. The name becomes a resume handle — you can jump straight back with claude --resume auth-refactor (more below).

Practice sample. You're juggling three things at once: a bug fix, a feature, and a code review. Name each session as you start it:

> /rename fix-login-race
# ... in another terminal ...
> /rename feat-csv-export
# ... in a third ...
> /rename review-pr-482

Now the picker reads like a to-do list, and claude --resume fix-login-race drops you straight back into the right one — no scrolling, no guessing.

/resume and --continue — coming back to work

Sessions persist, so you can leave and return. Two ways in:

  • claude --continue (or claude -c) reopens the most recent conversation in the current directory. No menu — just picks up where you left off.
  • claude --resume opens the session picker to choose from past sessions. Pass a name to skip the menu: claude --resume auth-refactor.
  • Inside a session, /resume opens the same picker to switch conversations without leaving Claude Code.

The picker is worth learning. Arrow keys navigate; Enter resumes; / (or just typing) filters by name or title; Ctrl+R renames; Ctrl+A widens to sessions from all projects on the machine. You can even paste a PR URL into the search to find the session that created it.

Practice sample. You closed your laptop mid-task yesterday. Today, from the project folder:

claude -c          # jump straight back into yesterday's session

Or, if you had several going and want a specific one:

claude --resume    # pick "fix-login-race" from the list

/clear vs /compact — keeping context lean

A long session fills the context window. Two commands manage that, and they're opposites:

  • /clear starts a fresh conversation in the same session — empty context, clean slate. The old conversation is saved and still resumable. Your CLAUDE.md and memory carry over; the files you'd read do not.
  • /compact summarizes the conversation in place, replacing the long history with a structured summary so you keep going in the same thread. It re-injects your CLAUDE.md, memory, and your few most-recently-edited files, so the task context survives.

Rule of thumb: /clear when you switch to unrelated work (the old debugging history is just noise now and costs tokens every message). /compact when the same task is filling up context and you want to keep going.

/compact takes an optional focus:

> /compact focus on the auth changes and the failing test

That tells the summary what to keep sharp. And the /rewindSummarize options are a scalpel version — compress just one verbose stretch (say, a long debugging detour) while leaving your original instructions and later work intact.

Practice sample. You spent an hour debugging a race condition; the context is bloated with dead-end attempts. You've fixed it and want to move to writing tests:

> /compact focus on the final fix for the login race
# context shrinks to a tight summary; you keep the same session and start on tests

If instead you were done with that bug entirely and switching to an unrelated feature, /clear would be the better call — a clean slate, old context saved for later.

A few more worth knowing

  • /branch [name] forks the current conversation into a new session, leaving the original untouched. Great for "let me try a different approach without losing this one." From the CLI: claude --continue --fork-session.
  • /export copies or saves the current conversation as readable text — handy for sharing a debugging session or archiving how something got built.
  • /context shows a live breakdown of what's eating your context window (CLAUDE.md, memory, files, history). Run it before you /compact to see what's actually taking up space.

A cheat sheet to steal

  • Made a bad edit? /rewind (or Esc Esc) → restore code or code+conversation. Remember it won't undo Bash rm/mv — that's what git is for.
  • Too many sessions? /rename each one; resume by name with claude --resume <name>.
  • Coming back? claude -c for the last session, claude --resume to pick one.
  • Switching tasks? /clear. Same task, context full? /compact (add a focus).
  • Want to try two directions? /branch.

Sessions are cheap to create and easy to lose track of. Spend two minutes learning these and Claude Code stops being a single runaway conversation and becomes a set of named, undoable, resumable workspaces you actually control.

Comments

Be the first to comment.