Undo/Checkpoint Feature for Correcting AI-Generated Code

Resolved 💬 83 comments Opened Mar 5, 2025 by cyberpapiii Closed Sep 29, 2025
💡 Likely answer: A maintainer (ashwin-ant, collaborator) responded on this thread — see the highlighted reply below.

Bug Description
NEED AN UNDO OR CHECKPOINT FEATURE SO USERS CAN GO BACK AND REVERSE CODE OR MISTAKES THAT CLAUDE MAKES

Environment Info

  • Platform: macos
  • Terminal: ghostty
  • Version: 0.2.32
  • Feedback ID: 175ac8be-c9ab-4955-8051-086d22413551

View original on GitHub ↗

83 Comments

ashwin-ant collaborator · 1 year ago

This is something we're thinking about! How would you imagine it working?

mmstroik · 1 year ago
This is something we're thinking about! How would you imagine it working?

Could maybe integrate it with a prompt edit feature, kinda like cursor. You'd have file state checkpoints created when the user sends a prompt, and then later the user can restore to that checkpoint, which would clear the chat context below it and allow you to edit and resend that prompt.

You could also have checkpoints created each time claude attempts to use the file edit tool, and if the user reverts back to it later (can maybe have some kind of /revert command) it could clear the context below that tool use and just show up as a user interruption to Claude

The file state snapshots could maybe work similarly to the local history feature in some IDEs

Kimeiga · 1 year ago

You could have /prev and /next commands to navigate up and down the stack of changes maybe
when you run /prev, it makes the last edit's output greyed out so you can still see it but scroll up to the one that is full bright that is currently selected. Maybe people who have the previous summary feature turned on would have the changeset that they just navigated away from with /prev get summarized to be smaller

If you run /prev and then do a different claude prompt, it could clear the rest of the output in front of it since you're overwriting

Personally i would prefer having the changesets not disappear entirely when you run /prev, but i realize that this would make it necessary for you to scroll a lot, and if you run /prev enough you could go up beyond your scrollback buffer

tekacs · 1 year ago

I came here to propose something similar: fast state/context saving & restoration would be super valuable.

At the moment, I decently often have threads where I'm building up the model's context to a point for it to be able to tackle a harder issue.

Unfortunately, as things stand, there's no /fast/ way to then snapshot that state of affairs and come back to it later

This feels like it's a third branch amongst the options of /clear, /compact and now /save + /restore. The idea being that you could:

  1. Build up a bunch of context
  2. /save <name>
  3. Work on a problem
  4. Approach full context, or decide to go backwards and try something else
  5. /restore <name>

Ideally given a <name> to save to (or an LLM-generated name), you could /save in one session and then open another session (or sessions) and /restore <name> to pick up from the first.

Would love to see something like this!

gsidsid · 1 year ago

+1! I'd prefer something simple, just an /undo to restore any file changes and conversation history back to the last user instruction. And maybe a /revert to go back (restore files) to before claude code was run. I'd also think it's fine to override any user edits to files between interactions with claude where inverting the diff/merging isn't possible.

aaronlippold · 1 year ago

Basically you could use a set of internal git stashes - this would do it I think.

aaronlippold · 1 year ago

This is one of the reason I usually use VSCode as my 'terminal' given I git a bit of undo naturally as part of the file updates in vscode but I know the desired first class approach is the strait terminal so a secondary git repo with a history of stashes - which you could name with whatever you use as your internal api interaction index so claude could reference it would likely get you where you need to go.

Also this would help save the 'claude went made and just assume all its magical code would work with no testing or validation of that assumption what so ever' --- sorry my own experiences are showing. LOL

aaronlippold · 1 year ago

Or maybe the other git worktree?

None of this should be taken as complaint. I have accomplished amazing I love this and will keep doing it but I have been basically doing a daily driver with this now for a solid month or so and like others and turning over a few rocks.

This features and a bit of focused work on active context management will take this to a level or two above its already leveled up status.

amackenzie1 · 1 year ago

Yeah, this feels like the main feature Claude Code is missing as compared to something like Cursor. Manually committing every time you ask Claude to make a new change seems pretty inefficient?

nsanden · 1 year ago
This is something we're thinking about! How would you imagine it working?

Just simply an /undo

I do also like the checkpoint idea as well though, where chat, code edits, etc reverts back.

sedghi · 1 year ago

This please
Sometimes Claude starts out well, but it's not quite good enough for me to commit. I request some modifications, but on the second try, it goes completely sideways. I really wish I had that original first checkpoint; even though it wasn't committable, it was a pretty good checkpoint.

Ixe1 · 1 year ago

