explainx.ainewsletter3.5k
TrendingNewsPathwaysSkills
Pricing
explainx.ai

Upskill in AI — 16 free pathways, live workshops & bootcamps, and 50+ courses from practitioners. Plus the skills, tools, and MCP servers to practice on.

follow us

custom AI agents

[email protected]

get started

Find your pathTake Free Evaluation

learn

pathways — start freeworkshopsbootcampscoursescertificationsmock testsexplainx universitycorporate traininglearn skills & mcp

discover

skillsmcp serversexplainx mcptoolsagentsllmsdesignsagi trackerranks

company

aboutvisionmissionteaminstructorscommunityhackathonscareers

content

daily AI newsstate of AI — live resultsblogreleasespromptsgeneratorsresource librarydemofor LLMs

solutions

all solutionsdeveloper upskillingmarketing upskillingproduct manager upskillingleadership upskilling

More from us

InfloqInfluencer marketingBgBlurPrivacy-first blurOlly SocialSocial AI copilotCeptoryVideo intelligenceBgRemoverBackground removal

newsletter · weekly

Get AI news, tools, and insights in your inbox.

supportprivacytermsdata rightssubmission guidelines

© 2026 AISOLO Technologies Pvt Ltd

On this page

  • How to activate the restore menu
  • Understanding the four restore options
  • Comparison with Cursor's checkpoint feature
  • When to use Claude Code restore vs git
  • Practical workflow examples
  • Best practices for checkpoint-driven development
  • Keyboard shortcut summary
  • Related on explainx.ai
  • Bottom line
← Back to blog

explainx / blog

How to restore previous code in Claude Code CLI: checkpoint feature similar to Cursor's restore functionality

Press ESC twice in Claude Code CLI to access checkpoint restore options that let you revert to previous code states. Choose from four options: restore code and conversation, restore conversation only, restore code only, or cancel. Similar to Cursor's checkpoint feature but built into Claude Code.

Jun 6, 2026·5 min read·Yash Thakker
Claude CodeDeveloper ToolsVersion ControlCheckpointsProductivity
go deep
How to restore previous code in Claude Code CLI: checkpoint feature similar to Cursor's restore functionality

Claude Code CLI has a powerful but lesser-known checkpoint restore feature that lets you revert to previous code and conversation states—similar to Cursor's checkpoint functionality—without relying on git.

Update — June 25, 2026 (v2.1.191): If you ran /clear and lost context, /rewind can now resume from before the clear — complementary to ESC × 2 checkpoints. See Claude Code 2.1.191 changelog.

The feature is activated by pressing ESC twice in rapid succession, which opens a menu with four restoration options:

  1. Restore code and conversation — revert both files and chat history
  2. Restore conversation — revert only the chat history
  3. Restore code — revert only file changes
  4. Nevermind — cancel the operation

This is particularly useful during experimentation, debugging, or when trying multiple approaches to a problem. You can quickly revert changes without the overhead of git commits or stash operations.

This article explains how to use the restore feature, when to use each option, how it compares to Cursor's checkpoints, and best practices for checkpoint-driven development.

Claude Code restore checkpoint feature — ESC twice to restore

Weekly digest3.5k readers

Catch up on AI

Curated AI updates on agents, skills, and MCP — delivered to your inbox. Unsubscribe anytime.

How to activate the restore menu

The restore feature is accessed with a simple keyboard shortcut:

  1. Press ESC twice (rapidly, within about 1 second)
  2. A menu appears with four options
  3. Use arrow keys or number keys to select an option
  4. Press Enter to confirm

Claude Code checkpoint restore menu showing four options

What happens when you press ESC twice

bash
# You're in an active Claude Code session
$ claude

# You've made several code changes and had a conversation
> Can you add error handling to the API?
[Claude makes changes to server.ts, adds try-catch blocks]

> Actually, let me try a different approach
# Press ESC ESC (twice rapidly)

