DEV Community

Boris Stojanov
Boris Stojanov

Posted on Originally published at solidvibes.dev AI-assisted

How to undo a change in Claude Code: /rewind, checkpoints and Git

I build with Claude Code every day and wrote this for people who don't code. First posted on solidvibes.dev.

You asked Claude Code for one change. It made three, and now the page looks wrong. Good news: you can go back. This post shows how, what the undo can and can't reach, and the one habit that makes every mistake easy to fix.

First: stop it

If Claude is still working and heading the wrong way, press Esc. It stops at once, and nothing it already did is lost or broken. Then you can undo calmly.

The quick undo: /rewind

Claude Code saves a checkpoint of your files before each message you send (checkpointing docs). Going back to one takes three steps:

  1. Type /rewind and press Enter. Or press Esc twice when the prompt is empty. /undo does the same.
  2. A list of your earlier messages appears. Pick the one sent just before things went wrong.
  3. Choose what to restore.

Tip: If text is in the prompt, the first double Esc only clears it. Press Up later to get your text back.

Which restore do I pick?

The menu gives you a few choices (checkpointing docs):

Choice What happens Use it when
Restore code and conversation Files and chat both go back You want a clean second try
Restore code Files go back, the chat stays Claude should remember what went wrong
Restore conversation Only the chat goes back The files are fine, the talk went off track
Never mind Nothing changes You picked the wrong line

Most of the time, Restore code and conversation is the one you want. Your old message comes back into the prompt, so you can reword it and send it again.

Prompt: Go back to how it was. Only change the button colour on the home page, nothing else.

If you see no code choices at all, Claude changed no files after that point. Only the chat can go back.

What /rewind can't undo

Checkpoints are a quick safety net, not a full history. The docs name what they miss (limitations):

  • Files changed only by a command. Claude sometimes runs commands instead of editing files directly, for example to install something or move files. If a command was the only thing that touched a file, /rewind leaves it as it is.
  • Your own changes. Edits you made yourself, outside Claude Code, are not tracked. Nor are edits from another Claude Code window.
  • Some helper work. Claude can hand parts of a job to helpers (subagents). Their edits to new files are usually not restored.
  • Old sessions. Checkpoints are deleted about 30 days after a session last saved one.

Warning: Checkpoints never undo things that happened outside your folder: a deployed website, a sent email, a changed database. Undo those where they happened.

The safer undo: Git

Git is a tool that saves named snapshots of your whole project. Each snapshot is called a commit. The checkpointing docs say it plainly: checkpoints are for quick recovery inside one session, and for lasting history you keep using version control, such as Git (checkpointing docs).

You don't need to learn Git commands. Ask Claude:

Prompt: Set up Git for this project if it isn't already, and save my work now with a short message.

Then, each time something works, ask it to save again. The quickstart shows the same kind of request: "commit my changes with a descriptive message" (quickstart).

If something breaks later, even days later, in a new session, or through a command /rewind couldn't see, ask Claude to go back to the last snapshot that worked:

Prompt: The site was working at my last save. Show me what changed since then, and undo it.

Git can also undo one saved change and keep everything after it (git revert). Claude knows how; you just say which change.

Which one should I use?

Situation Use
Claude just did something wrong, a few messages ago /rewind
You want to try the same request worded differently /rewind, Restore code and conversation
The problem is from yesterday or an older session Git
A command Claude ran broke things Git
You want to keep the new work but drop one old change Git

A simple habit

  • Before a big request, ask Claude to save your work with Git.
  • After each step that works, save again.
  • When something goes wrong right away, use /rewind.
  • When /rewind can't reach it, go back to your last save.

With this habit, a bad change costs you a minute, not an afternoon. New to Claude Code? Start with Claude Code for non-developers. It covers installing, your first session and the basics of stopping and undoing.

Top comments (0)