Claude just rewrote a file in a way I would not have asked for. Before I reach for git checkout, there is a quicker way out.
Claude Code snapshots your files before every prompt that starts a turn. Type /rewind (the alias is /undo) or press Esc twice on an empty prompt, and a menu lists your earlier prompts.
/rewind
Pick a prompt and choose what to roll back: code and conversation, only the conversation, or only the code. There is also Summarize from here, which squeezes a long debugging stretch into a short summary and frees context. After a restore, your original prompt lands back in the input box, so you can edit it and send it again.
Example: you asked for a small refactor and Claude touched six files. Rewind to that prompt, restore the code, rephrase the request more tightly, and go again.
The caveat matters. Rewind only tracks edits made with Claude’s own file tools. If a file was changed only by a shell command, or by a subagent, it stays as it is. The docs say it plainly: this is session-level recovery and does not replace git. I would still commit before a big task.
Further reading: Checkpointing – Claude Code docs, Commands – Claude Code docs, On this site: ask Claude Code a /btw question and keep your context clean, On this site: let a PostToolUse hook run Prettier after every Claude edit