A deterministic check produces the same validation result for the same inputs and explicit rules. Give blocking authority to such tools; let probabilistic models advise when judgment is required. section 5.3.2
Apply the distinction as an engineering guardrail:
- Block commits with checks that cannot reasonably be argued out of their result, such as secret scanning against known patterns. section 5.3.2
- Keep model-based review advisory because incorrect blocking trains developers to bypass the gate with --no-verify. section 5.3.2
- Parse structured verdicts with jq instead of grepping free text, which can mistake a response containing FAIL for PASS. section 5.3.2
Pre-commit gate
A staged diff first runs gitleaks protect --staged --redact and exits on failure. An AI reviewer then assesses conventions and prints concerns without blocking the commit. section 5.3.2
Listing 5.4 Pre-commit hook example
#!/bin/bash
# .git/hooks/pre-commit
set -euo pipefail
DIFF=$(git diff --cached)
[ -z "$DIFF" ] && exit 0
# Deterministic checks block. This is the real gate.
gitleaks protect --staged --redact || exit 1
# The model advises. It cannot block on its own.
VERDICT=$(printf '%s' "$DIFF" | claude -p "Review this diff against our
conventions: error handling, test coverage for new public functions,
naming. Reply with exactly one line of JSON and nothing else:
{\"verdict\":\"clean\"} or {\"verdict\":\"concerns\",\"notes\":\"...\"}")
if [ "$(printf '%s' "$VERDICT" | jq -r '.verdict')" = "concerns" ]; then
echo "AI reviewer raised concerns (advisory, not blocking):"
printf '%s' "$VERDICT" | jq -r '.notes'
fi
exit 0Inspect the complete shell hook showing staged-diff handling, deterministic secret blocking, structured model output, and advisory reporting. section 5.3.2


