---
title: "Checkpoint and rewind pattern for AI agents | Agentic Pattern Language"
description: "Snapshot the code before each agent turn, and go back to it when the agent goes off track. Sourced from Cursor, Anthropic, and Simon Willison."
url: https://agenticpatternlanguage.com/patterns/checkpoint-and-rewind/
---

33 [People and agents](https://agenticpatternlanguage.com/#people-and-agents)

# Checkpoint and rewind

Snapshot the code before each agent turn, and go back to it when the agent goes off track.

Also called Checkpointing

SW Cursor, Anthropic, Simon Willison

[How to read this](https://agenticpatternlanguage.com/notation/)

## Alternatives

* [Human approval](https://agenticpatternlanguage.com/patterns/human-approval/)

## The problem

The agent sometimes builds the wrong thing, and starting over often works better than repairing it.

> Sometimes the agent builds something that doesn't match what you wanted.

Cursor [Best practices for coding with agents](https://cursor.com/blog/agent-best-practices) Jan 9, 2026

> Starting over often has a higher success rate than trying to fix Claude’s mistakes.

Anthropic [How Anthropic teams use Claude Code](https://www-cdn.anthropic.com/58284b19e702b49db9302d5b6f135ad8871e7658.pdf)

## Therefore

> As you work with Claude, checkpointing automatically captures the state of your code before each prompt you send that starts a turn.

Anthropic [Checkpointing](https://code.claude.com/docs/en/checkpointing)

> Checkpoints save snapshots of your codebase during an Agent session. Agent automatically creates them before making significant changes, capturing the state of all modified files.

Cursor [Overview](https://cursor.com/docs/agent/chat/checkpoints)

> Keeping code in version control lets us record how that code changes over time and investigate and reverse any mistakes.

SW Simon Willison [Using Git with coding agents - Agentic Engineering Patterns](https://simonwillison.net/guides/agentic-engineering-patterns/using-git-with-coding-agents/)

## In use

Anthropic’s Claude Code team

> Teams emphasize starting from a clean git state and committing checkpoints regularly so they can easily revert any incorrect changes if Claude goes off track.

Anthropic [How Anthropic teams use Claude Code](https://www-cdn.anthropic.com/58284b19e702b49db9302d5b6f135ad8871e7658.pdf)

Claude Code

> Claude Code automatically tracks Claude’s file edits as you work.

Anthropic [Checkpointing](https://code.claude.com/docs/en/checkpointing)

## Where it breaks

Only the agent’s own file edits are saved: a file changed by a shell command stays changed, and lasting history belongs in Git.

> A file that only Bash commands changed isn’t tracked and stays as it is.

Anthropic [Checkpointing](https://code.claude.com/docs/en/checkpointing)

> Checkpoints are stored locally and separate from Git. Only use them for undoing Agent changes; use Git for permanent version control.

Cursor [Overview](https://cursor.com/docs/agent/chat/checkpoints)

## Sources

1. [Best practices for coding with agents](https://cursor.com/blog/agent-best-practices) Lee Robinson, Cursor, Jan 9, 2026
2. [How Anthropic teams use Claude Code](https://www-cdn.anthropic.com/58284b19e702b49db9302d5b6f135ad8871e7658.pdf) Anthropic
3. [Checkpointing](https://code.claude.com/docs/en/checkpointing) Anthropic
4. [Overview](https://cursor.com/docs/agent/chat/checkpoints) Cursor
5. [Using Git with coding agents - Agentic Engineering Patterns](https://simonwillison.net/guides/agentic-engineering-patterns/using-git-with-coding-agents/) Simon Willison

Added Nov 14, 2026