Agreed, a checkpoint feature would be extremely handy. I can think of two other IDE variants of this kind of project where they do checkpoints after changes have been made to a project, as well as one initially after the user starts a new task. Claude Code needs a checkpoint feature too.

Aron-Lomner · 1 year ago
This is something we're thinking about! How would you imagine it working?

Simple functionality to revert back to any prior prompt of user. Currently, if you are in a conversation and mess up a prompt, you encounter a dilemma, continue with the poisoned history burdening the context and clarity of Claude, or start a new chat and lose all your existing context. Neither options are appealing, but both are appalling. I fail to see any downside to implement what should be a simple and well needed feature. Please open my eyes.

max-sixty · 1 year ago
This is something we're thinking about! How would you imagine it working?

to keep claude relatively simple and avoid a whole new state management system, how about using git to manage the state?

  • when claude returns to the user, it runs sha=$(git stash create); git update-ref -m "claude $session_id $(date +%F_%H%M%S)" refs/claude-snapshot "$sha"; echo "$sha"
  • ...which saves the current state of the working tree as a ref, returning the hash of the ref. claude would be responsible for storing a map of conversation turns to git hashes
  • claude could offer a similar interface to the existing esc esc (which currently restores the _conversation_ state), to restore the repo state to a past conversation turn
  • on restoring, it runs git restore -SW --source=<sha> ., the repo is restored to that state
  • maybe it runs the same command as above on restoring, so someone can always undo the restore on their own if they're in a real bind

because it writes to refs/claude-snapshot, git will clean up the old snapshots along with its usual cleanups, there's no infinitely accumulating storage. and no need to build an opaque state management system in sqlite etc.

one downside is that it wouldn't handle untracked files. it could add these with --intent-to-add, but that does then make a small change to someone's git index. I'm not sure of a simple way to get around that beyond a workaround to 'add, save, undo add"

DystopianDisco · 1 year ago

checkpoints are essential. This has to be a top priority for Claude Code? especially with Sonnet 3.7 going off the rails at times and creating something you never asked for - overwriting entire app pages.

Crazytieguy · 1 year ago

Agree that this is a must, maybe the only thing keeping me from moving off cursor. Maybe check out Codebuff for inspiration

lukaemon · 1 year ago

per step checkpoint is necessary. one bad edit would ruin many good changes between commits if git is the only tool at the moment.

Crazytieguy · 1 year ago

My current work around is putting this in the CLAUDE.md (wip but already works pretty well):

## Git Workflow

- **Commit after each user request**: When completing what the user asked for, immediately commit: `git add -A && git commit -m "[action]: [what was accomplished]"`
- Commits should happen WITHOUT asking - they're for checkpoints, not cleanliness (will be squashed later)
- Commits are restore points - if user says something like "let's go back to before X" or "Lets undo that", find the appropriate commit and run `git reset --hard [commit-hash]` to restore the state. Always verify the commit hash via `git log` or `git reflog` first.
- If you've reset to a previous commit and need to go forward again, use `git reflog` to see all recent commits (including those "lost" by reset), then `git reset --hard [commit-hash]` to jump forward to any commit shown in the reflog.
- **ALWAYS update claude-notes.md and include it in EVERY commit** - this preserves context so future Claude Code sessions can continue from any restore point. Maintain a list of the commit messages made during the session/feature.
- When feature complete and user approves or asks to push perform a squash: run `pnpm run lint` first, then find the first commit for the session/feature, then `git reset --soft [starting-commit]` then CLEAR claude-notes.md and commit with `"feat: [complete feature description]"`
- Before major feature work: Tell user "Starting [feature], will make frequent commits as checkpoints then squash when complete"
- Claude Code notes file should include:
  - Current feature being worked on
  - List of commits made during the session/feature
  - Progress status and next steps
  - Important context or decisions made
  - Relevant file locations or dependencies

I think a possible improvement would be to tell claude to use branches instead of reset --hard, but I haven't tried it yet

davlasry · 1 year ago

it's a must indeed, considering moving exclusively to Cursor because of this...

Slavezax · 1 year ago

A must!

MichielMAnalytics · 1 year ago

The product is not usable without it even. Models make mistakes. That is fine. If you can undo. My way of working:

  • fire a prompt
  • let the model execute and watch
  • if you see he is taking the wrong direction
  • stop it and add a line to the prompt to make sure the model won't go into that wrong direction
  • iterate on this and eventually zero-shotting will ALWAYS work
ghodss · 1 year ago

Agreed here - I would prefer being able to use Shift+Up/Down-arrows to navigate through each user-submitted message - once at the message, <enter> allows you to revert both the conversation and the state of the code to that state.

