APX is a free, open-source desktop app that runs your own team of AI agents on your machine. The Git checks below work with any coding agent, whether or not you use APX.

Suppose an agent is fixing cart validation. Your editor has main open with an unrelated change to a pricing test. The agent should work in a linked worktree on fix/cart-validation. At the end it tells you that the tests passed. That doesn't tell you which copy it edited or where it ran the tests.

Before the edit: record what Git sees

Open a shell in the intended worktree. Use its absolute path in the handoff so neither you nor the agent has to rely on the shell's current directory:

git -C /path/to/cart-fix rev-parse --show-toplevel git -C /path/to/cart-fix branch --show-current git -C /path/to/cart-fix rev-parse HEAD git -C /path/to/cart-fix status --short --untracked-files=all 

Give the agent the expected repository root, branch, and full commit ID from a starting point you've checked. Ask it to run the same commands and report the output before editing. If the root, branch or commit differs, stop there. A blank branch name can mean a detached HEAD; it isn't a match. If there are existing edits, keep a record of them or start from a clean worktree instead of assuming that every change you see later came from the agent.

At handoff: check the patch and the test location

For a task where the agent may edit and test but not commit, ask for the same four outputs again. Also ask for the test command, the directory it ran in, and its exit status. The branch and commit ID should still match the baseline. The file list shows what Git now sees as changed. Review both parts of the patch from that same root:

git -C /path/to/cart-fix diff -- git -C /path/to/cart-fix diff --cached -- 

The first command shows unstaged changes to tracked files; the second shows staged changes. Neither shows the contents of new untracked files. Check for ?? entries in the status output and review any new files separately. In this example, also check the main worktree: the pricing edit you started with should still be there, and the cart patch shouldn't be. If anything looks off, pause the agent and inspect both locations before trying to move or undo changes.

One small handoff request covers the whole exercise:

Before working, verify the root, branch and full commit against the values below. Stop if any differs. Fix only cart validation. Do not switch branches, commit or push. At handoff, report the Git checks again, list the files changed, and include the test command, its working directory and exit status.

A worktree has its own HEAD and index, but shares repository objects and most refs with other worktrees. It's a separate working directory, not a permission boundary. The point of the two checks is to make the agent's report something you can verify from Git.

References

Disclosure: The APX team publishes this article. It was drafted with AI assistance.