The agent changes files for real, and sometimes it changes the wrong ones. Not because it's broken - it simply read the task differently than you meant it. The good news: Claude Code takes the code snapshots itself, without any help from you, and you can wind a bad attempt back with a couple of keystrokes.
The worse news: those snapshots have a boundary. Everything the agent types into files happens inside a fenced-off area, and from there it can be brought back. Anything that goes around that fence lands outside it: the snapshots never saw those changes and can't restore them. Better to learn where that fence runs in advance, and not at the moment something goes missing.
Below: how rollback works, where its fence runs, how long it lasts, and what covers whatever ends up outside it.
What a checkpoint is
A checkpoint is a snapshot of the files the agent is about to edit, taken before it touches them. Not a backup of the project and not an entry in version history, but a working restore point inside the current session - that is, inside your conversation with the agent.
The one thing this section is worth reading for: a snapshot is taken automatically before every message you send. You don't create it, don't configure it, and can't forget to press anything. Send a message and the point is already there.
- Your message
- Code snapshot
- Agent edits files
- Next message
- New snapshot
Note the order: snapshot first, edits after. That's why going back to a point means "put the code back the way it was before this message". You're not picking a moment in time; you're picking one of your own messages and canceling everything that followed it.
One more clarification to make the rest easier. A checkpoint is about code. Claude Code can rewind the conversation too, but that's a separate choice in the menu: code and conversation come back together or separately, whichever you decide.
How to open the rollback menu
There are two ways in, and they do exactly the same thing:
- the
/rewindcommand in the input line. It answers to the familiar aliases/undoand/checkpointas well; - the
EscEsckeys, if the input line is empty.
Most likely there was text in the input line. In that case the first Esc Esc only wipes what you typed, and no menu appears. The text isn't lost: it goes into the input history, and the up arrow brings it back. Press Esc Esc again on the now empty line and the menu opens.
What opens is a list of your messages from this session. Not a list of files and not a timeline - messages, one row for each one you sent. You pick the message after which things went sideways.
A special case: if you ran /clear earlier in this same Claude Code session, recent versions add an extra row at the top of the list. It takes you back to the conversation that was going before the clear. Clearing, as you can see, doesn't destroy anything.
What the menu offers
Pick a point and the agent asks what exactly to do with it. There are six options:
| Menu item | What it does |
|---|---|
Restore code and conversation | bring both the code and the conversation back to the chosen point |
Restore conversation | bring back the conversation only, leave the files as they are |
Restore code | bring back the files only, leave the conversation as it is |
Summarize from here | fold the conversation from this point onward into a summary |
Summarize up to here | fold the conversation up to this point, leaving the rest untouched |
Never mind | close the menu without doing anything |
The first thing to know about this table: the menu isn't always the same. The two code items appear only when the agent actually changed files after the chosen point. If it didn't, there's nothing to restore and those rows simply aren't shown. So four items instead of six doesn't mean you're running a different program.
The two Summarize rows stand apart. They work on the length of the conversation rather than on code: they fold a stretch of it into a summary. They don't reach the files on disk at all. Why you'd want that is a separate and sizable topic; here it's enough to know that this isn't a rollback, and code doesn't come back this way.
And a small thing that saves you some frustration. Once the conversation is restored, the text of that very message returns to the input line. No need to recall what you wrote and retype it - reword it and send again.
What rollback brings back, and what it does not
Inside its own zone, rollback is dependable. It restores two things: the file edits the agent made with its editing tools, and the conversation history in this session.
Here's what stays outside the fence.
- Changes made by terminal commands. The agent can do more than edit files - it can also run commands. If a file was deleted with
rm, moved, or overwritten by a copy, the snapshot never saw it and can't bring it back. - Changes made outside the agent. Files the agent never touched in this session are left alone by rollback entirely: you edited them in the editor yourself, another program overwrote them, a second session was running alongside - all of that stays as it is, and the menu can neither restore nor undo it. But if you hand-edited a file the agent was also editing, restoring the code puts that file back to the snapshot in full - your edit included.
- Subagent edits. If the agent handed part of the work to a helper subagent, that subagent's edits usually don't make it into the snapshots, and rollback won't bring them back. You roll those back through git.
- The rare case of symlinks. Rollback skips them and says so plainly on a line of its own. If you ever run into it you'll work it out; no need to prepare in advance.
From the outside the difference is barely visible. The agent reports just as calmly when it edits a file as when it runs a command that deletes one. To you those are two similar lines on the screen; to rollback they're fundamentally different events - it'll undo the first and not the second.
So a request to run a command that deletes, moves, or overwrites something deserves a closer read than a request for an ordinary edit. That's the case where there's no safety net behind you.
The short version: rollback watches what the agent types into files, not everything that happens on your computer.
How long a rollback lasts
Snapshots don't pile up forever. Every point is listed in the menu, but file snapshots are kept only for the last hundred of them: plenty for a single conversation, yet not unlimited, and the old ones are gradually pushed out.
The points aren't tied to an open terminal window, though. They are saved with the session, so you can close the terminal, come back tomorrow, pick up the same conversation - and the rollback menu works as if nothing had happened.
It doesn't stick around indefinitely either. Sessions and their snapshots are cleared out automatically after about a month, and that period is configurable if you want it longer.
Which leads to a simple conclusion: rollback works well within a single task - minutes, hours, a single conversation with the agent. It was never meant to store the history of a project, and that isn't a shortcoming - it's a different job. What covers the longer spans comes next.
Four safety nets, each with its own job
Undo, snapshot, folder copy, and version history aren't four names for one thing. They cover different time spans and different kinds of loss.
| Safety net | Who creates it | What it saves | How long it lasts | Where it is powerless |
|---|---|---|---|---|
| Undo in the editor | you, with a keystroke | your latest edits in the open file | not long, depends on the editor | edits across several files at once, and usually anything written to disk outside the editor |
| Checkpoint | Claude Code, on its own | the code before every message you send | as long as the session, a hundred points | terminal commands, changes made outside the agent |
| Folder copy | you, by hand | the whole project as of the moment you copied it | until you delete it | shows nothing about what changed, and clutters the disk |
| Version history, git | you, with a deliberate action | project states one after another | as long as the project | whatever you never got around to recording in it |
Choose a safety net by coverage first and by time horizon second. If Claude changes project files through its file-editing tools and touches nothing outside the session, a checkpoint covers a five-minute experiment well. If the work involves terminal commands or external changes, a checkpoint alone isn't enough, however short the task is. Only after narrowing the options by coverage should you look at time: several days of work, or a milestone that matters, calls for something that doesn't depend on the conversation with the agent.
A frank word about the folder copy. As a one-off move before something scary it works: copy it, go break things, put it back if the experiment fails. As a system it falls apart. A week later you have several nearly identical folders, and nobody remembers which one is current.
The last row is the only one that both keeps states for a long time and shows exactly what changed between them. That's git, and it's a large topic of its own: a separate tool with a separate set of commands, which we won't get into here. Its place in the table is enough for now - the longest horizon, and the only protection against what rollback doesn't cover.
How this changes the way you work
It's not really about the set of buttons. Here's what rollback means in practice:
- the snapshot happens by itself, but only an experiment on project files through Claude's file-editing tools costs almost nothing. If the work needs terminal commands or changes outside the session, choose another safety net first;
- the agent doesn't roll back for you. It can say it went the wrong way, but opening the menu and choosing is on you;
- asking for a terminal command is a different class of action than asking for a file edit. Rollback covers the second and not the first. The difference shows up only in the text of the request, which is exactly why it's worth reading;
- the bigger the step, the less rollback helps. Restoring is easy enough, but working out from a single menu what exactly came back gets harder the more the agent managed to do. Small steps win here too;
- rollback and version history aren't competitors. One covers minutes and hours within a single conversation, the other days, weeks, and project milestones.
Before a genuinely risky attempt, it pays to spend a minute recording the current state with something that outlives the session. Right now what you have on hand is a folder copy - as a one-off move before a risk, it does the job just fine.
But the real tool for the job is git. It keeps states for as long as you like, shows exactly what changed between them, and doesn't clutter the disk with near-identical folders. How to use it is a separate matter: the topic is large and deserves its own conversation. The habit of stopping for a minute before a risk will serve you either way, both with git and, for now, without it.
Leave the rollback menu to what it's good at, quick experiments. As a last resort it performs noticeably worse than as an everyday tool.
The contents of the rollback menu and the retention periods depend on your Claude Code version and settings, so yours may differ from what's described here. The menu itself always shows what your version offers.