sohei1l · 1 year ago
andrepimenta · 1 year ago

I've built a checkpoint feature where you can undo any change. It's a VS Code extension that provides a chat interface for Claude Code as well as the ability to restore checkpoints, try it out!
VS Code Extension: https://marketplace.visualstudio.com/items?itemName=AndrePimenta.claude-code-chat
Github: https://github.com/andrepimenta/claude-code-chat

reactsaas · 1 year ago

its really a must . I wont pollute my commit history with random "better save now because its risky " commit . Thats just a crutch in my oppion . Cursor does it perfectly with its restore checkpoints. Once this is added I will be onboard .

thinknirmal · 1 year ago

Lack of checkpoints is frustrating. This is probably the time to introduce a GUI where adding buttons makes sense.

Crazytieguy · 1 year ago

It looks like spamming the esc key lets you go back in the conversation now. This is already nice even without the file system checkpointing

nickjanssen · 1 year ago

Something similar to git rebase -i would be cool, where you can unselect any recent messages (and replies?) you don't want to keep.

MichielMAnalytics · 1 year ago

Worktrees allow for Parallelization now. amazing! see https://docs.anthropic.com/en/docs/claude-code/common-workflows

aaronlippold · 1 year ago

I’m glad they appreciated my suggestion

--------
Aaron Lippold

@.***

260-255-4779

twitter/aim/yahoo,etc.
'aaronlippold'

On Fri, Jun 27, 2025 at 03:11 MichielMAnalytics @.***>
wrote:

