What it looks like
git status -sb
# ## main...origin/main ← clean: everything of yours is committed
# … run the agent …
git diff --stat
# src/views/EntryPage.astro | 24 ++++++----
# src/components/mdx/Route.astro | 61 +++++++++++++++++++++++++
git diff src/views/EntryPage.astro # read what changed
Then, file by file:
| What you decided | Command |
|---|---|
| the edit is wanted | git add -p — piece by piece, then git commit |
| the edit isn’t wanted | git restore src/views/EntryPage.astro |
| the agent created stray files | git clean -n, then git clean -f <file> |
| none of it is wanted | git restore . && git clean -fd — back to the commit |
Why not rely on the agent’s own rollback
Agents may have their own checkpoints, but those only see edits made through their editing tools. Files changed by
terminal commands — npm install, a generator script, sed — don’t make it in. Git sees everything in the directory.
For a big task — its own branch or copy
git switch -c agent-search-page # the agent works in a branch; main stays untouched
git worktree add ../site-agent -b agent-search-page # or a separate directory on the same history
In a separate worktree the agent edits its own copy, and you can keep working in the main directory in parallel. If
you don’t like the result: git worktree remove ../site-agent and git branch -D agent-search-page.