Skip to content
Fallow home
All docs pages

fallow hooks: install Git and agent hooks

Install, remove, and inspect the fallow-managed Git pre-commit hook and the Claude Code and Codex gate that runs fallow audit before git commit and git push.

fallow hooks manages two kinds of hooks. Both run fallow audit on the changed code:

  • The Git target writes a shell-level pre-commit hook. It checks the commits of people.
  • The agent target writes a PreToolUse gate for Claude Code and Codex. It blocks an agent git commit or git push when the audit verdict is fail.

You can use both together.

fallow hooks status
fallow hooks install --target git
fallow hooks install --target agent
fallow hooks uninstall --target agent
SubcommandWhat it does
statusShows the installed hook state. It changes nothing.
installInstalls a fallow-managed hook.
uninstallRemoves a fallow-managed hook.

hooks status

Shows the state of four hook surfaces: the Git pre-commit hook (git), the Claude Code gate (claude), the Codex AGENTS.md routing block (codex), and the Codex gate (codex_gate).

fallow hooks status
fallow hooks status --format json
Git hook: installed (.git/hooks/pre-commit)
Claude hook: not installed
Codex hook: not installed
Codex block: not installed

For the JSON fields, see Inspect hook state. An agent reads user_edited before it changes a hook. When user_edited is true, the agent asks before it overwrites the file.

hooks install

fallow hooks install --target <git|agent> [OPTIONS]
FlagApplies toDescription
--target <TARGET>bothRequired. git writes a pre-commit hook in .git/hooks/ or .husky/. agent writes the Claude Code or Codex gate.
--branch <BRANCH>gitThe fallback base ref of the hook when the branch has no upstream. Default: the default branch of origin, else main.
--prune-baselinesgitRun fallow baselines prune before the audit and stage the pruned baseline files. See Prune baselines.
--agent <AGENT>agentInstall only the gate of one harness: claude or codex. Default: detect from the .claude/ and .codex/ directories.
--useragentWrite the gate to your home directory (~/.claude/, ~/.codex/), not to the project.
--gitignore-claudeagentAdd .claude/ to the .gitignore of the project when the command installs the Claude Code gate.
--dry-runbothPrint what the command would write. Change no files.
--forcebothOverwrite an existing managed hook, or a hook that you edited.

Git target

fallow hooks install --target git finds your hook manager:

  • With a .husky/ directory, it writes .husky/pre-commit.
  • With Lefthook (a .lefthook/ directory, lefthook.yml, or lefthook.json), it writes no file. It prints the pre-commit command to add to your Lefthook config.
  • Else it writes .git/hooks/pre-commit.

fallow init --hooks does the same. For what the generated hook runs, see Pre-commit hook.

The fallback base ref of the hook is the --branch value. Without --branch, it is the default branch of origin, else main.

When the pre-commit file exists, the command stops with exit code 2. This is also true for a hook that fallow wrote earlier. The command then prints the block to add to your hook by hand. To replace the file, pass --force.

Agent target

fallow hooks install --target agent writes .claude/settings.json and .claude/hooks/fallow-gate.sh. When the project has a .codex/ directory, it also writes the Codex gate and an AGENTS.md routing block. When neither .claude/ nor .codex/ exists, it installs the Claude Code gate. For the gate behavior, the block message, and the version floor, see Claude Code hooks.

fallow agent install installs the same gate together with the skill and the MCP registration.

hooks uninstall

fallow hooks uninstall --target <git|agent> [OPTIONS]
FlagApplies toDescription
--target <TARGET>bothRequired. The hook surface to remove: git or agent.
--agent <AGENT>agentRemove only the gate of one harness: claude or codex. Default: every surface that fallow finds.
--useragentRemove the gate from your home directory, not from the project.
--dry-runbothPrint what the command would remove. Change no files.
--forcebothAlso remove a hook script or Git hook that you edited. Without this flag, the command keeps such a file.

Uninstall removes only what fallow wrote. Handlers and hooks that you added stay. A second run prints unchanged or not present and exits 0.

Exit codes

CodeMeaning
0The command ran, also when there was nothing to change.
2Invalid input, for example an existing pre-commit file without --force, an invalid settings.json, or a repository without a .git directory.

See also