You approve a one-line change to a handoff note. Before your coding agent commits it, someone stages a debug file. The handoff still looks right. How would you spot the extra file before pushing?
At review time, save the object IDs of the starting commit and the staged tree. After the commit, check that its only parent is that starting commit and that its tree matches the one you reviewed. Adding the debug file changes the tree even if the handoff itself is identical.
Download the review commands, shell verifier and agent instruction (.md)
Review a fixed pair of snapshots
Start in the root of a trusted, complete local repository with ordinary history (no legacy grafts), an existing commit and the intended edits already staged. In a POSIX shell, capture the base and tree before opening the diff. The subshell stops on a Git error.
(
set -eu
export GIT_NO_REPLACE_OBJECTS=1
base=$(git rev-parse --verify 'HEAD^{commit}')
tree=$(git write-tree)
git --no-pager diff --no-relative --ignore-submodules=none --no-ext-diff --no-textconv "$base" "$tree" --
printf '\nbase=%s\ntree=%s\n' "$base" "$tree"
)
The index is Git’s staging area. git write-tree stores its snapshot in the object database and prints its ID. It requires a fully merged index. The diff above compares two named objects, so a later edit cannot change which snapshots those IDs identify. Git write-tree · Git diff
Review the changed paths and their contents. For a binary file or a submodule, inspect the referenced content if the displayed patch gives too little detail to decide. If you approve one local commit, keep the repository, branch, full base and tree IDs, permitted action and decision in a record you control. Keep that record somewhere the agent cannot rewrite.
Verify the commit the agent hands back
Ask the agent for the full commit ID. A branch name can move between the handoff and your verification. The download includes a shell script you can save outside the repository and run with the full IDs from the review and handoff.
sh /path/to/verify-reviewed-commit.sh BASE_ID TREE_ID COMMIT_ID
The script reads the candidate’s tree with ^{tree} and its complete parent list with %P. It prints MATCH and exits zero when the snapshot and its sole parent both match the review. On a mismatch it prints the actual tree and parents. If Git cannot resolve the candidate commit or its tree, the script stops with an error. Git revisions · Git commit formats
What changed in the four local checks?
We ran the download’s capture and verification commands with Git 2.54.0 in a disposable macOS repository. The staged handoff named the release lead as owner. Each check used the same saved base and tree.
| Candidate presented for verification | Observed result |
|---|---|
| The working copy was edited after staging. An ordinary commit saved the staged handoff. | Match. Reading the committed file returned the reviewed owner. |
| The same handoff and an extra staged debug file were committed on the approved base. | Mismatch. The parent matched and the tree differed. |
| The reviewed tree was placed in a commit with a different parent. | Mismatch. The tree matched and the parent differed. |
| A merge commit had the reviewed tree and the approved base as its first parent. | Mismatch. The additional parent appeared in the parent list. |
We created the first two commits through the normal staging and commit commands. For the history cases we constructed local commit objects with explicit parents. The exercise covered Git object verification. Testing agent behavior inside Codex or Claude Code would require a separate host session.
Did the passing tests use that commit?
A matching commit can still contain a bug. Suppose the committed rule says limit = 3, but an unstaged correction says limit = 4. A test that expects four passes in the agent’s working directory. The correction is absent from the commit you are about to push.
After the verifier reports a match, check out that full commit ID in a separate directory and run the project’s trusted test procedure there. From the repository root, replace COMMIT_ID below with the verified ID. Choose an unused sibling path; stop if creation fails.
GIT_NO_REPLACE_OBJECTS=1 git worktree add --detach ../review-check COMMIT_ID
This creates a linked worktree at the chosen commit without moving your current branch. It has its own checkout and index but shares repository data. It is not a security sandbox. Git worktree
Our small Python fixture needs no third-party dependencies. From the new checkout, we ran python3 -B -m unittest -v and observed:
| Files used by the test | Observed result |
|---|---|
| Original working directory, with the unstaged correction | Pass, exit 0 |
| Detached checkout of the verified commit, without that correction | Fail, exit 1 |
| Detached checkout of a new commit containing the correction, checked against a fresh base/tree record | Pass, exit 0 |
The middle case still returned MATCH from the commit verifier. It matched the recorded proposal; the test exposed a problem in that proposal. These were local checks on macOS with Git 2.54.0 and Python 3.14.4, using a synthetic rule and one unit test. No agent host or remote CI was exercised.
For your project, use its documented runtime, dependency setup and test command. Untracked or ignored configuration and installed dependencies from the old directory are not carried over by this checkout. Record the commit ID, command, environment, output and exit status together. Keep the checkout free of concurrent agent edits; inspect changes made during setup or tests before treating the result as evidence for the commit. A clean checkout alone does not prove a reproducible environment or meaningful test coverage.
The download includes the test commands, cleanup steps and an expanded agent handoff. A failed test calls for investigation and, if the code changes, a fresh proposal and review.
Use the result before a push decision
If the tree differs, compare the recorded tree with the candidate’s tree and inspect the extra or missing paths. If the parent list differs, establish which history the reviewer intended. Preserve the candidate for inspection and ask for a new decision before moving it forward.
A match answers a narrow question about tracked files and history in this repository. Commit messages, signatures, test results, branch destinations and permission to push each require their own evidence when they matter to the review. The local check runs after the commit exists. For a subsequent push, identify the exact commit and destination in the approval request. Approval request card
Updated 16 November 2026: added a tested example of passing tests against uncommitted code, plus commands for checking the verified commit in a separate worktree.