hook
Manage Claude Code hooks for automatic context injection.
Synopsis
bobbin hook <SUBCOMMAND> [OPTIONS]
Description
The hook command manages the integration between bobbin and Claude Code. When installed, bobbin hooks fire on every user prompt to inject semantically relevant code context, giving Claude automatic awareness of your codebase.
The hook system has two layers:
- Claude Code hooks — entries in
settings.jsonthat callbobbin hook inject-contextandbobbin hook session-contextautomatically. - Git hooks — an optional post-commit hook that re-indexes changed files after each commit.
Subcommands
install
Install bobbin hooks into Claude Code’s settings.json.
bobbin hook install [OPTIONS]
| Option | Description |
|---|---|
--global | Install to ~/.claude/settings.json instead of project-local <git-root>/.claude/settings.json |
--threshold <SCORE> | Minimum relevance score to include in injected context |
--budget <LINES> | Maximum lines of injected context |
This registers two hook entries:
- UserPromptSubmit — calls
bobbin hook inject-contexton every prompt, adding relevant code snippets. - SessionStart (compact matcher) — calls
bobbin hook session-contextafter context compaction to restore codebase awareness.
uninstall
Remove bobbin hooks from Claude Code settings.
bobbin hook uninstall [OPTIONS]
| Option | Description |
|---|---|
--global | Remove from global settings instead of project-local |
status
Show installed hooks and current configuration values.
bobbin hook status [PATH]
| Argument | Default | Description |
|---|---|---|
[PATH] | . | Directory to check |
Displays whether Claude Code hooks and the git hook are installed, along with the active configuration (threshold, budget, content mode, gate threshold, dedup settings).
inject-context
Handle UserPromptSubmit events. This is called internally by Claude Code — you typically do not run it manually.
bobbin hook inject-context [OPTIONS]
| Option | Description |
|---|---|
--threshold <SCORE> | Minimum relevance score (overrides config) |
--budget <LINES> | Maximum lines of context (overrides config) |
--content-mode <MODE> | Display mode: full, preview, or none (overrides config) |
--min-prompt-length <N> | Minimum prompt length to trigger injection (overrides config) |
--gate-threshold <SCORE> | Minimum raw semantic similarity to inject at all (overrides config) |
--no-dedup | Force injection even if results match the previous session |
--format-mode <MODE> | Injection format: standard (default), minimal, verbose, or xml |
Each injection includes a unique injection_id (e.g. [injection_id: inj-01KJ...]) in the output. Agents can reference this ID when submitting feedback via bobbin feedback submit or the bobbin_feedback_submit MCP tool.
session-context
Handle SessionStart compact events. Called internally by Claude Code after context compaction.
bobbin hook session-context [OPTIONS]
| Option | Description |
|---|---|
--budget <LINES> | Maximum lines of context (overrides config) |
install-git-hook
Install a post-commit git hook that runs bobbin index after each commit.
bobbin hook install-git-hook
Creates or appends to .git/hooks/post-commit. The hook re-indexes only files changed in the commit.
uninstall-git-hook
Remove the bobbin post-commit git hook.
bobbin hook uninstall-git-hook
hot-topics
Generate hot-topics.md from injection frequency data. Analyzes which code areas are most frequently injected as context and writes a summary.
bobbin hook hot-topics [OPTIONS] [PATH]
| Argument/Option | Default | Description |
|---|---|---|
[PATH] | . | Directory to operate on |
--force | Regenerate even if the injection count hasn’t reached the threshold |
Examples
Set up hooks for a project:
bobbin hook install
Set up globally with custom thresholds:
bobbin hook install --global --threshold 0.3 --budget 200
Check current hook status:
bobbin hook status
Also install the git hook for automatic post-commit indexing:
bobbin hook install-git-hook
Remove all hooks:
bobbin hook uninstall
bobbin hook uninstall-git-hook
JSON output for status:
bobbin hook status --json
JSON Output (status)
{
"hooks_installed": true,
"git_hook_installed": true,
"config": {
"threshold": 0.2,
"budget": 150,
"content_mode": "preview",
"min_prompt_length": 20,
"gate_threshold": 0.15,
"dedup_enabled": true
}
}
Prerequisites
Requires a bobbin index. Run bobbin init and bobbin index first.
See Also
- Hooks Guide — detailed setup and tuning guide
- Hooks Configuration — all configurable hook parameters
- watch — alternative continuous indexing via filesystem watcher