Unified Advisory Dispatcher
Consolidates 8 advisory hooks into a single process with budget-capped context injection
Runs 8 advisory hooks in a single process spawn, merging their output into one context injection capped at 800 tokens.
When It Fires
Event: PreToolUse · Matcher: Bash · Bundle: pretool.mjs
What It Does
Every time Claude is about to run a Bash command, the unified advisory dispatcher executes up to 8 internal hooks in sequence and merges their output into a single additionalContext string. This replaces what would otherwise be 8 separate process spawns, significantly reducing latency.
The dispatcher operates in three phases:
-
Input modification ---
default-timeout-setterruns first and may modify the command's timeout value. If it produces anupdatedInput, that modification is passed through to Claude Code. -
Blocking check ---
agent-browser-safetyruns second and can deny the command (e.g., blocking browser automation for agents that should not use it). If it blocks, the dispatcher returns the denial immediately and skips all advisory hooks. -
Advisory context --- The remaining 6 hooks run in order, each producing optional context. The dispatcher accumulates context until the 800-token budget is reached, then skips remaining hooks.
Consolidated Hooks
| Hook | Purpose |
|---|---|
default-timeout-setter | Adds default timeout to long-running commands |
agent-browser-safety | Blocks browser tools for non-browser agents |
error-pattern-warner | Warns about common error patterns in commands |
issue-docs-requirement | Reminds about documentation when working on issues |
multi-instance-quality-gate | Enforces quality when multiple Claude instances are active |
gh-issue-creation-guide | Provides guidance for GitHub issue/PR commands |
license-compliance | Warns about license implications of package installs |
affected-tests-finder | Suggests relevant tests to run based on changed files |
Security-critical hooks (dangerous-command-blocker, compound-command-validator) are not part of this dispatcher. They run as standalone entries to ensure they can block before any advisory logic executes.
Token Budget
The dispatcher enforces an 800-token cap on consolidated output. Each hook's context is measured with a token estimator before being appended. If adding a hook's output would exceed the budget, that hook is skipped and a log message is emitted.
Context sections from multiple hooks are joined with --- separators.
Configuration
This hook has no user-configurable options. The token budget (800) and hook execution order are defined in source code.
Related Hooks
- dangerous-command-blocker --- security blocker that runs before this dispatcher
- unified-dispatchers --- overview of the dispatcher pattern used across all events
File Guard
Protects sensitive files and enforces file size limits on writes
Stop Pipeline
Runs 23 cleanup hooks in a detached background process after session exit
Last updated on