PreToolUse gate on Claude’s Bash tool. When Claude tries git commit or git push, the hook runs fallow audit --format json --quiet --explain. pass and warn are allowed. fail is blocked, and the JSON findings are sent back to Claude on stderr so it can fix the code and retry.
This is Option C: local agent gate in the adoption rollout. Use it together with the shared CI gate from fallow audit, not instead of it. See Adopt Fallow in an existing repo.
Install it in one command
.claude/settings.json and .claude/hooks/fallow-gate.sh. It detects whether your repo also has an AGENTS.md or .codex/ and, if so, adds a managed Codex fallback block to AGENTS.md as well. To remove the generated artifacts later, run fallow setup-hooks --uninstall.
Preview first with --dry-run:
Install globally for every repo
Pass--user to install the gate under your home directory instead of per-project. The settings file lands at ~/.claude/settings.json, the hook script at ~/.claude/hooks/fallow-gate.sh, and the emitted handler command uses "$HOME" in place of "$CLAUDE_PROJECT_DIR" so it resolves in every repo Claude Code opens:
Remove it
.claude/settings.json, deletes the hook script if it still carries the generator marker (use --force to remove user-edited scripts), and strips the managed block from AGENTS.md. Handlers you added outside fallow stay untouched. Pass --user to uninstall the global artifacts at ~/.claude/ instead of the project ones.
The uninstall flow is idempotent: running it a second time prints unchanged / not present and exits 0. Dry-run is supported (--uninstall --dry-run).
fallow setup-hooks also recognises and cleans up hook commands that older manual setups emitted (absolute paths, ~/-based paths, Windows drive paths), so re-running it on a pre-existing install upgrades the handler to the canonical form without leaving duplicates.
Related but distinct:
fallow init --hooks scaffolds a shell-level Git pre-commit hook in .git/hooks/ that runs fallow on changed files. That is the human enforcement path. This page is the agent enforcement path. The two can be used together: git hooks catch human commits, the setup-hooks gate catches agent commits.Manual setup
1. Create .claude/settings.json
2. Create .claude/hooks/fallow-gate.sh
3. Make the script executable
Runtime errors fail open on purpose. In JSON mode,
fallow audit reports invalid refs, non-Git directories, and config errors as { "error": true, ... } with exit code 2. Letting those cases through prevents a brand-new repo or empty history from getting stuck before the first successful audit.Codex fallback
Codex now has an experimental hooks surface, but the low-friction fallback while it stabilizes is stillAGENTS.md. Add this to your repo root AGENTS.md:
fallow setup-hooks maintains this block for you, scoped between <!-- fallow:setup-hooks:start --> and <!-- fallow:setup-hooks:end --> markers so re-running the command is idempotent.
Why this works well with agents
fallow audit --explain gives Claude structured findings with docs links and fix guidance, while Agent Skills teaches the agent how to act on them. The result is a tight feedback loop: Claude tries to commit or push, the gate blocks only real fail-severity issues, Claude reads the JSON envelope, fixes the code, and retries.
Adoption rollout
See Option C: local agent gate next to warn-everywhere and error-plus-baselines.
fallow audit
Reference for verdicts, JSON output, and baselines.
Agent Skills
Teach the agent what to do after the gate blocks.