claude-news9 min read

Claude Code /rewind: How to Roll Back AI Mistakes with Checkpoints (2026)

Learn how Claude Code's /rewind command rolls back conversations and file changes to any checkpoint. Complete guide to the new feature released June 25, 2026.

Claude Code /rewind: How to Roll Back AI Mistakes with Checkpoints

You've been there. Claude makes a sweeping refactor, you realize halfway through it went the wrong direction, you try to redirect it — and it keeps building on the mistake because the bad context is still in its memory. Until now, your options were to manually undo every file, start a fresh session, or just live with the damage.

Claude Code 2.1.191, released June 25, 2026, ships /rewind — a checkpoint-based rollback system that simultaneously reverts both the conversation history and the file changes Claude made. It's the "Ctrl+Z for AI coding sessions" that developers have been asking for since day one.

This guide covers exactly how /rewind works, when to use it, what its limits are, and how to build it into a safer coding workflow.

What Is Claude Code /rewind?

/rewind is a command that lets you jump back to any checkpoint in your current Claude Code session. A checkpoint is a snapshot that gets created automatically at two moments:
  • Before every file edit — Before Claude writes or modifies a file, it saves a checkpoint.
  • After every prompt — Every time you send a message, Claude Code creates a new checkpoint.
  • When you /rewind to a checkpoint, two things happen simultaneously:

    • The conversation history is rolled back to that point. Claude's reasoning, your instructions, and all responses after the checkpoint are removed.
    • File changes that Claude made during the rolled-back portion of the session are reverted on disk.

    This is a fundamental improvement over just clearing context. Clearing context (/clear) removes the conversation but leaves your files in whatever state Claude left them. /rewind cleans up both.

    How to Use /rewind

    There are two ways to trigger the rewind menu:

    Option 1: Type the command

    bash/rewind

    Option 2: Keyboard shortcut

    Press Esc twice when the prompt input is empty. This opens the rewind menu without typing.

    Once the menu opens, you'll see a list of checkpoints with timestamps and brief descriptions of what happened at each one. Navigate to the checkpoint you want to restore, confirm, and Claude Code handles the rest.

    The Double-Escape Trick

    The Esc + Esc shortcut is worth memorizing. When you realize Claude is going off the rails mid-session, you don't need to type anything — just double-tap Escape. This is especially useful when Claude is in the middle of a long agentic run and you want to stop and revert quickly.

    What /rewind Does and Doesn't Revert

    This is the most important section to understand before relying on /rewind in production workflows.

    What gets reverted

    • File writes — Any file Claude created with the Write tool is deleted.
    • File edits — Any changes Claude made with the Edit tool are undone.
    • Notebook edits — Jupyter notebook cell changes made via NotebookEdit are reverted.
    • Conversation history — The entire conversation is rolled back to the checkpoint state.

    What does NOT get reverted

    • Terminal commands — If Claude ran git push, npm install, pip install, or any shell command, those are not undone. The /rewind system only tracks file editing tools (Write, Edit, NotebookEdit), not Bash execution.
    • External API calls — Any API requests Claude made during the session (webhook calls, database writes, etc.) are permanent.
    • Git operations — Commits, pushes, and branch operations are not reversed. If Claude committed to your repo, that commit stays.
    • Package installations — Dependencies installed during the session remain installed.

    The practical implication: If you let Claude run freely in an agentic loop that involves shell commands, /rewind won't fully clean up after it. The safest pattern is to review and approve shell commands before they execute (use --yes=false or review the permission prompts), so that /rewind can give you a true clean slate.

    /rewind vs /clear: When to Use Which

    /rewind/clear
    Removes conversation history
    Reverts file changes
    Restores to specific checkpoint❌ (full clear only)
    Use when...You want to undo a bad directionYou want a clean context without touching files

    Use /rewind when Claude made file changes you want to undo. Use /clear when you just want to reset context but keep all the work Claude did.

    One new addition in 2.1.191: /rewind can also resume sessions from before /clear was run. If you cleared context and then realized you wanted to go back, /rewind now reaches those earlier checkpoints.

    Why This Matters for AI Coding Workflows

    The /rewind feature addresses a deep problem with AI coding sessions that manual undo can't solve: model context contamination.

    When Claude makes a mistake, you can undo the files manually. But Claude still remembers making those changes. It has the bad refactor in context. When you say "that was wrong, revert it," Claude often half-reverts while still building on the wrong architectural decision — because the wrong reasoning is still baked into the conversation.

    /rewind solves this by rolling back the model's memory alongside the files. After a rewind, Claude doesn't know it made the mistake. You can redirect it from the clean checkpoint with fresh instructions.

    This is especially powerful for:

    • Refactoring sessions — You try one approach, it doesn't work, you rewind and try another without contaminating Claude's thinking.
    • Exploratory coding — Let Claude experiment with an implementation, evaluate it, then rewind to the pre-experiment state if it's not the right direction.
    • Teaching Claude your codebase — If you accidentally give Claude bad context about how your system works, rewind before it applies that wrong mental model to your files.

    Building a Safer Claude Code Workflow with Checkpoints

    Now that checkpointing is automatic, here's a practical workflow to get the most out of /rewind:

    1. Use explicit checkpoint moments

    Before asking Claude to make a large change, send a simple message: "Let's checkpoint here before the refactor." This creates a named reference point you can easily spot in the rewind menu.

    2. Keep shell commands out of agentic loops when possible

    Since terminal commands aren't reverted, structure your sessions so Claude does file editing first, then you run shell commands manually after reviewing. This maximizes what /rewind can cleanly undo.

    3. Rewind early, not late

    The moment you sense Claude is going the wrong direction, rewind. The further it goes, the more file changes accumulate, and the more likely it is that some external side effect (a shell command, a git commit) makes the rewind incomplete.

    4. Combine with Claude Code's sandbox credential blocking

    Version 2.1.191 also shipped sandbox.credentials — a setting that blocks sandboxed commands from reading credential files and secret environment variables. Enable this to limit the blast radius of an agentic session that goes wrong.

    json// .claude/settings.json
    {
      "sandbox": {
        "credentials": "block"
      }
    }

    With this setting on, even if Claude runs a shell command in an agentic loop, it can't accidentally exfiltrate or misuse credentials — adding a safety layer on top of what /rewind provides.

    Other Changes in Claude Code 2.1.191

    The /rewind feature ships alongside a broad reliability update. Key fixes in this release:

    • MCP resilience — Remote MCP tool calls that used to hang indefinitely (up to 5 minutes with no response) now abort with an error. This prevents stuck agentic sessions.
    • OAuth handling improvements — Better handling of MCP OAuth flows that previously required manual intervention.
    • Fixed --resume bug--resume was failing with "No conversation found" when the original -p run produced no model turns. Fixed.
    • Structured output reliability--json-schema and workflow agent({schema}) are now more reliable for extracting structured data from Claude responses.
    • Org-configured model restrictions — Admins can now restrict which models are available in the model picker, --model flag, /model command, and ANTHROPIC_MODEL env var. This matters for enterprise deployments.
    • Lower CPU and memory usage — Reduced resource consumption during streaming and long sessions.
    • VS Code stability — Several IDE extension fixes for edge cases in long agentic sessions.

    What This Means for the Claude Certified Architect Exam

    If you're preparing for the Claude Certified Architect (CCA) exam, the /rewind feature introduces a new category of Claude Code capability worth knowing: session state management.

    The CCA exam covers agentic architecture, tool use, and safety patterns. The addition of checkpoint-based rollback is a concrete example of how agentic systems should handle failure recovery — an architectural pattern where the system maintains rollback points to prevent irreversible state corruption. Understanding why /rewind only reverts file-editing tools (not shell commands) is exactly the kind of systems-thinking question the CCA tests.

    Key Takeaways

    • /rewind rolls back both conversation history and file changes to any checkpoint in the current session.
    • Checkpoints are created automatically before every file edit and after every prompt.
    • Terminal commands, git operations, and external API calls are not reverted — only Write, Edit, and NotebookEdit changes.
    • The Esc + Esc shortcut opens the rewind menu without typing.
    • Combined with sandbox.credentials: block, /rewind gives you meaningful error recovery for agentic coding sessions.
    • Version 2.1.191 also shipped MCP reliability fixes, structured output improvements, and org-level model restrictions.

    Next Steps

    If you're using Claude Code seriously, add /rewind to your workflow today. The biggest unlock is treating checkpoints as deliberate save points — message Claude before a risky operation to create a named checkpoint, then rewind to it if the operation goes wrong.

    Want to go deeper on building safe, reliable agentic workflows with Claude Code? Check out our Claude Code hooks tutorial for automating pre- and post-operation checks, or our Claude multi-agent orchestration guide for managing complex agentic sessions.

    And if you're preparing for the Claude Certified Architect certification, our CCA exam guide covers every domain including agentic architecture patterns — the exact category that /rewind and checkpoint design fall under.


    Sources: Claude Code changelog · ExplainX: Claude Code 2.1.191 · MindStudio: How to Use /rewind · Anthropic Release Notes

    Ready to Start Practicing?

    300+ scenario-based practice questions covering all 5 CCA domains. Detailed explanations for every answer.

    Free CCA Study Kit

    Get domain cheat sheets, anti-pattern flashcards, and weekly exam tips. No spam, unsubscribe anytime.