Skip to content
New — orchestrate a team of Mel agents from your terminal. Learn more about orchestrating Mel agents
Mel
← All articles

Mel – the agentic terminal
The agentic team for coding.

How to undo what an AI coding agent changed

November 21, 2026 · 5 min read

Share
In short
  • Mel shows every change three times: on the approval card, as a diff card, and in the code review panel.
  • Undo takes back one change, Discard reverts one file, and Discard all reverts every tracked change.
  • A worktree or a commit before each task makes undo easy every time.
  • Force-push, git reset --hard and deletes outside the project always wait for your approval.

To undo what an AI coding agent changed, use git. In Mel – the agentic terminal (openmel.dev), open the code review panel with Ctrl+Shift+= (⌘⇧= on a Mac): Undo takes back one change, ↩ Discard reverts one file, and ↩ Discard all reverts every tracked change after you confirm. Files the agent created are untracked, so you discard them one by one from their cards. The safest setup is to stop bad changes before they happen: Mel shows every edit as a diff on an approval card before it is written, and some steps, like git push --force or git reset --hard, always wait for you.

This guide covers the three moments you can catch a bad change, how to undo each kind of change, how to set up a project so undo is always easy, and what to do outside a git repository.

The three moments to catch a bad change

Mel shows every change the agent makes three times:

WhenWhereWhat you can do
Before it is writtenThe approval cardRead the exact diff, then allow or deny it
Just after it is writtenThe diff card in the conversationSee the file, the +N and -N counts and the changed lines
Before you commitThe code review panelAccept, undo, discard, comment or commit, per change or per file

The earlier you catch it, the less there is to undo. See reviewing the agent's changes.

How to undo agent changes in Mel

  1. Open the code review panel. Click ± Review changes under the turn that edited files, press Ctrl+Shift+= (⌘⇧= on a Mac), or run Open Code Review from the command palette.
  2. Undo one change. On a change inside a file, Undo takes that one change back out of your files, and Accept stages it instead.
  3. Revert one file. ↩ Discard on a file's card runs git restore for a tracked file. For a file the agent created, it deletes that file.
  4. Revert everything. ↩ Discard all in the header asks once more, then runs git restore .. It reverts tracked changes only and never bulk-deletes untracked files.
  5. Ask the agent to fix it instead. Hover a line, click 💬, write what is wrong, and send your comments to the agent.

If a file changed since the panel loaded its diff, Mel refuses the click, says so and refreshes the panel, so you never undo the wrong version. See the code review panel.

What about changes the agent already committed?

Mel's review panel works on uncommitted changes. For a commit, use git in the terminal, where you can see each command before it runs:

You want toCommandSafe?
Undo a commit and keep a recordgit revert <commit>Yes, it adds a new commit
See what a commit changedgit show <commit>Yes, it only reads
Move a branch back and throw away workgit reset --hard <commit>No, it cannot be undone

If the agent itself wants to run git reset --hard, git push --force or another command Mel recognises as impossible to undo, it always stops for your approval, even in hands-off mode. See tools and approvals.

Set up a project so undo is always easy

  • Work in a git repository. The review panel needs one. Outside one, you still get the approval card and the diff cards, but no one-click undo.
  • Commit before you hand off a task. Then git restore . or ↩ Discard all takes you back to a known point.
  • Give the agent its own worktree. In Mel, choose Track this repo for worktrees, then Worktree: your-repo from the + new-tab menu. The agent works on its own branch in its own folder. If you don't like the result, you delete the branch, and your main folder was never touched. See projects and folders.
  • Keep "Always allow" short. "Always allow" lasts for one conversation and one kind of step. A new conversation asks again, and typing /always-ask makes the current one ask again.

What Mel never lets the agent do without asking

Whatever your settings, these always wait for you:

  • a command Mel recognises as impossible to undo, such as a recursive delete outside the project, git push --force, git reset --hard, sudo, a script piped from the internet into a shell, or publishing a package
  • reading a file that holds credentials, such as an .env file, or running a command that names one
  • writing outside the project
  • using a connector or an MCP server

Those steps need a click or Ctrl+Enter (⌘Enter on a Mac). Pressing Enter alone does not approve them. The full list is in security and privacy.

Frequently asked questions

Can I undo everything the agent did? In a git repository, yes: ↩ Discard all in the code review panel reverts tracked changes. Files the agent created are untracked, so discard them one by one from their cards.

Does Discard all delete new files? No. It runs git restore ., which reverts tracked files only. Delete new files one by one with ↩ Discard on each card.

Can I undo just one change inside a file? Yes. Undo on a change takes back that one change and leaves the rest of the file as it is.

What if I'm not in a git repository? You still see every edit on the approval card before it is written and as a diff card after. There is no one-click undo, so read each card before you allow it, or run git init and commit first.

Can the agent force-push or delete files without asking? No. Force-push, git reset --hard and deletes outside the project always wait for your approval, whatever you set.

Does the VS Code extension show diffs too? Yes. Each changed file gets a card, and Open diff opens it in VS Code's diff editor.

Try it

Download Mel, commit your work, and hand the agent a task in its own worktree. When it is done, open the review panel and keep only what you want. For more, read how to keep an AI coding agent under control.

Mel – the agentic terminal · openmel.dev. The agentic team for coding.

Found this useful? Share it with your team.
Share
Lalla Asmaa Alaoui
Written by
Lalla Asmaa Alaoui
Founder & CEO of Mel

Lalla is a hands-on tech founder, agentic infrastructure architect and the vision behind Mel.

Follow on LinkedIn

Get started

Try the agentic terminal for teams.

The Mel terminal is free to download, no account needed. The AI agent is free on your own provider key — 1,500 hosted-AI credits a month on Pro.