---
title: "Claude Code rollback: How to undo changes using /rewind"
description: "Learn how to perform a Claude Code rollback using the /rewind command. Restore your code and conversation history quickly. Follow our guide to recover safely."
---

# Claude Code rollback: How to undo changes using /rewind

Published: 2026-09-18T02:24:30.903Z

Author: [Goon Nguyen](/author/goon)

Reading time: 14 minutes

Learn how to perform a Claude Code rollback using the /rewind command. Restore your code and conversation history quickly. Follow our guide to recover safely.

# Claude Code rollback: How to undo changes with `/rewind`

When an incorrect refactor or configuration edit changes several files, stop making further changes and run `/rewind`. This Claude Code rollback flow lets you select the prompt immediately before the unwanted edit, then restore code, conversation history, or both. After restoration, inspect the working tree before continuing. According to the [official Claude Code checkpointing documentation](https://code.claude.com/docs/en/checkpointing), recovery coverage depends on how the files were modified. Changes made through Bash commands, manual edits, or external processes may not be restored.

> **Quick answer:** Run `/rewind`, select the checkpoint before the unwanted change, choose the appropriate restore mode, then verify the result with `git status`, `git diff`, and relevant tests.

![Image](https://cdn.agentkit.best/blog/cfai-media/8fc65fe4375d41d66ca7fb1935de14435f95fc3bed815d742d22a767b2e62c38-b67ece8597bdea5a3e02edaf40bc6143b92969a74b8227dfb3b039837f1aef6e.jpg)

## How to perform a Claude Code rollback with `/rewind`

`/rewind` is the primary session-level recovery command for reverting recent [Claude Code](https://agentkit.best/blog/claude-code-guides/what-is-claude-code-a-complete-guide-to-the-ai-coding-tool) changes. It uses available checkpoints associated with the current or resumed session.

To roll back Claude Code changes:

![Image](https://cdn.agentkit.best/blog/cfai-media/9059161b7104afbef7b76519db3c95ba19214e2b92e58c6e981b07d38bc5b664-5769326f52973ceedfbcdb5dadb627cf2910df5ec103eab53c59d73d5c8299ea.jpg)

Choose the prompt immediately before the failed implementation, deletion, refactor, or configuration change.

The safest target is usually the last point where the code was known to behave correctly. If uncertain, preserve irreplaceable uncommitted work before attempting another restoration.

> **Warning:** `/rewind` is not a repository-wide recovery guarantee. A mixed task involving Claude file tools, Bash commands, IDE edits, or generators can produce a partial rollback. Do not immediately run `git reset --hard`, `git clean`, or broad deletion scripts before reviewing useful work.

## Choose the correct restore option

File state and conversation state are separate. Choose the option based on what went wrong, rather than assuming restoring both is always safest.

![Image](https://cdn.agentkit.best/blog/cfai-media/144056d2e6b018f8be35334ed2c333a9004c2f6217c4a33a6715590c09d0922a-1679713ecf7f30c78ccb133557ea15d8a10f0083c5dc14bae9e68622f7f72bdf.jpg)

### Restore code and conversation

Use Restore code and conversation when both the implementation and reasoning moved in the wrong direction. A failed architectural change or unsuitable multi-file refactor is a typical example.

Covered files return to the selected checkpoint state, and the conversation returns to that point. Claude Code also places the selected prompt back into the input field, allowing you to revise its scope before trying again.

### Restore code only

Use **Restore code** when Claude correctly diagnosed the problem but implemented the wrong solution. The covered file state is restored while the current conversation remains available.

This option preserves useful analysis, constraints, and debugging context. Always review the resulting diff because unsupported file mutations may still be present.

### Restore conversation only

Use **Restore conversation** when the current files are acceptable, but later messages have created misleading or unproductive context.

Restoring conversation does not revert files. The working tree remains as it was before selecting the option.

### Summarization options

Context summarization does not modify files on disk. It manages the available conversation context and should not be treated as code recovery.

## What Claude Code rollback can and cannot restore

Claude Code checkpointing creates session-level file snapshots for supported Claude file operations before each user prompt. `/rewind` uses available checkpoints to restore covered code, conversation history, or both. It does not automatically recover Bash mutations, manual IDE edits, external side effects, unsupported paths, or snapshots removed by retention cleanup.

The official documentation states that Claude Code retains file snapshots for the 100 most recent checkpoints in a session. Session snapshots are generally subject to a cleanup period of approximately 30 days after the session was last saved, unless `cleanupPeriodDays` is configured differently. Verify these values before publication because checkpoint behavior can change between versions.

![Image](https://cdn.agentkit.best/blog/cfai-media/171c4ad05161e6d516fa7c1b90646461c6d8cb87a352f71c4ff07286f5ae6466-90f02d566fe04bd81d3e797b15f86cc2a5f2331219b71dae56e9bd43ebc68812.jpg)

### Changes usually covered by checkpointing

When the checkpoint remains available, Claude Code can generally restore:

These file snapshots are designed for short-term, session-level recovery. They are not permanent backups or a replacement for repository history.

### Changes that usually require another recovery method

Use Git, local history, backups, or a system-specific recovery process for:

Restoring local source files does not reverse a deployment, published package, database operation, or remote API request.

### Why partial rollbacks happen

Consider a task where Claude edits source files directly, then runs a shell command that regenerates configuration files. `/rewind` may restore the directly edited source files while leaving generated files unchanged.

The working tree then contains a combination of restored and externally modified files. This is why `git status`, `git diff`, and project tests are required after recovery.

> **Important limitation:** A successful recovery message only confirms that the selected action completed. It does not prove that every repository file or external system returned to the intended state.

## Troubleshooting when `/rewind` does not restore the expected files

If Claude Code rewind is not working, diagnose the modification source before trying random checkpoints. Repeated attempts can make the working tree harder to understand.

### 1. Stop before making more changes

Do not rerun the same Claude task, apply a formatter, execute a generator, or use broad shell commands. If the working tree contains irreplaceable uncommitted work, copy the affected files or preserve them through an appropriate non-destructive method before continuing.

### 2. Confirm how the file was modified

Determine which process created the unwanted change:

Checkpoint coverage follows the source of the mutation. A file discussed by Claude is not necessarily a file tracked by checkpointing.

### 3. Confirm the session and checkpoint

Resume the Claude Code session that originally produced the change. Checkpoints are stored with the conversation, so switching to another session can hide the relevant recovery points.

Select a checkpoint that predates the unwanted edit. A later checkpoint may preserve part of the change, while an unnecessarily early checkpoint may remove useful Claude-tracked work.

![Image](https://cdn.agentkit.best/blog/cfai-media/45d5352b497997d23bd8efcf1ba2cabcf7109406c00a39becca574d56a541c43-63ec0b98cf751f2632779ee638f5ea2af32bdce25c0099566a8463c916fa5c1b.jpg)

### 4. Check checkpoint retention

Checkpoints and file snapshots are not retained indefinitely. Older snapshots may be removed during retention cleanup even when the session conversation remains available.

If Claude Code reports **“No files were restored,”** possible causes include:

Do not assume retention is the only cause.

### 5. Check unsupported paths and subagent activity

Review restoration warnings involving:

Subagent recovery depends on how the subagent performed its edits. Treat its coverage as conditional unless verified in the current session.

### 6. Inspect Git and local history

Start with inspection rather than destruction:

`git status
git diff
`

`git status` identifies modified and untracked files. `git diff` shows tracked working-tree differences, but it does not automatically display the contents of untracked files.

Then inspect available recovery sources:

> **Warning:** Do not run destructive Git commands before reviewing and preserving useful work. Those commands can remove uncommitted changes that Claude Code file recovery cannot restore.

## Claude Code `/rewind` vs. Git Rollback

The practical difference between Claude Code rollback and Git revert lies in their scope. The `/rewind` command manages recent session checkpoints and can restore conversation state, while Git provides durable project history, collaboration support, and detailed release tracking.

`git revert` is a specific Git command that creates a new commit reversing an earlier commit. It should not be used as a generic name for every Git recovery method.

![Image](https://cdn.agentkit.best/blog/cfai-media/62ba57dffc8bff0c2c096be189499032bf9a62e3a2ac1b47294ab63f2d563c9f-130d67d715bae17cd9210d600f13a6171660849d8468324ac0c543daf829c640.jpg)

### Use `/rewind` when

### Use Git when

### Use both

A safer recovery model has three layers:

Neither tool universally replaces the other. Git cannot restore Claude Code session history, while `/rewind` does not provide complete repository or release history.

## A safer workflow for future Claude Code changes

A rollback-safe workflow reduces both recovery time and uncertainty. The objective is to create clear boundaries before Claude edits code or triggers external processes.

![Image](https://cdn.agentkit.best/blog/cfai-media/63d9e9b3fcc6b7c3f4c8ef297d96e5863290edced09e2949a405ca2ead09e847-f729ba3513a5af8d604560e1ed9755d56710aee958f4c7b1cf20b29a9b4497f8.jpg)

Require an explicit approval gate before Claude performs:

Separating direct code edits from shell commands also makes recovery boundaries easier to understand. If possible, review code changes before allowing a formatter, generator, migration, or deployment command to run.

AgentKit can standardize this process through reusable Claude Code workflow setup, affected-file planning, automated testing, review agents, and approval gates. These AI agentic workflows improve process consistency but do not extend Claude Code’s native checkpoint retention or file coverage.

## Restore first, then verify

A reliable Claude Code rollback starts by stopping further changes, running `/rewind`, and selecting the checkpoint immediately before the unwanted edit. Choose whether to restore code, conversation history, or both based on the actual failure.

Recovery is not complete until you inspect the working tree, review the diff, and run relevant tests. Use Claude Code `/rewind` for available session-level recovery, while relying on **Git version control** for durable project history, collaboration, and release traceability.

## Frequently asked questions

### What is Claude Code rollback?

Claude Code rollback is a session-level recovery mechanism that uses the `/rewind` command to revert your files and conversation history to a previous checkpoint. It allows you to undo unwanted edits performed by Claude Code and reset your session state after a mistake.

### How do I undo changes in Claude Code?

To undo changes, stop making further edits and run the `/rewind` command in your terminal. Select the checkpoint immediately preceding the unwanted changes, choose whether to restore code, conversation, or both, and verify the resulting diff using `git diff` before continuing your work.

### Which restore option should I choose?

Choose "Restore code and conversation" for failed multi-file refactors. Use "Restore code only" if Claude identified the correct problem but implemented the wrong solution. Select "Restore conversation only" if your files are acceptable but the session context has become misleading or unhelpful.

### Does `/rewind` restore files changed by Bash commands?

No. `/rewind` only tracks and restores file edits performed by Claude Code’s internal tools. Changes made through Bash commands, manual IDE edits, formatters, or external processes are not automatically tracked by checkpointing and generally require recovery via Git or local history.

### Can I use Git instead of `/rewind`?

Yes. `/rewind` is optimized for fast, session-level recovery between checkpoints, whereas Git provides durable repository-wide history, collaboration, and release-level traceability. The best practice is to commit at important milestones using Git and use `/rewind` for fine-grained rollbacks during active development sessions.

### Why did "No files were restored" appear?

This message typically occurs if you selected a checkpoint where no snapshots were available, if the files were modified via unsupported external tools, or if the checkpoint retention period has expired. In this case, inspect your working tree with `git status` and revert changes using Git.

**Read more**:

## Conclusion

Overall, Claude Code’s `/rewind` command provides a convenient way to undo recent changes, while Git offers more reliable long-term version control. By reviewing the restored files, checking the differences, and running relevant tests, developers can recover safely and continue working with confidence.
