← Claude Docs

Rewind file changes with checkpointing - Claude Code Docs

Claude Docs · July 16, 2026
File checkpointing tracks file modifications made through the Write, Edit, and NotebookEdit tools during an agent session, allowing you to rewind files to any previous state. Want to try it out? Jump to the interactive example. With checkpointing, you can:

Detailed Analysis

Anthropic's Claude Agent SDK documentation introduces file checkpointing, a feature that gives developers a structured way to undo or redirect changes made by Claude Code during agentic coding sessions. The mechanism works by creating backups of files immediately before they are modified through the SDK's core file-manipulation tools—Write, Edit, and NotebookEdit. As Claude works through a session, each user message in the response stream is tagged with a checkpoint UUID, which developers can later use to call a rewindFiles() (TypeScript) or rewind_files() (Python) method to restore the project to that exact point in time. This effectively creates a version-control-like safety net purpose-built for autonomous coding agents, distinct from traditional git workflows.

The significance of this feature lies in the growing autonomy given to AI coding agents. As Claude Code and similar tools are increasingly trusted to make multi-step, multi-file changes—refactoring authentication modules, adding test suites, or restructuring codebases—the risk of unwanted or incorrect modifications grows correspondingly. Checkpointing addresses this by letting developers treat agent actions as reversible experiments rather than irreversible commitments. The documentation outlines concrete patterns for this: checkpointing before "risky operations" so a single rewind can undo an entire failed turn, and maintaining multiple restore points across a session so that, for example, a beneficial refactor from an earlier turn can be preserved while a problematic later change (like an unwanted test addition) is rolled back independently. This selective, granular control is a meaningful improvement over blunt "undo everything" approaches.

Technically, the feature requires explicit opt-in via an enableFileCheckpointing flag, and the documentation is notably detailed about failure modes—missing UUIDs due to unset replay-user-messages flags, stale SDK versions, attempting rewinds on sessions where checkpointing wasn't enabled, or calling rewind after a stream has already closed (requiring a session resume with an empty prompt first). This level of granular troubleshooting guidance suggests Anthropic anticipates checkpointing will be widely adopted in production agent pipelines, where session lifecycle management (resuming, forking, and closing connections cleanly) becomes a first-class engineering concern rather than an edge case.

More broadly, this feature reflects a maturation trend across the AI agent tooling ecosystem: as agents move from single-turn code suggestions toward long-running, multi-turn autonomous workflows, safety and reversibility mechanisms are becoming as important as raw capability. Competitors and open-source agent frameworks have grappled with similar challenges—sandboxing, dry-run modes, diff previews—but Anthropic's approach of embedding checkpoint UUIDs directly into the message stream ties reversibility tightly to the conversational state itself, making it a native part of the developer experience rather than a bolted-on utility. This positions Claude Code as not just a code generator but as a more trustworthy collaborator for production engineering environments, where the ability to safely explore, fail, and recover is essential to earning developer confidence in agentic automation.

Read original article →