Cheap changed-file checks gate every commit, marker-verified.

Pre-commit hook (3-stanza, tree-sha markers)

Intent — A three-stanza pre-commit hook that runs changed-file lints and unit-tier tests and writes tree-sha-keyed marker files, so an agent's commit cannot advance to merge unless the cheap checks actually passed on exactly this tree.

SummaryCheap changed-file checks gate every commit, marker-verified.
TargetAgent · Gates & merge-train
Formquality-gate
EnforcementHard (deterministic) · blocking — the hook fails the commit; merge-check rejects agent commits lacking valid markers · bypass prefixes (sentinel: / tombstone: / chore(worktree):) skip; --no-verify is banned for agents

Motivation — the failure it kills

Agents commit fast and often. Without a cheap gate at commit time, a broken change flows downstream to the expensive gates (merge-train, deploy) where the context of what the agent was doing is gone and the cost of diagnosis is highest. Worse, because the merge-train batches many agents' work, one un-checked broken commit can poison an entire batch. The failure recurs on every commit and compounds with fleet size: the later the break is found, the more work is entangled with it.

Why it's not just "run CI on the pull request"

CI-on-PR is late and coarse: it discovers the break after the commit exists and has been batched, far from the moment and context of authoring. The pre-commit hook is the first and cheapest stair of the path-to-production staircase: changed-file-scoped lints plus unit-tier tests, run at the instant of commit. And it does something CI-on-PR does not: it writes tree-sha-keyed marker files that a downstream verifier (merge-check) checks, so "the cheap checks ran green on this tree" becomes a deterministic, forgeable-proof fact rather than a trust assumption. What does CI-on-PR give the merge step to trust? Only that the PR exists. This hook hands it a tree-keyed marker: the gate fired early, and its passing is independently auditable.

Mechanism

Three stanzas fire in order: (1) changed-file lints; (2) unit-tier tests; (3) marker write. Markers are keyed by the tree-sha so a marker from one tree cannot vouch for another. A worktree merge-check step refuses to advance an agent commit that lacks a valid marker for its tree. Bypass-prefix subjects (sentinel:, tombstone:, chore(worktree):) skip the hook by design; codemod-class waves use an explicit pre-commit-skip: <reason> marker (lint stanza skipped, unit-tier still runs); --no-verify is banned for agents because it also skips the CWD-drift fences.

Prerequisites

Consequences & costs

Known uses

Related mechanisms