The workflow looks like this. An agent is running in a terminal. You describe what you want, it works for forty seconds, and files change. You read what it did, decide whether it is what you meant, and either accept it or redirect.
The interesting part is not the code generation. It is that the loop has moved. You are no longer writing and then occasionally checking in with version control. You are reviewing constantly, and version control is the thing you review through.
That changes which parts of Git matter. The commands are the same. The frequency and the purpose are not.
#Commits stop being milestones
When you write code yourself, you know what changed because you changed it. A commit is bookkeeping, a marker you place when a unit of work is done.
When an agent writes code, you do not know what changed until you look. And because you do not know, the commit becomes something else: a point you can return to. It is the boundary between "state I have verified" and "state I have not".
That makes them worth taking far more often than feels justified. Three commits in ten
minutes, all called things like wip: agent added the retry logic, is not sloppy in this
context. It is a save point before something unpredictable happens.
The objection is that it makes a mess of the history. It does, and the mess is trivially
fixable. git rebase -i collapses
eleven checkpoints into three real commits in about two minutes, which we went through in the
interactive rebase guide. Committing too rarely costs you
work you cannot get back. Committing too often costs you a rebase.
#The diff is the review, not the summary
Agents narrate what they did. The narration is fluent, well-organised, and derived from what the agent intended rather than from the diff it produced. Most of the time those match. When they do not, the summary is confidently wrong, which is the worst failure mode for something you are using as a review artefact.
So the diff is the review surface. Not the summary, not the file tree, not a green check in a test runner. The actual lines that changed.
This is why partial staging matters more in this workflow than it used to. When you write
code, your working tree contains changes you chose to make and you generally want all of
them. When an agent writes code, your working tree routinely contains three changes you
asked for, one refactor you did not, and a console.log left behind from debugging.
git add -p handles this, and it handles it slowly. Walking hunk by hunk through a
four-file change with single-letter answers and no way to jump around is exactly the
friction that causes people to give up and run git add . instead. Which they then commit,
including the stray logging.
Staging directly from the diff, line by line, is the right shape for this. You see the whole change, pick the lines that belong, commit them, and discard the rest. If you have not used line-level staging before, the git add tutorial covers what it does under the hood.
#What to actually look for in an agent's diff
"Review the diff" is easy to say. The failure modes of generated code are specific enough that a short checklist catches most of them, and they are not the same failure modes as human code.
Scope creep. The single most common one. You asked for rate limiting and got rate
limiting plus a reformatted config file plus a renamed variable in an unrelated module.
None of it is wrong; none of it is what you asked for. Check git status for files you did
not expect to be touched before reading any of them.
Plausible but wrong constants. Timeouts, retry counts, buffer sizes and status codes are where a model will confidently produce a reasonable-looking number that has no basis in your system. These read as correct because they are the kind of value that varies by project.
Silently swallowed errors. A generated try block that logs and continues, where the
existing code in the same file propagates. Consistency with the surrounding code is
something models are unreliable about, and it is invisible unless you look at the file
rather than the hunk.
Tests that assert the implementation. A test written after the code, by the thing that wrote the code, frequently asserts what the function does rather than what it should do. It passes and proves nothing.
Dependencies you did not agree to. Check package.json in every diff. Adding a library
to solve a problem is a reasonable move for an agent and a decision that should be yours.
None of these require deep reading. They require looking at the right four things, which is what makes a checklist worth having: it turns review from an open-ended task into a bounded one.
| What you find in the diff | What it usually means | What to do |
|---|---|---|
| Files touched you did not mention | Scope creep | Unstage them, ask why separately |
| A timeout, retry count or buffer size changed | Plausible but arbitrary constant | Verify against the actual system, do not trust the number |
A try/catch that logs and continues | Inconsistent error handling | Compare against how the rest of the file handles errors |
| A new test that mirrors the implementation | Test asserts behaviour, not intent | Rewrite from the requirement, not the code |
A new line in package.json | Undiscussed dependency | Decide deliberately, do not accept by default |
#Guardrails that do the boring part
Review catches judgement problems. Everything mechanical should be caught before you look at it, because attention spent on formatting is attention not spent on logic.
A pre-commit hook running your formatter and linter on staged files means generated code
arrives in your house style, and diffs stop containing whitespace noise. A commit-msg
hook enforcing your convention means AI-generated messages land in the same format as
yours. And running the type checker before the commit rather than after catches the class
of error that a model produces most often, which is code that references something that
does not exist.
# .githooks/pre-commit
npx lint-staged || exit 1
npx tsc --noEmit || exit 1
The git hooks tutorial covers wiring these up so they are shared rather than per-machine.
The point is not process for its own sake. It is that when you are committing eight times an hour, anything you have to remember to check will eventually not get checked.
#Parallel agents want parallel worktrees
Once you are running more than one agent, or one agent on a long task while you work on something else, the single working directory becomes the bottleneck. You cannot let an agent refactor the auth module while you are editing it.
Worktrees solve this properly. One repository, several checked-out directories, each on its own branch, all sharing the same object database.
# A second working directory for the agent, on its own branch.
git worktree add ../app-agent -b feature/rate-limiting
# Point the agent at ../app-agent, keep working in the original.
git worktree list
git worktree remove ../app-agent
Because the object store is shared, commits made in one worktree are immediately visible in
the other, so you can review the agent's branch from your main checkout without fetching
anything. And because they are separate directories, your build and its build do not fight
over the same node_modules and dist.
This is a much better answer than the common alternative of cloning the repository twice, which duplicates the entire history and leaves you pushing between two remotes to move work around.
#The context switch tax
Here is the mechanical problem with the setup most people have.
The agent runs in a terminal, in one window. Your editor is another window. Your Git client, if you have one open, is a third. Every review cycle crosses at least two of them: agent finishes, switch to see the diff, switch back to give the next instruction.
You will do that fifty times in an afternoon.
The cost is not the two seconds of window switching. It is that each switch drops the thread. You arrive in the diff view and spend a moment remembering what you were checking for. You go back to the terminal and re-read the last instruction to remember where you were. Small, repeated, and it accumulates into the specific tiredness of an afternoon where you were busy and did not get much done.
The fix is to reduce the number of surfaces, not to switch between them faster.
#Running the agent inside the Git client
Gitoryx has a real PTY terminal embedded per repository, toggled with Cmd+J. Not a
command output pane, an actual shell, which means Claude Code,
Codex, Aider or anything else you drive from a prompt runs inside it.
That collapses the loop. The agent runs in the bottom half of the window. The commit graph and the staging view are in the top half, and they update as files change on disk. Agent finishes a task, the diff is already on screen. You tick the hunks you want, commit, and type the next instruction, without a single window switch.
It spawns your own shell as a login shell, so your prompt, aliases, PATH and whatever
version manager you use behave exactly as they do in your normal terminal rather than in
some reduced environment. That sounds like a detail and it is the difference between an
embedded terminal being usable and being a novelty.
#A concrete loop
What this looks like on an actual task.
You want rate limiting on an API endpoint. Before starting, you commit whatever you had in
progress, so HEAD is a state you trust.
You describe the task to the agent in the embedded terminal. It works for a minute and touches four files: the route handler, a new middleware, the config, and a test.
The staging view already shows all four. You read the middleware first, because that is where the logic is, and it is fine. The route handler is fine. The config change added the limit but also reformatted twenty unrelated lines, which you do not want. The test covers the happy path and not the limit being exceeded.
So you stage the middleware and the route handler in full, stage only the two added lines
from the config, and leave the test unstaged. Commit those three as
✨ add rate limiting to the export endpoint, generated from the staged diff so the
message describes what is actually in the commit rather than what the agent set out to do.
Then you tell the agent to add the missing test case. It modifies the still-unstaged test
file. You review, stage, commit as ✅ cover the rate limit rejection path.
Two clean commits. The unwanted reformatting never entered the history. Total elapsed time is a couple of minutes, and none of it was spent switching windows.
#When it goes sideways
It will. The agent misreads the task, refactors something it should not have touched, or gets into a loop where each fix breaks something else.
Because you committed a checkpoint first, the recovery is one command:
git reset --hard HEAD
If some of the work is worth keeping, stage the good hunks, commit them, and discard the rest:
git add -p # or tick the hunks in a diff viewer
git commit -m "♻️ keep the extracted validator"
git restore . # discard everything else
And if you have already committed something you regret, the undo guide covers the rest of the decision tree.
The point is that these are all cheap, and they are cheap because of the checkpoint. Without it, the same recovery means reading a large diff and reconstructing which parts were yours.
#What is actually different
The tooling has not changed. git add, git commit, git reset, git rebase -i. Every
one of them predates this workflow by a decade.
What changed is the ratio. You are reading diffs far more than you are writing code, and you are committing far more often, and both of those put pressure on parts of Git that used to be occasional. Partial staging goes from a nice-to-have to something you do every commit. The reset commands go from an emergency measure to a routine one.
That is the argument for having a proper diff and staging surface open while you work, rather than reaching for one when something goes wrong. It is the same argument we made about which operations belong in a GUI, just with the frequency turned up. When you review a diff four times an hour, the cost of a slow review surface stops being a preference and starts being the bottleneck.