MichielMAnalytics left a comment (anthropics/claude-code#353) <https://github.com/anthropics/claude-code/issues/353#issuecomment-3011949687> Worktrees allow for Parallelization now. amazing! see https://docs.anthropic.com/en/docs/claude-code/common-workflows — Reply to this email directly, view it on GitHub <https://github.com/anthropics/claude-code/issues/353#issuecomment-3011949687>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AALK42DOYPPW5LJPNAECUGL3FTVAXAVCNFSM6AAAAABYNFGVHKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTAMJRHE2DSNRYG4> . You are receiving this because you commented.Message ID: @.***>
tekacs · 1 year ago

This is a Gemini CLI feature, where you can /chat save <name> and then /chat resume <name> within the same session, using their checkpointing functionality.

AizenvoltPrime · 1 year ago

I think the way the checkpoint should work is that when you hit double ESC to go back to previous prompt in the conversation, the changes made after that point you went back to should be reverted.

lukedays · 1 year ago

Please add this!! With this feature and Windows support (WSL is too slow in my PC), I would switch from Cursor.

AniruddhS24 · 1 year ago

Please add this feature. Would be highly useful

RonitSachdev · 1 year ago

i made a tool called ccundo that is around this issue!
be sure to check my profile!

RonitSachdev · 1 year ago
This is something we're thinking about! How would you imagine it working?

@ashwin-ant I made the tool myself, feel free to use the npm package, its called ccundo!

Crazytieguy · 1 year ago

Something I really wish I had — in addition to going back to one of my previous messages, go back to an arbitrary Claude message. Sometimes Claude works for a long time without my supervision, and there's a moment where it started going in the wrong direction and I wish I was there to interrupt it. Could be an extra key press after esc+esc

D-Squared70 · 1 year ago

+1 add please

0-hero · 1 year ago

+1

homestakes · 1 year ago

@ashwin-ant Any rough idea of when we might see checkpoint functionality in CC? Thanks!

sm1899 · 1 year ago

+1

alandolsi · 1 year ago

I’d like to add a strong +1 to this request.

In day-to-day engineering work, the ability to preview, accept/reject, and roll back AI-generated changes is essential for maintaining code quality and confidence. GitHub Copilot sets a solid precedent here: every suggestion is presented as a clear diff, which can be staged selectively, rejected wholesale, or reverted later with a single click. That workflow keeps experimentation safe while letting developers see exactly how each suggestion affects the codebase.

Claude already excels at generating clean, context-aware code, but without fine-grained undo/checkpoint support many of us hesitate to integrate it into larger projects or CI pipelines. A built-in, version-aware undo mechanism would:

Reduce cognitive load – no need to stash or manually track snippets just in case we change our minds.

Boost trust and adoption – teams can experiment freely, knowing they can always revert.

Align with modern DevOps practices – mirroring the diff-based, review-centric approach developers are accustomed to.

In short, this is not a “nice-to-have” UX polish; it’s a foundational feature that unlocks safe, iterative collaboration with AI. I hope it can be prioritized soon.

ramathornn · 12 months ago

+1

francescomugnai · 12 months ago

+1

arnavpraneet · 12 months ago

+1

gosuto-inzasheru · 12 months ago

manually /saveing is cumbersome. i want to be able to always go back to step n, where every time i prompt a number is assigned automatically

caramale07 · 11 months ago

+1

gosuto-inzasheru · 11 months ago

just hit esc twice

sedghi · 11 months ago
just hit esc twice

I like your confidence

alwynmathew · 11 months ago

+1

betteroneday · 11 months ago

+1

Jerry-Chang975 · 11 months ago

+1

chiminhtathoj · 11 months ago
  • 1
r-Kai-dev · 11 months ago

+1

nthtrung09it · 11 months ago

+1

waylonwang · 11 months ago

+1

manikv12 · 11 months ago

+100

mateenmotavaf · 11 months ago

+1

SebasScript · 11 months ago

+1
cusor developed a pretty neat version of it as will already know, will be harder to do in cli, but maybe one option is that checkpoints are created before (only needed before first edit in the current session) and after each edit, then there is a slash command to view all checkpoints in the current session with short auto generated summary of the edit, selecting the edit would ideally show two options, revert to to check point and show edits which would show the full list of changes it made previous, like claude code is allreayd doing when making edits,

austinmw · 11 months ago

I feel like the principle of least surprise would follow that the double-escape functionality to browse through previous user inputs would revert to that checkpoint when editing/resubmitting a previous msg? That was my expectation anyway...

RabbaniF22 · 11 months ago

+1

amxv · 11 months ago

+1. This is one of those instances where Cursor nailed the UX. Just copy their implementation and take a file system snapshot at every user message. Double esc should always default to restoring both the prompt + file state at that point of the conversation (that's what most new users expect anyway).

I don't like the idea of telling Claude to make a commit at every message. I don't want to use git operations in a hook for this and pollute my git history either - both solutions feel really hacky.

Maybe using rsync? Does anyone have a working UserPromptSubmit hook they can share as a temporary workaround?

Thanks :)

bauersimon · 11 months ago

+n

ohmaseclaro · 11 months ago

only reason I pay 200$ cursor ultra and not to claude code is the lack of this feature.

manikv12 · 11 months ago

Agree

momadacoding · 11 months ago

I command it to roll back the last change, but Claude Code discarded my whole day's work! It's all in one file, it just reverted to the last git commit

flow-ryan · 11 months ago

strong +1. Main thing I go back to cursor for

dddraxxx · 11 months ago

Need it so bad. Have to cancel my Claude Max subscription for lack of this feature

coygeek · 11 months ago
mrestrepoj10 · 11 months ago

Any news or plans on this ?

p32929 · 10 months ago

Hi, I actually have created this package for this very reason: https://github.com/p32929/ccheckpoints or https://www.npmjs.com/package/ccheckpoints
Feel free to give it a try. Thanks

CharlieJCJ · 10 months ago

Would really want this feature natively

liuzsen · 10 months ago

Maybe a command /checkout like git checkout can do the trick

tjx666 · 10 months ago
tjx666 · 10 months ago

checkpoint featue = code changes undu + chat history undo.

This is not a thing can be fixed only by git commit.

Checkpoink like a time machine.

It's much better than you to ask it to revert the code.

undo better than fix.

dddraxxx · 10 months ago

anyone had to stop Claude subscription for this? Why 6 months past and still no response

nengelmann · 10 months ago

+1

adeel-rana · 10 months ago

Do you know if there is any progress on this suggestion?

ramathornn · 9 months ago

You guys are the best! Thank you for releasing the feature: https://www.anthropic.com/news/enabling-claude-code-to-work-more-autonomously

hackyon-anthropic collaborator · 9 months ago

Hey everyone - we've just released Claude Code v2.0.0 along with Claude Sonnet 4.5, and with it we are rolling out a checkpointing feature!

You can now restore code and/or conversation in the rewind dialog by hitting Esc twice, or using the /rewind command. You can read more about it in the docs.

Please give it a spin and let us know what you think. We're always eager to hear your feedback!

xshapira · 9 months ago
Hey everyone - we've just released Claude Code v2.0.0 along with Claude Sonnet 4.5, and with it we are rolling out a checkpointing feature! You can now restore code and/or conversation in the rewind dialog by hitting Esc twice, or using the /rewind command. You can read more about it in the docs. Please give it a spin and let us know what you think. We're always eager to hear your feedback!

@hackyon-anthropic Awesome job! Thanks! But it's worth mentioning that it works only in the command line, not in the native VS Code extension.

ANogin · 9 months ago

Was this feature disabled in 2.0.1? It briefly worked for me, and now it's not there? And does not seem to be in settings anymore?

github-actions[bot] · 9 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.