Skip to content

How-to: set up the pre-commit gate

Wires the audit pipeline into git commit so every commit is validated before it lands.

One-time setup (per clone)

python scripts/setup_hooks.py            # if already a git repo
python scripts/setup_hooks.py --init     # initializes git first

This sets core.hooksPath to .githooks/ and chmods the hooks executable.

What runs on each commit

The pre-commit hook calls scripts/pre_commit_check.py, which runs:

  1. scripts/sync_registry.py --dry-run (detects _meta drift)
  2. scripts/audit.py (structural)
  3. scripts/audit_semantic.py (semantic)

If any of these fail, the commit is aborted.

The repo also ships a .pre-commit-config.yaml for the pre-commit framework:

pip install pre-commit
pre-commit install

This adds: trailing whitespace, end-of-file fix, JSON/YAML/TOML validation, ruff lint/format.

git commit --no-verify

CI will still catch it.