pre-commit hook
NAME
pre-commit - a local git hook over a committed fixture
Catching drift before it is pushed keeps the shape change and the lock update in the same commit, which is the state a reviewer can actually reason about.
HOOK
.git/hooks/pre-commit#!/bin/sh# only run when the fixture or the lock is part of this commitif git diff --cached --name-only | grep -qE '^(fixtures/|schema\.lock$)'; then driftpipe check --input fixtures/orders.ndjson --fail-on any || { echo "schema drift in staged fixture; re-snapshot or fix before committing" >&2 exit 1 } fi
WHEN IT FIRES
Because the fixture is small and reviewed, the strict threshold is the right one: a new field in it was typed on purpose, and the matching lock line should be in the same commit. The hook stays silent on commits that touch neither the fixture nor the lock, so it costs nothing on unrelated work.
RE-SNAPSHOT FLOW
When the drift is intended, record the new baseline and stage it alongside the code that produced it:
$driftpipe snapshot --force --note "added coupon_code, 2026-10" wrote schema.lock format 3 31 paths$git add schema.lock fixtures/orders.ndjson$git commit
GOTCHAS
- A git hook is not shared automatically; distribute it through your hook manager of choice or a bootstrap script in the repository.
- Do not reach for an
ignoreentry to get past the hook. That exemption is permanent and silent, and nobody will remember the Tuesday it was added. - The hook is a convenience, not a gate: the authoritative check is still the one that runs on the server, where it cannot be skipped with
--no-verify.