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

Guides · AI coding agents

How to review an AI agent's code changes

By Lalla Asmaa Alaoui, founder of Mel · Updated

Start every agent task from a clean git tree, so that afterwards git diff shows exactly what the agent changed and nothing else. Then read the diff, run the tests yourself, and commit only the parts you would have been happy to write.

An agent's summary tells you what it meant to do. The diff tells you what it did. Reviewing the diff is the habit that makes agents safe to use on real projects, whichever tool or model you use.

Steps

  1. Start clean. Before you hand over a task, commit or stash your own work.
git status
git stash push -u -m "my work before agent task"

-u includes new files. If git status says "nothing to commit, working tree clean", you are ready.

  1. Give the agent its own branch.
git switch -c agent/fix-login-timeout

If the result is bad, you can switch back and delete the branch. main never changed.

  1. Let the agent work, then get the overview.
git status
git diff --stat

Check the list of files. Is every file one you expected? A change to a lockfile, a CI config, or a file far from the task deserves a closer look.

  1. Read the whole diff.
git diff

New files do not appear in git diff until they are staged. Open them, or run git add -N . first so git diff includes them.

  1. Look for the usual problems. Agents tend to make the same kinds of mistakes: - Tests that were changed or deleted to make them pass. - Error handling that hides a failure, such as an empty catch. - New dependencies you did not ask for. - Secrets, tokens or local paths written into files. - Unrelated "clean up" edits that make the diff bigger. - Code that duplicates something the project already has.
  1. Run the checks yourself. Do not rely on the agent saying they passed.
npm test
npm run lint

Use your project's own commands, such as pytest, cargo test or go test ./....

  1. Keep what you want, drop the rest. Stage piece by piece:
git add -p

Discard a file you do not want with git restore path/to/file, and delete unwanted new files.

  1. Read what you are about to commit, then commit.
git diff --staged
git commit -m "Fix login timeout on slow networks"
  1. Bring back your own work.
git stash pop

For bigger changes

  • Compare the branch with main: git diff main...HEAD shows everything the branch added.
  • Ask for small commits. Several small, focused commits are far easier to review than one big one.
  • Open a pull request, even if you work alone, so the diff is reviewed in one place with CI.

Doing it with Mel

Mel builds this review loop into the terminal.

While the agent works. Mel's approvals let you decide which edits and commands need your yes. With approvals on, each change shows on an approval card before it happens, with Allow, Always allow and Deny. Every applied edit shows as a diff card in the conversation, with the file path and the lines added and removed.

After it finishes. Press ctrl+shift+= (cmd+shift+= on macOS), or click Review changes under an agent turn that edited files. The code review panel opens beside the terminal with every uncommitted change as a card per file, including new files. You can switch the base to compare against another branch, open a file in Mel's editor, or Discard a file's changes.

Send fixes back. Hover a line in the review panel and click the comment button to leave a note. When you are done, Send to Agent turns all your notes, with their file, line and code, into one prompt for the agent. Then review the new diff the same way.

When a team of agents works on one task, they edit the same checkout, so the review panel shows the team's combined output in one place.

FAQ

How do I see exactly what an AI agent changed? Start from a clean tree, then run git status and git diff after the task. Use git diff --stat for a quick list of files.

Should I trust an agent when it says the tests pass? Run them yourself. It takes a minute and catches the cases where tests were skipped, changed or never run.

What should I look for in an agent's diff? Changed or deleted tests, swallowed errors, new dependencies, secrets in files, and edits outside the task.

How do I undo an agent's changes? If you started clean, run git restore . for tracked files and git clean -n then git clean -f for new ones. If it worked on its own branch, switch away and delete the branch.

Is it OK to let an agent commit for me? Yes, once you have read the diff. Commit messages are cheap to fix; unreviewed code is not.

Mel – the agentic terminal · openmel.dev. A multi-agent, multi-model AI terminal for Mac, Windows, Linux and VS Code. Free with your own API key.

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.

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.