How to undo Claude Code changes: rewind, git, checkpoints

Undo Claude Code changes with /rewind, git or AgentVera checkpoints: what each one restores, what it misses, and how to roll back one agent turn safely.

Solviera Teknoloji 6 min read

To undo Claude Code changes, use /rewind for edits made in the current session, git for anything you committed or can restore from the repository, and AgentVera checkpoints when you want to roll the whole working folder back to the start of a specific agent turn. Each one covers a different gap. Knowing which one to reach for saves you from losing work while undoing the agent’s.

This guide compares the three, shows the exact steps for each, and lists what each one misses. That last part is usually what bites.

The short answer

You want to undoUseWatch out for
The last few edits in this Claude Code session/rewind or Esc twiceShell command changes aren’t tracked
Changes to one tracked filegit restore <file>Uncommitted edits in that file are gone
Everything since the last commitgit stash -u or git reset --hard + git cleanclean deletes untracked files for good
A committed changegit revert <commit>Creates a new commit that reverses it
One agent turn, including files the agent made with shell commandsAgentVera checkpointsRolls back other agents in the same folder too

Option 1: /rewind inside Claude Code

Claude Code saves checkpoints as it edits files. To go back, press Esc twice or run /rewind. You pick a message from the session, then choose what to restore:

  • Code only: files go back to how they were at that message, and the conversation stays.
  • Conversation only: the conversation goes back, and the files stay as they are.
  • Both: a clean step back to that point.

This is the fastest undo while you are still in the session, and it is the right first move when the agent just made a bad edit.

What it misses: Claude Code’s checkpoints track the edits its own file tools make. Changes made by shell commands, such as rm, mv, a code generator or a migration script, aren’t tracked. Changes from other sessions or other tools in the same folder aren’t either. /rewind is a convenience, not a replacement for version control.

Option 2: git

Git is the undo that works for every tool, as long as the work you want to keep or drop is something git can see.

# See what changed
git status
git diff

# Throw away changes to one tracked file
git restore src/api/user.ts

# Park everything, including new files, and keep it in case you need it
git stash -u

# Drop all uncommitted changes to tracked files
git reset --hard

# Delete untracked files and folders (check first with -n)
git clean -n -d
git clean -f -d

# Reverse a commit the agent already made
git revert <commit>

Two habits make git a much better undo for agent work:

  1. Commit before you start an agent on a task. Then git diff shows exactly what the agent did, and git stash -u or git reset --hard takes you back.
  2. Give each agent its own worktree. Then undoing one agent never touches another agent’s work. See Git worktrees for parallel agents.

What it misses: anything between commits. If you made your own edits in the same files while the agent worked, git reset --hard drops yours too. git clean deletes untracked files for good, so always run it with -n first.

Option 3: AgentVera checkpoints

AgentVera adds a per-turn undo that sits between the two. It works with any agent CLI that runs in a local folder, not only Claude Code.

How the snapshots work

At the start of each turn, AgentVera snapshots the agent’s working folder (its worktree, or the project folder). The snapshot covers tracked and untracked files and respects .gitignore. It is stored as a commit under a hidden ref, refs/agentvera/checkpoints/…. Your branches, index, stash and HEAD are not changed, and nothing shows up in git log or git status.

The last 60 turns are kept per agent. Deleting the agent drops its snapshots. The project has to be a Git repository. The first snapshot is taken when you send the agent a message (or type to Claude in the terminal).

Roll back a turn

  1. In the agent’s pane header, click Turns (“Turns and rollback”). In a narrow pane it is under Options.
  2. The list shows the turns newest first, each with its number, prompt and time. A turn typed directly into the terminal shows as “Turn typed in the terminal”.
  3. Expand a turn to see the files it changed, marked added, modified or deleted, with line counts.
  4. Click Roll back this turn and confirm Roll back turn.

The working folder goes back to the start of that turn. Files added after it are deleted, and changed or deleted files are restored. AgentVera then reports how many files it restored. If the agent is still working, the dialog recommends stopping it first, so it doesn’t keep editing while the folder changes under it.

Undo the rollback

Before rolling back, AgentVera saves the current state separately. It appears at the top of the list as State before the rollback. Click Return to this state to get back exactly what you had. So trying a rollback is safe. If it turns out the agent’s change was fine, you can return to it.

From your phone

If you control agents from Telegram, the agent buttons include ↩️ Undo last turn. It shows the file list and asks you to confirm. Afterwards you can still undo it from the checkpoint list on the desktop. See Telegram control.

What it misses

  • Other agents in the same folder. A rollback restores the folder, so later changes by other agents working in that folder are rolled back too. The confirmation says so. Worktrees avoid this.
  • Ignored files. Files matched by .gitignore, such as node_modules or a local .env, aren’t part of the snapshot.
  • Things outside the folder. A database the agent migrated, a package it published or a push it made aren’t files in the folder, so no folder snapshot can undo them.
  • SSH agents and plain terminals. No checkpoint is taken for agents on a remote server, because their folders aren’t on this computer.

Which one to use when

  • The agent just made a bad edit and you are still in the session: /rewind.
  • The agent ran a script that deleted or generated files: AgentVera checkpoints or git, not /rewind.
  • Several turns went the wrong way: roll back to the start of the first bad turn in Turns. You can return to the current state if you change your mind.
  • The work is committed: git revert.
  • You want a clean slate for the whole task: git stash -u or git reset --hard, if you committed before starting.

Fewer undos in the first place

Undo is the safety net, not the plan. A few habits mean you need it less:

  • Small, scoped prompts. A turn that changes three files is easy to review and easy to roll back.
  • Plan first for risky work. Have the agent describe the change before it makes it.
  • Review every turn. AgentVera’s code review can review an agent’s code at the end of every turn. AI code review covers what to look for.
  • Keep destructive commands behind approval. AI coding agent security covers permissions, Docker isolation and approvals.

Wrapping up

There is no single undo for an AI coding agent. /rewind is quick for the current session’s edits. Git covers anything it can see, best when you commit before each task. AgentVera checkpoints fill the gap between them with a snapshot of the whole working folder at every turn, a rollback you can itself undo, and the same button on your phone. The checkpoints and replay page also covers session replay, which plays a Claude or Codex session back step by step so you can see where it went wrong.

Questions

How do I undo the last thing Claude Code did?

In Claude Code, press Esc twice or run /rewind, pick the message to go back to and choose whether to restore code, conversation or both. In AgentVera, open Turns in the agent pane and choose Roll back this turn.

Why didn’t /rewind bring back a deleted file?

Claude Code’s checkpoints track the edits its file tools make. Files changed or deleted by shell commands, such as rm or a script, aren’t tracked. Use git or a folder snapshot such as AgentVera checkpoints for those.

Do AgentVera checkpoints change my branches or stash?

No. Snapshots are stored under a hidden git ref. Your branches, index, stash and HEAD are left alone. The project must be a Git repository.

Can I undo a rollback?

Yes. Before a rollback, AgentVera saves the current state as “State before the rollback”. Choose Return to this state to go back to it.

Do checkpoints work with Codex and other agents?

Yes. Checkpoints are taken for any agent CLI that works in a local folder, not only Claude Code. They are not taken for agents on an SSH server or for plain terminals.

Bring your agents to one desk.

Download AgentVera for free; your installed CLIs are ready to go.

More posts