┌─────────────────────────────────────────────────────┐
│  Restore checkpoint                                  │
├─────────────────────────────────────────────────────┤
│  1. Restore code and conversation                   │
│  2. Restore conversation                            │
│  3. Restore code                                    │
│  4. Nevermind                                       │
└─────────────────────────────────────────────────────┘

Understanding the four restore options

Each restore option serves a different use case during development:

1. Restore code and conversation

Use case: You want to completely undo both the code changes and the conversation history.

bash
Before restore:
- server.ts modified with try-catch blocks
- 5 messages in conversation about error handling

After "Restore code and conversation":
- server.ts reverted to checkpoint state
- Conversation reverted to checkpoint state
- Fresh slate for new approach

When to use:

  • You've gone down a wrong path entirely
  • Both the code and conversation are no longer relevant
  • You want to start fresh from a known good state

2. Restore conversation

Use case: Keep your code changes but reset the conversation context.

bash
Before restore:
- server.ts modified with try-catch blocks (KEEP)
- 5 messages in conversation about error handling (REVERT)

After "Restore conversation":
- server.ts still has try-catch blocks
- Conversation history cleared
- Useful for explaining code to someone else with fresh context

When to use:

  • You want to keep the code but explain it differently
  • The conversation became cluttered or went off-topic
  • You're starting a new task but want to keep recent code changes

3. Restore code

Use case: Revert code changes but preserve the conversation history.

bash
Before restore:
- server.ts modified with try-catch blocks (REVERT)
- 5 messages in conversation about error handling (KEEP)

After "Restore code":
- server.ts reverted to checkpoint state
- Conversation history preserved
- Useful for referencing what didn't work

When to use:

  • The code approach didn't work but the discussion is valuable
  • You want to reference the conversation while trying a new implementation
  • Debugging: keeping the analysis but reverting attempted fixes

4. Nevermind

Use case: Cancel the restore operation.

bash
# You pressed ESC ESC by accident
# Select "Nevermind" to continue without restoring anything

Comparison with Cursor's checkpoint feature

Both Claude Code and Cursor offer checkpoint functionality, but with different approaches:

FeatureClaude CodeCursor
ActivationPress ESC twiceDedicated checkpoint UI
GranularityCode, conversation, or bothCode checkpoints
Session scopeCurrent sessionProject-based
Git integrationIndependentCan integrate with git
Conversation restore✅ Yes❌ No
Visual timeline❌ No (menu-based)✅ Yes

Key advantage of Claude Code: The ability to restore conversation state separately from code is unique and valuable for maintaining context during experiments.

Key advantage of Cursor: Visual checkpoint timeline makes it easier to see what changed at each checkpoint.

When to use Claude Code restore vs git

Use Claude Code restore when:

✅ Experimenting with quick iterations ✅ Trying multiple approaches in a single session ✅ You want to preserve conversation context ✅ No need for permanent version control ✅ Working on throwaway code or spikes

Use git when:

✅ You need permanent version control ✅ Collaborating with others ✅ You want detailed commit messages and history ✅ Changes need to be shared across machines ✅ You're working on production code

Best practice: Use both—Claude Code restore for rapid iteration, git for checkpoints you want to keep.

Practical workflow examples

Example 1: API design experimentation

bash
$ claude

> Design a REST API for user authentication

# Checkpoint 1 (automatically created)
[Claude designs JWT-based auth]

> Actually, let's try session-based auth instead
[Claude implements session-based approach]

# Not happy with it
ESC ESC → "Restore code and conversation"
# Back to Checkpoint 1

> What about OAuth2 with refresh tokens?
[Claude implements OAuth2]

# This works! Commit to git
$ git add . && git commit -m "Add OAuth2 authentication"

Example 2: Debugging with conversation preservation

bash
$ claude

> The login endpoint returns 500 errors

# Deep conversation about potential causes
# Claude suggests checking database connection, environment variables, etc.

> Try fixing the database connection timeout
[Claude modifies db.ts with new timeout settings]

# Didn't work, but the conversation analysis is valuable
ESC ESC → "Restore code"
# Code reverted, conversation preserved

