The /rewind command in Claude Code lets you roll back both code and conversation to an earlier point—better than correcting mistakes mid-session.
When You Need to Undo More Than Just Code #
You’ve been working in Claude Code for 20 minutes. Claude has edited five files, added a new module, and restructured a function — but you can see it’s gone in the wrong direction. The logic is off. You ask it to fix the issue, and it layers another correction on top of the bad foundation. Now you’re further from working code than when you started.
This is a real problem with agentic coding sessions. Correcting mistakes mid-conversation doesn’t always work, because the model carries the context of those mistakes forward. It “knows” what it did and often keeps building on it, even after you point out the error.
The /rewind
command in Claude Code solves this differently. Instead of correcting the path, it lets you abandon it entirely — rolling back both the conversation history and the actual file changes to a specific earlier checkpoint.
This guide walks through exactly how /rewind
works, when to use it, and how to build habits that make rollbacks faster and more reliable.
What the /rewind Command Actually Does #
Most developers assume /rewind
is like an undo button for the chat window. It’s more than that.
When you use /rewind
in Claude Code, it does two things simultaneously:
Rolls back the conversation history to the selected checkpoint, removing everything that happened after it — including Claude’s reasoning, your instructions, and its responses.Reverts file changes that Claude made during the rolled-back portion of the session.
Remy doesn't write the code. It manages the agents who do. #
Remy runs the project. The specialists do the work. You work with the PM, not the implementers.
The file revert is what makes this different from just clearing context. Claude Code tracks the edits it applies during a session, so when you rewind to an earlier point, the files on disk return to their state at that checkpoint — not just the chat.
This matters because the two problems are connected. If you only clear the conversation but leave the file changes in place, Claude starts from bad code with no memory of how it got there. That’s often worse than either state alone.
What Gets Rolled Back vs. What Doesn’t
Understanding the scope of /rewind
prevents surprises:
What rolls back:
- Conversation messages after the selected checkpoint
- File edits Claude made in that rolled-back portion
- Claude’s “understanding” of what it was trying to accomplish
What doesn’t roll back:
- Terminal commands that had external effects (e.g.,
git push
, package installs, API calls) - Changes you made manually outside of Claude Code
- Any state outside the conversation and file system (database writes, etc.)
This is why working habits matter — more on that below.
How to Use /rewind Step by Step #
Prerequisites
- Claude Code installed and running in your terminal
- An active session (the command only works within a session that has history)
- Awareness of roughly where in the conversation you want to rewind to
Step 1: Recognize You Need to Rewind
The trigger for /rewind
is usually one of these situations:
- Claude has made several edits that compounded an initial mistake
- You gave Claude a vague instruction that it interpreted in a way you didn’t intend, and now it’s too far down that path
- Tests are failing in new ways, not just the original way
- Claude is confidently wrong and correcting it keeps producing variations of the same error
The key signal is that you’re no longer working toward the right solution — you’re working to undo what went wrong. That’s when rewind beats correction.
Step 2: Type /rewind in the Claude Code Interface
In your terminal, within the active Claude Code session, type:
/rewind
Claude Code will display a list of checkpoints from the current session. These correspond to earlier moments in the conversation — typically shown as a numbered or timestamped list of past states you can return to.
Step 3: Select Your Target Checkpoint
Review the list and identify the point before things went wrong. This is usually:
- Before you gave the instruction that sent Claude in the wrong direction
- Before Claude started a refactor that broke something
- Before a sequence of edits that compounded a mistake
Select that checkpoint. Claude Code will confirm what it’s about to do before executing.
Step 4: Confirm the Rollback
Claude Code will ask you to confirm before reverting. Take a moment to verify:
- The checkpoint shown is actually where you want to return
- You understand any external effects (terminal commands) that won’t be rolled back
Confirm, and the rollback executes. The conversation resets to that point, and your files return to their state at that checkpoint.
Step 5: Re-approach the Problem Differently
This is the step most people skip. After rewinding, give Claude a clearer, more constrained instruction than you gave before. The rewind removes the bad path, but if you repeat the same vague prompt, you’ll likely end up in the same place.
Be specific:
- Name the exact file and function you want changed
- Describe the expected behavior, not just the change
- Add constraints (“don’t change the interface, only update the internal logic”)
When /rewind Is Better Than Trying to Correct #
There’s no rule that says every mistake needs a rewind. Sometimes correcting mid-session is faster and fine. Here’s a practical way to think about it:
Use /rewind when:
Multiple files were edited incorrectly. Unwinding file changes manually across several files is tedious and error-prone./rewind
does it in one step.Claude is anchored to a wrong assumption. If Claude made a false assumption early in the session and keeps building on it, clearing that context completely resets its frame.The conversation has gone in circles. Repeated corrections that aren’t converging on a solution indicate the session has accumulated too much conflicting context.You’re about to try a significantly different approach. Rewinding to a clean state before trying a new strategy means Claude starts with no prior bias toward the approach that didn’t work.
Use correction (not /rewind) when:
- The mistake is isolated to one file or one function
- You can describe the fix clearly and specifically
- Claude understood the intent correctly — it just made a minor implementation error
- You’re close to a working solution and only need a small adjustment
The general principle: the more context Claude has accumulated around a bad path, the more useful a rewind becomes.
Building Habits That Make /rewind More Effective #
The /rewind
command works better when you’ve been deliberate about the structure of your session. These habits make rollbacks faster and more reliable.
Keep Sessions Focused
A session that’s bounced between five different features has checkpoints spread across unrelated work. When you need to rewind, it’s harder to find a clean cutoff point.
Work on one focused problem per session. When you shift to a different task, start a new session. This keeps checkpoints meaningful and rollback points obvious.
Front-load Clarity
The earlier in a session you give Claude clear, specific context, the more useful the early checkpoints are. If your first prompt is vague, even rolling back to the start of the session gives you a weak foundation.
Before Claude writes or edits anything significant, make sure it has:
- The specific files and functions involved
- The behavior you want to produce
- Any constraints on how to achieve it
Use /rewind Before Trying Something Risky
You don’t have to wait until something goes wrong. If Claude is about to attempt a major refactor or a structural change you’re not sure about, note where you are in the session first. If it goes sideways, you know exactly where to rewind.
Think of it like saving a game before a hard level — you create the option to revert before you need it.
Avoid External Side Effects During Uncertain Sections
The biggest limitation of /rewind
is that it can’t undo terminal commands with external effects. If Claude runs npm install
, pushes to a remote branch, or makes an API call, those effects persist after a rewind.
When Claude is doing exploratory or uncertain work, be cautious about letting it run commands with external effects. Stick to file edits until you’re confident in the direction.
Common Mistakes When Using /rewind #
Rewinding Too Far Back
It’s tempting to rewind to the very beginning of a session when things go wrong. But if you invested time establishing context early in the session (explaining the codebase, describing the goal, clarifying constraints), rewinding past all that loses useful setup.
Choose the most recent clean checkpoint, not the earliest safe one.
Not Changing the Prompt After Rewinding
Rewinding and then repeating the same instruction often produces the same result. The model will make similar choices given similar input.
After a rewind, take a moment to think about why things went wrong and adjust your prompt accordingly before letting Claude continue.
Relying on /rewind Instead of Version Control
/rewind
is not a substitute for git. It operates on the current session’s changes, but it doesn’t give you a durable history of your project state. If you close the session or start a new one, the rewind history for that session is gone.
Keep committing your code at meaningful points. Use /rewind
for within-session recovery, and git for everything else.
Using /rewind for Simple Mistakes
If Claude makes a small typo in one file or misnames a variable, a rewind is overkill. A simple correction instruction is faster. Save rewinds for situations where the session has genuinely drifted off course.
Comparing /rewind to Other Claude Code Commands #
Claude Code includes several commands for managing session state. Here’s how /rewind
compares to the others:
/rewind vs. /clear
/clear
removes the entire conversation history. It’s a full reset — Claude starts from scratch with no context from the session.
/rewind
is more surgical. It lets you choose a specific point to return to, preserving the work done before that point. It also reverts file changes, which /clear
does not.
Use /clear
when the entire session has gone wrong. Use /rewind
when part of the session is worth keeping.
/rewind vs. /compact
/compact
compresses the conversation history to reduce context window usage. It summarizes earlier parts of the conversation so Claude can fit more in its working memory.
This is a performance tool, not a rollback tool. It doesn’t revert file changes or let you return to a specific earlier state.
/rewind vs. Manual Undo
You could manually undo changes using git or by reverting files by hand. This handles the file side but not the conversation side — Claude still has all that context about what it tried to do, which can pull it back toward the same approaches.
/rewind
handles both at once.
Where MindStudio Fits Into Agentic Development Workflows #
Seven tools to build an app. Or just Remy. #
Editor, preview, AI agents, deploy — all in one tab. Nothing to install.
Claude Code’s /rewind
solves a specific problem: recovering cleanly when an agentic coding session goes off course. But the broader challenge for teams using AI agents — whether for code, content, or operations — is orchestrating multiple steps reliably without getting stuck in bad states.
That’s where MindStudio addresses a different layer of the problem. Instead of recovering from mistakes after they happen, MindStudio lets you build structured, multi-step AI workflows where each step is defined, observable, and testable before it runs.
With MindStudio’s Agent Skills Plugin, Claude Code can call MindStudio’s typed capabilities directly — agent.runWorkflow()
, agent.searchGoogle()
, agent.sendEmail()
— as simple method calls. This means you can offload structured, well-tested sub-tasks to MindStudio agents while Claude Code handles the code-level reasoning. The result is fewer situations where Claude Code needs to rewind, because the riskier or more structured operations are handled by dedicated, tested workflows.
If you’re building agentic development pipelines and find yourself rewinding frequently, it’s worth considering whether some of what Claude Code is attempting could be wrapped in a more structured, reusable MindStudio workflow instead. You can try MindStudio free at mindstudio.ai.
Frequently Asked Questions #
Does /rewind work across multiple sessions?
No. /rewind
only works within the current active session. Once you close a session or start a new one, the checkpoint history from the previous session is no longer available. This is why combining /rewind
with regular git commits is important — git gives you durable rollback history, while /rewind
handles within-session recovery.
Will /rewind undo git commits Claude made?
It depends. If Claude ran git commit
during the session and you rewind past that point, the file state reverts — but the git commit itself is still in your repository history. You’d need to handle that separately with git reset
or git revert
. /rewind
operates on Claude Code’s session state, not your git history.
Can I rewind to the very beginning of a session?
Yes. The checkpoint list typically includes the start of the session as an option. Keep in mind that this reverts all file changes Claude made during the entire session, so make sure that’s actually what you want before confirming.
What if I select the wrong checkpoint?
If you immediately realize you rewound too far (or not far enough), you can try /rewind
again from the new state. However, if you rewound too far and lost useful work, there’s no “redo” — the rolled-back conversation and file changes are gone. This is another reason to commit code frequently so you can recover file state from git even if Claude Code’s checkpoint history doesn’t help.
Does /rewind affect files outside the project directory?
/rewind
reverts files that Claude Code edited during the session, which typically means files within the project directory you’re working in. If Claude edited files outside that scope, behavior may vary. As a general practice, keep Claude Code focused on a specific working directory to keep rollbacks predictable.
Is /rewind available in all Claude Code versions?
Other agents start typing. Remy starts asking. #
Scoping, trade-offs, edge cases — the real work. Before a line of code.
/rewind
is a feature of Claude Code as released by Anthropic. Availability may depend on your version of Claude Code. If the command isn’t recognized in your session, check that you’re running a current version of Claude Code. Anthropic has been actively updating the tool, so keeping it up to date ensures you have access to the latest session management features.
Key Takeaways #
/rewind
rolls back both the conversation history and file changes to a chosen checkpoint — it’s not just a chat undo.- Use it when Claude has compounded mistakes across multiple files, or when the session has accumulated bad context that correction isn’t fixing.
- After rewinding, change your prompt — repeating the same instruction often reproduces the same problem.
- Combine
/rewind
with regular git commits: git handles durable history,/rewind
handles within-session recovery. - Terminal commands with external effects (git push, API calls, package installs) are not reverted by
/rewind
. - Building focused, well-structured sessions with clear early context makes checkpoints more useful and rollbacks cleaner.
For teams looking to reduce how often agentic coding sessions need to recover, MindStudio provides a structured layer for building and testing repeatable AI workflows — a useful complement to the more exploratory, in-session work that Claude Code handles best.