Sub topic 14
Reviewing What the Agent Did: Diffs, Logs, and Version Control
This chapter assumes you can use git on the command line, know the allow, ask, and deny decisions from earlier chapters, and have run a coding agent that edits files. Permissions limit what an agent may do. Review checks what it actually did. You need both, because rules can be too loose and approvals get skimmed.
Why review is a separate control
Approval prompts happen before an action, and you often see only a short command or a partial edit. Review happens afterward, with the whole result in front of you. It also catches problems that no rule describes, such as a correct-looking change that alters behavior.
Review matters most in the modes where you approve less. If the agent can edit files without asking, the diff becomes your main check.
Start from a clean state
Before a session, commit or stash your own work. A clean working tree means every change in the next diff came from the agent. A branch gives you a cheap way to throw the whole session away.
git status --short
git switch -c agent/fix-login-bugIf git status prints anything, deal with it first. Otherwise you cannot tell your edits from the agent's.
Read the diff
After the session, look at the summary first, then the details.
git status --short
git diff --stat
git diff--stat shows which files changed and how many lines. Check it against what you asked for. A request to fix one function that touched a config file, a lockfile, or a CI workflow deserves a closer look.
Untracked files do not appear in git diff. Use git status to find new files, and read them too. Files the agent created outside the repository will not show up here at all, so the diff is only complete for work inside the workspace.
What to look for
- Changes outside the scope you requested.
- Edits to sensitive files: CI workflows, build scripts, dependency manifests,
.envfiles, and the agent's own settings. - New dependencies or new network calls.
- Deleted tests, loosened assertions, or skipped checks.
- Hard-coded tokens or URLs.
Use logs for non-file actions
A diff shows file changes only. Commands that ran, network requests, and tool calls to external servers leave no trace in it. Many agents keep a transcript or session log of tool calls. Check what your tool provides, where it stores it, and whether it records command arguments. Where the tool provides no log, shell history or a wrapper script can fill the gap.
Commit in small steps
Large diffs get skimmed. Commit after each reviewed step, so the next diff holds only new work. Use git add -p to stage hunks one at a time and read each one.
git add -p
git commit -m "Fix login redirect"To undo an unwanted change, restore the file or discard the branch.
git restore path/to/file
git switch main && git branch -D agent/fix-login-bugBoth commands discard work. Check git status before running them.
Common errors
- Reviewing only the files you expected. Run
git statusand--statto see the rest. - Trusting the agent's own summary. It describes intent, and the diff shows the result.
- Running tests only. Tests the agent edited can pass while the behavior is wrong.
- Reviewing after pushing. Review before the commit leaves your shared history.
Exercise
You ran an agent in auto-edit mode on a clean branch, and git diff shows only the one source file you expected. Name two reasons you should still not conclude the session did nothing else.
Show answer
New untracked files do not appear in git diff, so you must check git status. Commands the agent ran, network requests, and changes outside the repository leave no trace in the diff, so you need the session log or other records to see them.