How to undo what a coding agent changed
Claude Code can rewind the files it edited, Gemini CLI can restore a checkpoint if you switched checkpointing on, Codex's documentation points you to git, and Clixad's /undo takes back your message and names the files that changed without reverting them.
No agent's undo reaches what a command did outside the files it tracks: a migration, an install, a push. A branch or a worktree per task, with a commit before you start, is the undo that covers everything an agent writes, whichever agent wrote it.
What each agent can take back
| Agent | How | What comes back | What does not |
|---|---|---|---|
| Claude Code | /rewind, or Esc twice on an empty prompt | Files Claude edited, the conversation, or both | Files only a shell command changed |
| Gemini CLI | /restore, once checkpointing is switched on | The project's files as they were before an approved edit | Anything, if checkpointing was off |
| Codex | Git, as its CLI page advises | What you committed | What you did not |
| Clixad | /undo | Your last message, back in the input box | Files, and the credits the turn used |
Claude Code keeps checkpoints: "A checkpoint is a restore point for the files Claude edits." and "Every prompt you send that starts a turn creates a new checkpoint." You "Run /rewind, or press Esc twice when the prompt input is empty, to open the rewind menu", and choose to restore the code, the conversation or both. The documentation is direct about the gap: "A file that only Bash commands changed isn't tracked and stays as it is. To revert it, use version control, such as Git." It also warns that "restoring code can discard changes you or another session made to that file after the selected checkpoint."
Gemini CLI can do something similar, but its checkpointing is off until you switch it on in
settings.json. Then a checkpoint is made when "you approve a tool that modifies the file system (like
write_file or replace)", stored as "A commit is made in a special, shadow Git repository located in your home
directory", and /restore lists the checkpoints and restores one. It does not touch your own
repository's history.
Codex's CLI page gives the advice that holds for every agent: "Create Git checkpoints before and after a task so you can revert changes."
Clixad's /undo takes your last message back into the input box, so you can change
it and send it again, and cuts the conversation before it. It does not restore files. It says so every time,
names the files the agent wrote or edited for that message, and counts the commands it ran. The credits the turn
used stay spent. If you come from Claude Code, where Anthropic lists /undo as another name for
/rewind, that difference matters.
What no undo reaches
Every agent's undo works on files, and only on files it was tracking. A command runs in the world outside them. None of these come back through an agent's undo, and most do not come back through git either:
- A database migration that ran, or rows a script deleted.
- Packages installed globally, or a system setting changed.
- Files outside the project, which neither the agent's checkpoints nor your repository know about.
- Anything sent over the network: a push, a deploy, a message, a call to a paid API.
- A file that was never committed and that a command deleted. Git cannot give back what it never had.
That is the reason to read a command before you approve it, and the reason modes that skip approvals belong in a container. Permission modes in coding agents compares what each agent asks about.
A git routine around an agent task
Git is the undo that covers everything an agent writes into a repository, whichever agent wrote it. Five habits make it work.
- Start from a clean tree. Run
git status. Commit what you have, or put it aside withgit stash, which git describes as for when "you want to record the current state of the working directory and the index, but want to go back to a clean working directory." - Give the task its own branch.
git switch -c agent/fix-date-parsing. Throwing the attempt away is thengit switch mainandgit branch -D agent/fix-date-parsing. - Or its own directory. "A git repository can support multiple working trees, allowing you to check out more than one branch at a time."
git worktree add -b agent/fix-date-parsing ../repo-fixgives the agent a separate checkout to work in, while yours stays as it was.git worktree remove ../repo-fixclears it away. - Commit as you go. After each step that works,
git add -Aandgit commit -m "checkpoint: parser handles ISO dates". Each commit is a point you can return to, and unlike a session's checkpoints it is still there next week. - Review before you keep it.
git diff --statshows which files changed,git diffhow.git restore path/to/filetakes back the changes to one file you have not staged, andgit clean -nlists new untracked files the agent created, beforegit clean -fremoves them.
Undo in Clixad, step by step
- Take back what you asked:
/undo. The message comes back into the input box as you typed it, and the saved session is cut to match, so resuming it later starts from the same place. - Take back the files: git, using the list of files
/undoprints. - Stop before it goes further: Esc stops a turn at once, and n in a permission dialog refuses one step and lets the agent find another way.
- Change nothing until you have seen a plan: plan mode, with Shift+Tab.
Our docs on /undo cover the details, including what happens when the message was refused before any work was done.
FAQ
How do I undo changes made by Claude Code?
Run /rewind, or press Esc twice on an empty prompt, and choose to restore the code, the conversation or both. Claude Code's checkpoints cover files Claude edited, not files that only a shell command changed; for those, use git.
Does Codex have an undo?
Its CLI page advises creating git checkpoints before and after a task so you can revert changes. Commit before you start, and the commit is the undo.
Does Clixad's /undo revert files?
No. It takes your last message back into the input box and cuts the conversation before it. The files the agent changed stay changed, and it names them so you can revert them with git.
Is git enough to undo what an agent did?
For files in the repository, yes, if you committed before the task. It does not reach a database a migration changed, packages installed outside the project, anything sent over the network, or an untracked file a command deleted.
What is a git worktree, and why use one for an agent?
A second working directory attached to the same repository, on its own branch. The agent works there while your own checkout stays as it was, and removing the worktree throws the attempt away.
Sources
- Anthropic, Checkpointing, for "A checkpoint is a restore point for the files Claude edits.", "Every prompt you send that starts a turn creates a new checkpoint.", the rewind menu and its options, /undo as an alias of /rewind, the sentence on Bash commands, and the warning about other changes. Read 2 December 2026.
- Google, Checkpointing, for checkpointing being off by default, when a checkpoint is made, the shadow Git repository and
/restore. Read 2 December 2026. - OpenAI, Codex CLI, for "Create Git checkpoints before and after a task so you can revert changes." Read 2 December 2026.
- Git, git-worktree, for "A git repository can support multiple working trees, allowing you to check out more than one branch at a time." Git, git-stash, for when to use it. Both read 2 December 2026.
- What Clixad's
/undodoes and says: the source of the command line tool at github.com/clixad/cli, and our docs.