"I asked Claude to do something, and it ended up breaking the code that was working just fine..."
"After I sent that last message, it suddenly made some off-base changes and I can't get it back..."
The command that solves these "typical AI problems" in one go is Claude Code's /rewind. In this article, we will cover everything from the mechanism and usage to convenient scenarios and precautions, so even first-time users won't get lost.
Introduction: What is /rewind in a nutshell?
/rewind is the "save & load feature for Claude Code."
Think of it as bringing that gaming experience of "saving before a boss fight and reloading if you lose" directly into your coding workflow.
To be more precise, /rewind is a command that allows you to roll back code (file contents) and conversation (chat history) to any point in the past during a session. It serves as the gateway to the "checkpoint feature" that has been standard since Claude Code v2.0.0.
The key point is that this rollback can be used without knowing Git. No commits, branches, or spells like git reset are required. That's why it's a safety device that is especially welcome for non-engineers who "don't really understand version control" and AI coding beginners.
Why is /rewind necessary?
There is an unavoidable "fear" in AI coding.
Misinterpreting instructions and overwriting files you didn't want it to touch
Trying to be helpful and over-engineering, making simple code complex
It was perfect halfway through, but suddenly went off the rails after one move
Many people are likely afraid of these "screw-ups," leading them to be overly cautious with their instructions or manually taking backups every time.
With /rewind, this premise is flipped on its head.
"If it goes wrong, I can just roll it back"—because you have that peace of mind, you can boldly leave things to the AI. This is the essential value of /rewind. In fact, the official documentation positions it as a "safety net" that allows you to take on ambitious, wide-ranging tasks knowing you can always return to a previous state.
Mechanism: Checkpoints are created "automatically"
The key to understanding /rewind is the concept of checkpoints (=save points).
It's saved automatically even if you do nothingHappily, creating checkpoints is completely automatic. No configuration is required at all.
Every time you send a prompt (instruction), a new checkpoint is created.
Before Claude edits a file, the state of the code at that moment is captured.
Checkpoints are retained across sessions (they remain even if you close Claude Code and restart it later).
Older ones are automatically cleaned up along with the session after about 30 days (this period can be changed in the settings).
In other words, you don't need to consciously press a "Save" button. Just by chatting with Claude, saves are steadily accumulating in the background.
Conceptual Diagramあなた:「ログイン機能を作って」 ← ここでセーブ① ↓ Claudeがファイルを編集 あなた:「デザインを整えて」 ← ここでセーブ② ↓ Claudeがファイルを編集 あなた:「テストも書いて」 ← ここでセーブ③ ↓ Claudeがファイルを編集(←ここで何か壊れた!) → /rewind で「セーブ②」や「セーブ③」の地点に戻れる
Each checkpoint is linked to and displays "the message you sent" and "the files changed at that time (+1 -0 style diff notation)," so you can intuitively understand where you should return to.
How to use: The flow from startup to restoration
① Open the menu (two methods)Method A: Type the command Type /rewind in the prompt input field and press Enter.
Method B: Press the Esc key twice (fastest) When the input field is empty, quickly press Esc twice to open the rewind menu.
② Choose the point you want to return toThe menu lists a list of prompts sent during that session in chronological order. Use the arrow keys to select the point you want to return to.
③ Choose what to restore (5 actions)This is the most important part of /rewind. After selecting a point, choose what to rewind.
① Restore code and conversation (restore both code and conversation) Both files and chat history will be completely reverted to that point in time. Use this when you want to "completely redo things from that point." If you're unsure, choose this.
② Restore conversation (restore conversation only) Reverts the chat history, but the code remains as it is. Use this when you want to keep the code but change the flow of instructions.
③ Restore code (restore code only) Reverts only the files, but the conversation remains as it is. Use this when you want to discard only the broken code while keeping the context of the conversation.
④ Summarize from here (summarize from this point forward) Compresses the conversation after the selected point into a summary (files are not changed). Use this when you want to fold up side-tracked discussions while keeping the initial context.
⑤ Summarize up to here Compresses everything before the selected point into a summary (files remain unchanged). Use this when you want to fold away the initial setup conversation while keeping the recent work in detail.
In addition, you can use Never mind to close the menu without doing anything.
④ Rewound instructions return to the input fieldThis is a subtly useful feature. When you restore a conversation or select 'Summarize from here', the prompt of the selected message is automatically returned to the input field.
In other words, if you think, 'My phrasing for that last instruction was bad,' you can edit that instruction and send it again. You can smoothly perform the 'Rewind → Rephrase' flow.
The difference between 'Restore' and 'Summarize'
This is a point where beginners often get confused, so let me break it down further.
Restore = Time Machine. Returns the state to the past. Code and conversation are rolled back to the state at the selected point. What you did is effectively 'undone'.
Summarize = Decluttering. Does not revert the state. Files remain as they are. It simply has the AI summarize and compress a portion of a conversation that has become too long, creating space in the context window (the capacity the AI can remember at once).
Summarize is similar to Claude Code's /compact, but the difference is that you can target only 'before or after the selected point' for compression rather than the entire conversation. The original messages remain in the session record, so Claude can refer to the details later if necessary.
When is it useful? 4 major use cases + concrete scenarios
The official documentation lists 4 main 'useful scenarios.' I have added concrete examples for each to make them easier for beginners to visualize.
Use Case 1: Recovering from mistakes (the most common usage)Whether a bug was introduced or a feature was broken, being able to instantly return to the point where it was working correctly is the best time to use this.
Use Case 2: Trying different approaches (experimenting boldly)You can try out "implementations you're not sure will work" without any risk. You gain the psychological ease of being able to tell the AI, "Just give it a try."
Use Case 3: Feature Iteration (Repeatedly building and reverting) Use Case 4: Saving Context Capacity (Effective for long debugging sessions)️ Important: The "3 Limitations" of /rewind
If you rely on this without knowing these, you will get burned. Beginners especially must keep these in mind.
Limitation 1: Changes made by bash commands cannot be revertedFile operations performed by Claude Code via terminal commands (bash) are not tracked by checkpoints. For example:
rm file.txt # 削除 mv old.txt new.txt # リネーム cp source.txt dest.txt # コピー sed -i ... # 一括置換
These cannot be reverted with /rewind. You can only roll back changes made directly by Claude using dedicated editing tools like Write, Edit, or NotebookEdit.
Limitation 2: Manual edits and changes from other sessions are generally not trackedChanges you made by hand in the editor or changes from another Claude Code session are generally not captured (unless you happened to be touching the same file).
Limitation 3: It is not a replacement for GitThis is the most important point. /rewind is strictly a "quick rollback within a session (local Undo)." It is not a feature for permanent version history or team sharing.
/rewind = A "powerful Ctrl+Z" for the moment (temporary, session-based)
Git = "Official record of history" (permanent, team-shared, for deployment)
The official documentation also states: "Checkpoints complement version control, but do not replace it." For important projects, make it a habit to always create a Git commit at milestones ("feature complete," "before major refactoring," etc.) and use it alongside /rewind.
Smart ways to use it alongside Git
Characteristics of /rewind (checkpoint)
Purpose: Quick rewinding during a session
Creation: Created automatically for every prompt
Lifespan: Automatically deleted after about 30 days
Unit: Per conversation turn
Git knowledge: Not required
Characteristics of Git
Purpose: Permanent history and team sharing
Creation: Created by making commits manually
Lifespan: Can be kept indefinitely
Unit: Per meaningful milestone
Git knowledge: Required
Recommended usage: Use /rewind to iterate quickly during trial and error, and only commit with Git at milestones where you want to "lock in" progress. The two do not conflict and serve as a parallel safety net.
A deeper dive: Settings and forks
Retention period settings (cleanupPeriodDays)Checkpoints are kept for about 30 days by default, after which they are automatically deleted per session. This period can be changed in the configuration file using cleanupPeriodDays.
If you want to "branch" instead of "rewind" → fork/rewind is a feature for rewinding state within the same session. If you want to "keep the original session intact while trying a different path", use fork (branch) instead of rewinding.
claude --continue --fork-session
It's like "preserving the original timeline while experimenting in a parallel world."
Quick Start for Beginners
Finally, here is a summary of the key points you need to remember to start using it today.
It's saved even if you do nothing → A checkpoint is automatically created every time you send a prompt
Open it with /rewind or by pressing Esc twice in an empty field
Select the point you want to return to
If you're unsure, choose 'Restore code and conversation' (reverts everything entirely)
The reverted instruction will return to the input field, so rephrase it and resend
Bash commands and manual edits cannot be reverted. Use Git to commit at important milestones
Once you make /rewind your ally, your instructions to the AI will become much bolder. 'If I fail, I can just go back'—this sense of security is the greatest weapon for making AI coding fun and fast. Please try it out starting from today's session.
Reference (Official Information)Claude Code Official Documentation 'Checkpointing': https://code.claude.com/docs/en/checkpointing
Claude Agent SDK 'File checkpointing': https://platform.claude.com/docs/en/agent-sdk/file-checkpointing
* Claude Code is a product that updates rapidly. Always check the official documentation for the latest behavior and options.