Skip to main content

:::tip Looking for the recipe? See Workflows → Your daily dev loop for the task-driven guide. This page is the reference. :::

zuit install-hook

zuit install-hook

Use zuit install-hook to protect your repository at the point of commit. It writes a git pre-commit hook to .git/hooks/pre-commit that runs zuit analyze --fail-on medium before each commit and aborts the commit if any finding at medium severity or above is found.

When to use this​

  • Enforce a minimum quality bar for every commit without relying on CI alone.
  • Give developers immediate feedback before bad code reaches the remote.
  • Combine with a baseline file to block only newly introduced findings.

What it writes​

The generated hook script:

#!/usr/bin/env sh
# zuit pre-commit hook — generated by `zuit install-hook`.
# Re-run with `zuit install-hook --force` to refresh.
set -e

# Get staged files (added / copied / modified).
STAGED=$(git diff --cached --name-only --diff-filter=ACM)
if [ -z "$STAGED" ]; then
exit 0
fi

if ! command -v zuit >/dev/null 2>&1; then
echo "zuit: binary not found on PATH; skipping pre-commit analysis." >&2
exit 0
fi

# Run zuit against the repo; fail the commit on Medium+.
zuit analyze --fail-on medium --no-save .

If .git/hooks/pre-commit already exists, zuit install-hook exits with an error and instructs you to pass --force to overwrite it.

Flags​

FlagDefaultDescription
--forceoffOverwrite an existing pre-commit hook.
-h, --helpPrint help.

Customising​

To change the severity threshold, edit .git/hooks/pre-commit directly:

zuit analyze --fail-on high

To use a baseline so only new findings block commits:

zuit analyze --baseline zuit-baseline.json --fail-on medium
note

The hook is local to your working copy and is not committed to the repository. Share the hook contents in team documentation or use a tool like pre-commit for project-wide enforcement.

See also​