Skip to content

Hooks Reference

Every BoB hook, by event. Extracted from handbook §14.

← docs home

Hooks Reference

Hooks are shell scripts wired into Claude Code events via ~/.claude/settings.json. They run automatically at the right moment — never invoke them manually.

Hooks receive ALL data via stdin as JSON. There are no magic variable substitutions.

bash
INPUT=$(cat)
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command')

Template: templates/hooks/command-hook.sh. Requires jq.

Hooks by event

EventHookPurpose
SessionStarttemporal-context.shInject current date/time so Claude doesn't drift
SessionStartautoloop-inject.sh / warp-drive-inject.shRestore loop state on session resume
SessionStartloop-notes-inject.shInject the project's loop episodic-memory notes (discovered hidden rules) as context (#588)
PreToolUsestrip-ai-boilerplate.shStrip generic AI prose from outgoing edits
PreToolUsecheck-branch.shBlock writes on master/main
PreToolUsesession-branch-guard.shGuard against committing to wrong branch
PreToolUserdb-enforce-ask-remote.shWhen _rdb.enabled, force ask_remote over AskUserQuestion
PreToolUseautoloop-gate.sh / warp-drive-gate.shBlock tool calls outside the current loop phase
PreToolUsevalidate-commit-message.shReject commits with generic / AI-boilerplate messages
PreToolUsevalidate-pr-requirements.shPR must reference a requirement issue
PreToolUsevalidate-requirement-refs.shRequirement IDs in commit messages must resolve
PreToolUsepre-release-checklist.shRun before release commands
PreToolUsedev-auto-start.shAuto-start dev server when project requires it
PreToolUseautonomous-audit-log.shAt automation L3 only, record every auto-approved tool call (tool, target, ts) to a per-session JSONL audit log; strict no-op at L1/L2 (#420)
PostToolUsewarp-drive-edit-tracker.shTrack edits during a warp-drive chunk
PostToolUsewarp-drive-commit-detector.shDetect commits and advance the state machine
PostToolUsewarp-drive-docs-detector.shDetect doc changes and route to journal
PostToolUsecapture-decision.shCapture AskUserQuestion / RDB ask_remote outcomes to the decision log (#332)
Stopautoloop-stop.sh / warp-drive-stop.shPersist state on session stop
Stopwarp-drive-pre-exit.shCleanup before exit
Stopsession-summary-reminder.shRemind to capture session summary
Stopstop-notify-rdb.shNotify Telegram when warp-drive stops
SubagentStopswarm-result-gate.shBlock a swarm worker's stop when its result fails the per-worker gate (#579)

(Exact wiring lives in ~/.claude/settings.json. Use make check-hooks to verify all hook scripts exist and are executable.)

Git hooks (distinct from Claude Code hooks)

Separately from the settings.json event hooks above, cdi installs a git commit-msg hook (templates/git/hooks/commit-msg) into each project. It runs for every commit — Claude-made or human — and does two things in order:

  1. Strips AI boilerplate (Co-Authored-By: Claude, 🤖 Generated, …).
  2. On projects with automated versioning (.versionrc.json / commitlint.config.* present), enforces Conventional Commitscommitlint if installed, else a built-in dependency-free check (#278). Non-versioned projects keep strip-only behavior. See the versioning guide.

Decision log — outer improvement loop (#332)

capture-decision.sh (above) records the stream of user decisions so they can later be distilled into updated, version-controlled instructions. The capture writers and the schema live under scripts/decision-log/ and schemas/:

  • Log: <project-root>/.claude/.decisions.jsonl — JSONL, append-only, one record per decision. Runtime state, gitignored (the distilled output is what gets git-tracked, not the raw stream).
  • Schema (source of truth): schemas/decision-log.schema.json, validated in make check against a committed sample fixture.
  • Sources: AskUserQuestion and RDB ask_remote (captured automatically by the hook); /code-review accept/reject (captured via scripts/decision-log/log-code-review.sh, since a slash command's outcome is not a hookable tool call).
  • Rotation: see scripts/decision-log/README.md.