> Based on your analysis above, let's try the environment variable approach
[Claude fixes .env configuration]
# This works!

Example 3: Cleaning up conversation clutter

bash
$ claude

> Refactor the authentication module
[Long conversation with multiple tangents and clarifications]

# Code is good, but conversation is messy
ESC ESC → "Restore conversation"
# Code preserved, conversation reset

> I've refactored the auth module to use dependency injection
# Fresh conversation context for the next developer

Best practices for checkpoint-driven development

1. Know your checkpoint states

Claude Code creates automatic checkpoints at key moments (exact timing is implementation-dependent). Understanding when checkpoints are created helps you restore to the right state.

2. Use restore for experiments, git for keepers

bash
# Experiment with Claude Code restore
ESC ESC → try approach A
ESC ESC → try approach B
ESC ESC → try approach C

# When you find the winner, commit to git
$ git add . && git commit -m "Implement approach B for auth"

3. Preserve valuable conversations

If a conversation contains valuable analysis or context, use "Restore code" instead of "Restore code and conversation" to keep the discussion.

4. Combine with /goal for autonomous checkpoints

If you're using /goal for long-running tasks (see Claude Code /goal command guide), you can use restore to revert if the autonomous agent goes off track.

bash
> /goal All tests passing, coverage > 90%
[Claude works for 30 minutes across multiple turns]
[Results are not what you expected]

ESC ESC → "Restore code and conversation"
# Back to before /goal was invoked

Keyboard shortcut summary

ActionShortcutResult
Open restore menuESC ESC (twice rapidly)Shows 4 restore options
Navigate menuArrow keys or 1/2/3/4Highlight option
Confirm selectionEnterExecute restore
CancelSelect "Nevermind" or ESCClose menu without restoring

Related on explainx.ai

  • Claude Code /goal command: long-running agents — set completion conditions and let Claude work autonomously
  • Cursor vs Claude Code comparison — full comparison of AI coding assistants (hypothetical link)
  • Claude Code keybindings customization — customize keyboard shortcuts (hypothetical link)

Bottom line

Claude Code's checkpoint restore feature (activated by pressing ESC twice) provides Cursor-style checkpoint functionality with the added benefit of separate conversation and code restoration.

The four options—restore code and conversation, restore conversation, restore code, or nevermind—give you fine-grained control over what to revert during development.

Use it for rapid experimentation during active sessions, and commit valuable changes to git for permanent version control. The combination of Claude Code checkpoints for iteration and git for persistence creates a powerful workflow for AI-assisted development.

Next time you're experimenting with Claude Code, try ESC ESC to explore different approaches without fear of losing progress.


Claude Code documentation: https://github.com/anthropics/claude-code. explainx.ai is not affiliated with Anthropic.

Yash Thakker

Written by

Yash Thakker

Yash is an AI expert with over 300K learners. Join his workshops →

Related posts

Jun 24, 2026

Claude Code Adds Itself as Git Co-Author: What It Means and How to Disable It [2026]

Claude Code automatically appends a "Co-Authored-By: Claude Opus <[email protected]>" trailer to every git commit it creates. The debate is live on X: some engineers call it dishonest to remove it, others call it inappropriate to credit a tool. Here is where it comes from, why other AI coding tools do the same thing, and the exact steps to turn it off — including a one-line settings.json fix and a Claude Code skill that prevents it permanently.

Jun 22, 2026

Steering Claude Code: CLAUDE.md, Skills, Hooks, Subagents, and Rules Explained

CLAUDE.md loads at session start and stays forever. Skills load only when invoked. Hooks run deterministically outside the context window. Subagents return only a summary to the main thread. Anthropic's new guide maps all seven instruction methods — here is the practical breakdown with decision rules for each.

Jun 12, 2026

Claude Code Context Window: What Happens When You Hit the Limit (and How to Fix It)

Claude Sonnet 4.6 has a 1 million token context window, but long sessions fill it faster than you expect. Learn what triggers the limit, how automatic compaction works, and the exact commands (/clear, /compact, --fork-session) to manage context like a pro.