Deploy & Ops
Verifying the Committed Tree Before Push
Use before pushing to a deploy branch on a repo where fast iteration or agents leave files uncommitted, so a commit that imports an unstaged module cannot pass local checks and then fail the remote gate. Covers typechecking an isolated worktree of HEAD rather than the dirty working tree. Also use when a build is green locally and fails on the deploy with a module-not-found. If a push can break main, use this skill.
1 file
Description
Use before pushing to a deploy branch on a repo where fast iteration or agents leave files uncommitted, so a commit that imports an unstaged module cannot pass local checks and then fail the remote gate. Covers typechecking an isolated worktree of HEAD rather than the dirty working tree. Also use when a build is green locally and fails on the deploy with a module-not-found. If a push can break main, use this skill.
name: commit-tree-verification description: Use before pushing to a deploy branch on a repo where agents (or fast iteration) leave uncommitted files, so a commit that imports an unstaged module cannot pass local checks and then fail the remote type gate. Covers an isolated worktree typecheck of HEAD.
Verifying the Committed Tree Before Push
When to trigger
Before every push to a branch that auto-deploys (for example Vercel building main), on a repo where an agent may have left in-progress files in the working tree.
The failure this prevents
Local checks run against the working tree, which includes files you have not staged. An agent commits code that imports lib/new-thing.ts but leaves that file unstaged. pnpm typecheck passes locally (the file is on disk) and the deploy's tsgo gate fails (the checkout has only the commit). The fix is to check the committed tree, in isolation from the dirty working directory.
Typecheck an isolated worktree of HEAD
Add a detached worktree at HEAD in a temp dir, share node_modules by symlink so install is instant, run the exact deploy gate there, then clean up:
#!/bin/bash
set -euo pipefail
REPO="$(git rev-parse --show-toplevel)"
TMP="$(mktemp -d /tmp/verify-XXXXXX)"
trap 'git -C "$REPO" worktree remove --force "$TMP" 2>/dev/null || true; rm -rf "$TMP"' EXIT
git -C "$REPO" worktree add --detach "$TMP" HEAD --quiet
ln -s "$REPO/node_modules" "$TMP/node_modules"
cd "$TMP"
npx -y @typescript/native-preview --noEmit # the SAME gate the deploy runs
echo "commit tree verifies clean: $(git -C "$REPO" rev-parse --short HEAD)"
Run this exact gate, not just next build; a build can pass where a strict typecheck fails. Because the worktree is HEAD only, an uncommitted import fails here exactly as it will in CI.
Pitfalls
- Running the check in the main checkout defeats the purpose: it sees the dirty working tree and passes on the very files CI will not have. Use an isolated worktree of HEAD.
- Copying
node_modulesinto the temp dir is slow and can race a concurrent build. Symlink it instead. - Leaving the temp worktree behind clutters
git worktree listand/tmp. Remove it in a trap so it cleans up even on failure. next buildsucceeding is not the deploy gate if the deploy runs a separate typecheck. Run the same command the deploy runs.
Added 2026-07-01. Back to the Skill Library.

Get Smarter About AI Dev
New tutorials, open-source projects, and deep dives on coding agents - delivered weekly.