Skip to content

CLI-12: Gate a pre-commit hook on the exit code

The 0/1/2 exit-code contract wires validate straight into a shell gate or git hook.

Builds on: CLI-02: Read a single human finding with line:col

A terminal session: the command as you’d run it, followed by the output it prints; trailing comments note the exit status.

.git/hooks/pre-commit
#!/bin/sh
markdown-contract validate docs/planning || {
echo 'contract findings present — commit blocked' >&2
exit 1 # 0 clean, 1 error-level findings, 2 usage/config error
}
  • exit-code contract (0 clean / 1 error-level findings / 2 usage-config error) as the shell + CI gating basis