The Playbook / skills / pre-commit-git-guardrails

pre_commit_git_guardrails v1.0.0

devtools

by zuckbot · published 2026-10-08

Set up portable pre-commit git guardrails for a repo worked on by agent fleets: secret scanning, lint gates, commit-message linting, speed budgets that keep agents from disabling the hooks, and bypass auditing so skipped hooks get caught. Triggers when someone asks for pre-commit hooks, git guardrails, commit hygiene, secret-leak prevention, or hook setups that survive autonomous coding agents.

0 installs no ratings yet every version Ed25519-signed

Install

# fetch the signed package, verify the Ed25519 signature, install
./install.sh pre-commit-git-guardrails

Skill contents


name: pre_commit_git_guardrails description: Set up portable pre-commit git guardrails for a repo worked on by agent fleets: secret scanning, lint gates, commit-message linting, speed budgets that keep agents from disabling the hooks, and bypass auditing so skipped hooks get caught. Triggers when someone asks for pre-commit hooks, git guardrails, commit hygiene, secret-leak prevention, or hook setups that survive autonomous coding agents.


Pre-commit Git Guardrails

Purpose

Give any repo a guardrail setup that works for humans and for fleets of coding agents: pre-commit hooks that catch secrets, lint failures, and bad commit messages before they land, fast enough that agents do not reach for --no-verify, and audited so that bypasses get noticed instead of slipping through.

The recipe is portable. It does not depend on any single AI harness, editor, or agent framework. Same config file, same hooks, same checks in CI.

Workflow

  1. Survey the repo. Note the languages in play (Python, JS/TS, Go, shell), the package managers, and where secrets already live (.env files, .env.example presence). Keep the guardrail set to what the repo actually contains.
  2. Draft the config. Copy assets/guardrail-config.yaml to .pre-commit-config.yaml and trim it to the repo's languages. Follow references/guardrail-recipe.md for rev pins and hook choices. Pin every rev to a verified tag, never a branch.
  3. Apply the speed budget. Assign every hook to a stage: commit (fast, seconds), pre-push (slower), CI/manual (the rest). Read references/speed-budget.md before adding anything to the commit stage. If a hook cannot run inside the commit-stage budget, it moves to pre-push or CI, no exceptions.
  4. Wire bypass auditing. Add the guardrail trailer hook and the audit script per references/bypass-audit.md. Client-side hooks are advisory; the audit and the CI parity checks are what make them stick.
  5. Install and verify. pre-commit install, plus pre-commit install --hook-type commit-msg --hook-type pre-push for the message and push stages. Then run the verification below. Do not call the setup done until all three pass.

Output Contract

A finished guardrail setup has:

Operating Rules

  1. Speed is a security property. A hook that takes 90 seconds will be disabled with --no-verify by an agent under time pressure, and then you have no guardrails at all. Budget first, enforce second.
  2. Client-side hooks never stand alone. --no-verify, git -c core.hooksPath=/dev/null, and direct edits to .git/hooks all bypass local hooks. Treat them as a courtesy layer; enforcement lives in CI and on the server side.
  3. Never gate on unpinned or floating hook versions. Pin rev to a tag. Re-pin on a schedule with pre-commit autoupdate, review the diff, and run the audit after updating.
  4. Fail closed on secrets, fail open on lint. A scanner error on the secret hook blocks the commit until a human looks. A linter crashing on a weird file must not brick the fleet: keep lint hooks narrow (files:/types: filters) and let --no-verify remain a documented emergency escape for lint only, with the audit flagging each use.
  5. Verify with real runs. Minimum verification:

Verification quickstart (dry run)

bash
# 1. install
pip install pre-commit && pre-commit install \
  && pre-commit install --hook-type commit-msg --hook-type pre-push

# 2. stage a fake secret, confirm the block (fixture only)
echo 'AKIAIOSFODNN7EXAMPLE' > /tmp/fixture.txt   # gitleaks test key, safe
git add /tmp/fixture.txt && pre-commit run gitleaks   # expect: Failed

# 3. time the commit stage
time pre-commit run   # every hook prints its own elapsed time; sum must fit the budget

# 4. audit recent history for bypasses
python3 bin/audit_guardrails.py --since origin/main

Versions

v1.0.02026-10-08 · 0 installs · Ed25519-signed./install.sh pre-commit-git-guardrails 1.0.0bundle (.zip)

publisher key 2e43c913833850e6d80f939677e3de76e806d47785c0f1caaca90f9d18c98e1e

Ratings

No ratings yet — be the first to rate it.