How to review changes made by an AI coding agent
Updated · Every command on this page ran in our practice shell
Short answer
Before you accept an AI agent's work, run git status to see every file it touched (new files too), git diff --stat for the size of each change and git diff to read every line. If it committed on a branch, review the range: git log --oneline main..HEAD and git diff main...HEAD. Search new files for secrets with grep, and look for deleted or weakened tests and edits it didn't mention.
Coding agents are fast and confident, and their summaries don't always match their diffs. An agent asked to "add discount codes" might also delete a failing test or paste a key into a config file. Git already has everything you need to check. The examples below use a small kiosk app after an agent session.
Start with git status
git status lists every file the agent modified, deleted or created. Compare it with what the agent said it did. Here it says "added discount codes", but it also changed config.js and deleted a test.
learner@shellstreak:~/kiosk$ git status -s M src/cart.js M src/config.js D tests/cart.test.js ?? src/discount.js
Size up the change with git diff --stat
--stat shows how many lines changed in each file. A huge change in a file that should have needed one line is a sign to look closer.
learner@shellstreak:~/kiosk$ git diff --stat src/cart.js | 7 +++++-- src/config.js | 1 + tests/cart.test.js | 5 ----- 3 files changed, 6 insertions(+), 7 deletions(-)
Read the actual lines with git diff
Then read the diff itself, file by file: git diff path. Lines with + are new. Look for hardcoded secrets, disabled checks, loosened permissions and commented-out code.
learner@shellstreak:~/kiosk$ git diff src/config.js diff --git a/src/config.js b/src/config.js index 1d95086..415f54c 100644 --- a/src/config.js +++ b/src/config.js @@ -1,2 +1,3 @@ export const API_URL = "http://localhost:8080"; export const TIMEOUT_MS = 5000; +export const API_KEY = "sk-test-placeholder";
Scan only the added lines
For a quick sweep of a large diff, filter to added lines with grep. Searching for words like key, token, password, rm -rf or skip finds most problems fast.
learner@shellstreak:~/kiosk$ git diff | grep '^+' +++ b/src/cart.js +import { applyDiscount } from "./discount.js"; + +export function total(items, code) { + const sum = items.reduce((sum, item) => sum + item.price * item.qty, 0); + return applyDiscount(sum, code); +++ b/src/config.js +export const API_KEY = "sk-test-placeholder"; +++ /dev/null
Search new files for secrets too
git diff doesn't show untracked files at all, and a scratch file is exactly where an agent leaves a key. List new files with git status --porcelain (they start with ??), then search the folders, not the diff: grep -rnE 'sk-|AKIA|ghp_|PRIVATE KEY|password' src scripts. A scanner such as gitleaks, run in a pre-commit hook, does this on every commit. If a key was ever committed or pushed, revoke and rotate it first; deleting it from git doesn't un-leak it.
learner@shellstreak:~/kiosk$ git status --porcelain && grep -rnE 'sk-|AKIA|ghp_|PRIVATE KEY|password' src M src/cart.js M src/config.js D tests/cart.test.js ?? src/discount.js src/config.js:3:export const API_KEY = "sk-test-placeholder";
Watch for new and deleted files
Then run the tests yourself, with the project's script: sh scripts/test.sh (sh runs it with the shell). Read new files in full with cat. Deleted or weakened tests (.skip, .only, expect(true), a hard-coded expected value) are a classic agent shortcut for making a failing build pass.
learner@shellstreak:~/kiosk$ cat src/discount.js export function applyDiscount(total, code) { return code === "BREAD10" ? total * 0.9 : total; }
If the agent committed: review the whole range
Agents that commit as they go should do it on their own branch. Review everything since that branch left main: git log --oneline main..HEAD lists the commits, and git diff main...HEAD shows the combined change (add --stat for a summary). git log --format=%s main..HEAD prints just their subjects. Don't sort commits by the Author: line: agents usually commit with your name and email, and the author can be set to anything.
learner@shellstreak:~/kiosk$ git log --oneline main..HEAD && git diff --stat main...HEAD bd00b40 (HEAD -> agent/discounts) Speed up test script edc216d Add discount codes scripts/test.sh | 1 + src/cart.js | 7 +++++-- src/discount.js | 3 +++ tests/cart.test.js | 5 ----- 4 files changed, 9 insertions(+), 7 deletions(-)
Check that the message matches the change
A commit called Speed up test script should only touch the test script. This one also deleted a test file. When the message and the diff disagree, trust the diff.
learner@shellstreak:~/kiosk$ git show --stat commit bd00b40f4cc060e4428fb9bf50b83645fc3fbdbf (HEAD -> agent/discounts) Author: You <you@example.com> Date: Sun Mar 1 09:40:00 2026 +0000 Speed up test script scripts/test.sh | 1 + tests/cart.test.js | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-)
Check yourself
One real exercise from the “Supervising an AI coding agent” unit. No account needed.Here the agent staged its edits. Show a per-file summary of what's staged.
What's checked: the output of your last command.
Common mistakes
Reading the agent's summary instead of the diff.
Running only
git diffand missing new files, which onlygit statusshows.Approving a commit that deletes or skips tests "to make the build pass".
Letting a hardcoded key reach a commit. Even if a later commit removes it, it stays in the history.
Trusting the
Author:line to tell you which commits the agent made. Review by range instead.
Questions
Should I let an AI agent commit on its own?+
It's fine on a separate branch, as long as you review every commit before merging. Keep it away from pushing to shared branches.
What if the agent's change is mostly good but has one bad file?+
Undo just that file with `git restore file` (uncommitted) or `git restore --source=HEAD~1 file` (committed), and keep the rest.
How do I see everything an agent did across several commits?+
If it worked on a branch, `git diff <base>...HEAD`, for example `git diff main...HEAD --stat`, then drop `--stat` to read the lines. Without a branch, diff from the last commit before the session: `git diff <hash> HEAD`.
How do I stop an agent from pushing straight to main?+
Turn on branch protection on the server (GitHub, GitLab and others have it): require a reviewed pull request, block force-pushes and deletion. Then give the agent credentials that can only push its own branches.
Reading is step one. Now make it stick.
Practise this in a five-minute lesson with instant feedback. No account needed.