The safest pre-review check for a coding-agent patch is a three-view Git audit: compare the exact base and head, inspect the summary and raw metadata, then list staged, untracked, and special entries separately. Do not approve a patch from a line diff alone. A line-oriented view can hide a rename, executable-bit change, symbolic link, submodule pointer, or file that is present in the checkout but outside the commit range.

Last reviewed: 2026-11-27

Freeze the patch boundary first

Start by recording the base revision that the reviewer will use. In a pull request, that is normally the merge base with the destination branch, not whichever commit happens to be checked out in the agent workspace. GitHub’s pull-request review guidance treats commits, changed files, and diffs as separate review surfaces; keep those surfaces tied to one immutable head.

Use a disposable clone or a clean worktree for the audit. Substitute the real destination branch for origin/main:

base=$(git merge-base origin/main HEAD)
head=$(git rev-parse HEAD)
git status --short --untracked-files=all

If the status output is not empty, decide whether those files belong to the proposed change. A dirty worktree is not automatically unsafe, but it is unsafe evidence: the reviewer cannot tell whether a result came from the committed patch, an agent’s leftover file, or a local edit. Record the decision before continuing.

If the agent was allowed to create commits, audit the range from $base through $head. If it was only allowed to edit files, audit both the worktree and the eventual staged snapshot. A useful companion is the site’s change-scope note workflow . Put the base, head, intentional non-changes, and unresolved status entries in the handoff so the reviewer does not have to reconstruct the boundary.

Produce three complementary Git views

Git’s diff documentation exposes more than patch hunks. Generate these views from the same revisions:

git diff --name-status --find-renames $base $head
git diff --summary $base $head
git diff --raw $base $head

The first view is the review inventory. It makes additions, modifications, deletions, and detected renames easy to count. The second is the structural alarm: Git documents it as a compact summary of extended-header changes such as creations, renames, and mode changes. The third retains raw metadata, including old and new modes and object identifiers that a normal hunk view may not make prominent.

Do not treat rename detection as a fact about intent. It is a similarity-based presentation of a delete/add pair. Read the old and new paths, inspect the content delta, and ask whether the destination path changes loading, permissions, ownership, or deployment behavior. If a path must remain stable for a package, policy, or runtime lookup, a rename may be an operational break even when most lines are unchanged.

For a staged snapshot, repeat the inspection against the index rather than assuming that the worktree matches it:

git diff --cached --name-status --find-renames
git diff --cached --summary
git diff --cached --raw

This catches a common agent handoff error: the reviewer sees a clean committed branch while the operator is about to stage an additional file, or a needed file exists only in the worktree and will not reach the pull request.

Inspect special entries and untracked files

The git ls-files reference supplies the index-oriented view that a patch hunk cannot. Use it to inspect staged mode, object, and stage number, then list files that are not tracked:

git ls-files --stage
git ls-files --others --exclude-standard
git ls-files --others --ignored --exclude-standard

Pay special attention to entries whose mode is not an ordinary regular file, including symlinks and Git links to submodules. A submodule is not an ordinary directory diff: Git’s submodule documentation explains that the superproject records a reference to a commit in another repository. Review the referenced commit, the submodule URL policy, and whether the target is available to every build or deployment environment. Do not approve a pointer change merely because the parent repository’s visible diff is small.

The two others commands answer different questions. The first exposes untracked files that standard ignore rules do not hide. The second exposes ignored files as well, which is valuable for an agent workspace containing generated output, local configuration, test fixtures, or credentials-shaped material. Do not copy those files into a review artifact; record only a safe path classification and the decision to remove, ignore, or intentionally add them.

For a compact manifest, normalize each path to a record with its status, old and new path when applicable, mode transition, whether it is tracked, and whether it is a special entry. Keep file contents and environment values out of the manifest. The goal is to prove the patch shape, not to create a second copy of the repository.

Turn the audit into a merge decision

Use a small policy table rather than a vague conclusion:

FindingRequired reviewer action
Unexpected rename or deletionConfirm callers, packaging rules, and rollback path.
Mode change or symlinkInspect the target, checkout behavior, and execution boundary.
Submodule or Git-link changeReview the referenced commit and repository policy.
Untracked or ignored artifactRemove it or explain why it is intentionally part of the change.
Base/head mismatchRecompute every view after the branch is stable.
Clean metadata and expected pathsContinue with tests, security checks, and human review.

A signed-commit control answers who produced a commit, not what hidden file shape it contains. If the repository uses the site’s verified signed-commit gate , run it over the same commit range and compare the verified head with the audited head. A rebase, amend, cherry-pick, or conflict resolution invalidates both the prior signature result and the prior patch audit.

The audit should fail closed when the base cannot be resolved, the worktree changes during collection, the index contains unresolved entries, a special entry is not covered by policy, or the manifest cannot be reproduced. It should not fail merely because Git labels a valid content move as a rename. That is a review signal, not a defect; the reviewer decides whether the path change is intended.

Failure modes to test

Only the pretty diff is reviewed. A normal hunk view can make a mode, link, or path transition easy to miss. Require the name-status, summary, and raw views in the check output.

The agent leaves generated files behind. Untracked files do not appear in a commit diff. Run the tracked and untracked listings from the same worktree and retain a sanitized count and classification.

Ignored files are assumed harmless. Ignore rules are repository convenience, not a security boundary. Inspect ignored entries for generated secrets, local settings, and files that a packaging step might copy.

The audit runs against the wrong base. A stale local branch or a moving remote changes the patch being described. Resolve and record the base and head object IDs, then rerun after any rebase or force-push.

A submodule pointer is treated like source code. The parent diff does not contain the child repository’s changes. Review the referenced commit and ensure the build can fetch the declared dependency under repository policy.

A green audit is mistaken for a safe patch. Metadata proves shape, not behavior. Continue with tests, dependency and security checks, runtime verification, and a human decision about intent.

FAQ

Does this replace pull-request review?

No. It makes the file and object boundary explicit so the reviewer can spend time on behavior and risk. GitHub’s review workflow still expects inspection of proposed changes and a decision to approve, request changes, or leave a comment.

Should the agent be allowed to create commits?

That is a repository policy decision. If it may create commits, bind the audit to the complete base-to-head range and verify each resulting head. If it may only edit files, inspect the worktree and index before a trusted process creates the commit.

Is an ignored file automatically a secret?

No. It is simply excluded by ignore rules. Classify it without printing contents, remove it when unneeded, and escalate anything that could affect packaging, runtime behavior, or credential handling.

What should the check retain?

Retain the base and head object IDs, normalized status records, mode and special-entry findings, untracked and ignored counts, policy version, tool version, and final decision. Exclude file contents, prompts, shell environment, tokens, and private paths from ordinary logs.

Sources checked

Contract details to verify

Before making the check required, write down the destination branch, base-resolution rule, whether untracked and ignored files block the handoff, the approved special-entry policy, and the exact status-check name. Run the audit against a fixture containing a rename, a mode change, a symlink, an untracked file, and a submodule pointer if the repository supports submodules. Confirm that expected findings are classified and that an unexpected finding blocks the check without exposing file contents.

Do not let the agent edit the audit policy and the application patch under one unreviewed scope. Route changes to ignore rules, path allowlists, submodule policy, or required-check configuration through the same reviewer who owns the repository boundary.

Reader next step

Run the three-view audit on the next agent-authored branch before opening its pull request. Attach the sanitized manifest and the base/head IDs to the change-scope note, resolve every special or untracked entry, then proceed to behavior tests and human review. The result you want is not that the diff looked normal; it is that the reviewer can explain every path, mode, object, and file that will cross the merge boundary.