Guide 05 · Harnesses
Hooks: which one, for what
A hook is a script that a tool runs at a set moment and that can stop or change the next step. Git, OMP and Claude Code each have their own.
What it is for
A check can live in three places. Git runs hooks around commits and pushes in a repository. An agent harness such as OMP or Claude Code runs hooks around the agent's tool calls. Approval rules such as OMP's bash.patterns sit next to them: they are not hooks, but they often do the same job. This guide helps you pick the place for a check.
Pick a hook
| I want to… | Use | Because |
|---|---|---|
| Stop any commit that adds a marker, a secret or a failing check | Git pre-commit | It runs for every commit in the repo, from a person or an agent. Any non-zero exit stops it. |
| Enforce a commit message format | Git commit-msg | It gets the message file and can reject or rewrite it. |
| Refuse a push to a protected branch | Git pre-push | It sees every ref being pushed before anything is sent. |
| Have a second model review each commit | A pre-commit hook that calls an agent CLI | See Commit review by a second model. |
| Stop the agent from running a command | OMP tool_call hook, Claude Code PreToolUse hook | It sees the tool call before it runs, including commands that never reach git. |
| Forbid one command without writing code | OMP bash.patterns with deny | One line of config. It matches the command text and covers the bash tool only. |
| Add a step to a command before it runs | OMP tool_call returning a new input, Claude Code updatedInput | The agent does not have to remember the step. |
| Tell the agent something after a tool ran | OMP tool_result, Claude Code PostToolUse, with additionalContext | The note reaches the agent before its next step. The call itself cannot be undone. |
| Run something when a session ends | OMP session_shutdown, Claude Code SessionEnd | For logs and summaries. It cannot stop anything. |
The kinds at a glance
| Kind | Runs | Sees | Stops it with | Limits |
|---|---|---|---|---|
Git pre-commit | before git creates a commit | the staged change (no arguments) | any non-zero exit | skipped by --no-verify; only active once core.hooksPath points at it |
Git commit-msg | after the message is written | the path to the message file | any non-zero exit | skipped by --no-verify |
Git pre-push | before a push sends anything | remote name and URL; one line per ref on stdin | any non-zero exit | skipped by --no-verify; runs only on the pushing machine |
OMP tool_call | before an agent tool runs, before approval | tool name and input | { block: true, reason }, or a new input instead | tool calls only; loads at session start; 30 s, then the call is blocked |
OMP bash.patterns | before a bash tool command | the command text | deny or prompt | literal text with *; bash tool only; not a sandbox |
Claude Code PreToolUse | before a tool call | JSON on stdin: tool_name, tool_input, cwd, session_id | exit 2 (stderr goes to Claude) or JSON permissionDecision: "deny" | any other exit code lets the call through |
OMP tool_result, Claude Code PostToolUse | after the tool ran | the input and the result | feedback to the agent, a replaced result | cannot undo the call |
Git rows: Git 2.52, from its documentation and our tests. OMP rows: OMP 18.14.1 documentation. Claude Code rows: its hooks reference, checked Nov 4, 2026, against version 2.1.281.
Set them up
- Git hooks:
pre-commit,commit-msgandpre-pushkept in the repo, how to switch them on and who may skip them. - Agent hooks in OMP and Claude Code: stop or change a tool call before it runs, with the same example in both tools.
- Commit review by a second model: a pre-commit hook that calls a second agent.
- Our hooks as they are set today.
What hooks are not
A hook sees the text of a command or a tool call, not the intent behind it. A git hook can be skipped with --no-verify, and an agent once got past one of our agent hooks by building the blocked word from parts. Put the real boundary in permissions: what the process may delete and where it may write. A hook is a guardrail on top. Codex's documentation says the same: “Treat tool hooks as a useful guardrail, not a complete enforcement boundary.”
Sources
- Git documentation: githooks and git-config, Git 2.52
- OMP documentation, version 18.14.1:
hooks.md,extensions.md,settings.md - Claude Code hooks reference, checked Nov 4, 2026
- Our OMP hooks
hooks/pre/git-commit-log.tsandhooks/pre/guard-recursive-delete.ts, and OMPconfig.yml - K-B sprint notes and session notes, Oct 15 to Nov 4, 2026