Lesson 4 · Git workflow in the age of agents
Read the diff as if it will break production
Swap roles: an AI agent opened a PR in your sandbox, and you’re the reviewer. About 30 minutes.
Today’s win: you’ll find real problems in an agent’s PR, leave line comments and a suggested fix on GitHub, submit a review, and learn the one GitHub rule that affects solo developers who work with agents.
What a review is
A review is a set of comments plus one decision. GitHub has three: Decision wording: GitHub Docs, “About pull request reviews”. Steps: “Reviewing proposed changes in a pull request”.
| Decision | Means | gh pr review |
|---|---|---|
| Comment | “Leaves general feedback without explicitly approving or requesting changes.” | --comment -b "…" |
| Approve | “Signals that the changes are ready to merge.” | --approve |
| Request changes | “Flags feedback that the author should address before merging.” | --request-changes -b "…" |
On GitHub you add line comments from the Files changed tab. Hover over a line, click the blue +, write your comment, and click Start a review. Those comments are drafts: “Before you submit your review, your line comments are pending and only visible to you.” Nothing reaches the author until you click Submit review. Two extras are worth using. A suggestion is a block containing the exact replacement code, which the author can commit with one click. Viewed checkboxes track which files you’ve finished reviewing. “If the file changes after you view the file, it will be unmarked as viewed.”
What to look for
Google’s public code-review guide is the most widely cited checklist. These four questions catch most problems in agent PRs: Quotes: Google Engineering Practices, “What to look for in a code review”. The guide also covers design, complexity, naming, and comments.
- Functionality: “Does this CL do what the developer intended?” Compare the code with the task and with the PR description. Agents often describe what they meant to do, not what the code actually does.
- Scope: does every changed file belong to this task? Look at the file list before reading any code.
- Tests: “Will the tests actually fail when the code is broken?” A test that can’t fail only makes the PR look tested.
- Every line: “look at every line of code that you have been assigned to review.” That includes leftover debug output.
“Reviewing means reading the code.” Reading is only part of it. You can also run the code. gh pr checkout puts the PR on your laptop in one command. One concrete input that gives the wrong answer is worth more than a lot of reading.
Warm-up: spot the issues
An agent was asked to “add retries to fetch_user”. Click every line you would comment on, then press Submit review. There are three planted problems.
Review a real agent PR
I opened PR #6 in your sandbox, acting as an agent. It was given this task: “Add a small script that counts the words in a text file.” The PR has at least four problems. Your job is to find them and report them as a reviewer would.
-
Read the task and the description first
cd ~/Work/git-sandbox git switch main && git pull gh pr view 6Note what the description claims. You’ll check each claim against the code.
-
Check scope: which files changed?
gh pr diff 6 --name-only gh pr diff 6Before reading the code, ask whether every file in that list belongs to a word-count task.
-
Run it: predict, then test the description’s claims
gh pr checkout 6 python3 -c "from wordcount import count_words; print(count_words('one two three'))" python3 -c "from wordcount import count_words; print(count_words('one\ntwo'))" python3 wordcount.py README.md git switch mainWrite down the correct answer for each input before you run it. The first input has two spaces after
one.gh pr checkoutcreates a local branch with the PR’s commits, so you’re testing exactly what would be merged.gh pr checkout: gh manual. -
Leave line comments on GitHub, including one suggestion
gh pr view 6 --webOpen Files changed. For each problem, comment on the exact line, then click Start a review (and Add review comment after that). Say what’s wrong and why it matters. For at least one problem, click the suggestion icon (±) and write the fixed line. Tick Viewed on each file when you’re done with it.
-
Submit, and find GitHub’s self-review rule
Click Review changes, write a one-line summary, and try to choose Request changes. You’ll find you can’t. Submit it as Comment instead. Then try to approve from the terminal:
gh pr review 6 --approveThat fails too. “Pull request authors cannot approve their own pull requests.” I pushed this PR with your
ghlogin, so GitHub sees you as its author. Quote: GitHub Docs, “Approving a pull request with required reviews”. The same page says you can’t approve a PR that Copilot raised if you were the one who assigned the task to Copilot. -
Get graded, then have the agent fix it
In Claude Code, say “check my review on PR #6”. I’ll read your comments through the GitHub API and tell you which planted problems you caught and which you missed. Then say “address the review”, and I’ll push fix commits as the agent. Next, re-review: GitHub unticks Viewed on every file that changed, so you can see what to look at again. Finish with
gh pr merge 6 --merge --delete-branchand syncmain.
The solo-agent catch: when an agent uses your gh login, every PR it opens is your PR. You can’t formally approve it, and a rule like “require one approval before merging” would block you on your own repo. For now, your review is a Comment followed by your merge. Lesson 5 covers the alternatives: required checks, rulesets, and giving agents their own identity.
Recall it
No scrolling up. Spaced review: retry the Lesson 3 quiz and its Drill 3 before this one.
Go deeper
Primary source: Google, “What to look for in a code review” (about 10 minutes). Then read “How to write code review comments” for wording comments that get acted on.
Reference: Cheat sheet (new review section) · Glossary.
Not sure whether something is worth a comment, or how to word one so an agent acts on it? Ask me in Claude Code. I’m playing the agent this time, so I can also show you how I read your comments.