Hooks Guide
Hooks allow you to inject custom behavior at key points in the orchestration lifecycle.Hook Events
| Event | When | Purpose |
|---|---|---|
pre-prompt | Before LLM processes prompt | Inject context, coding standards |
pre-tool-call | Before tool execution | Validate, block dangerous commands |
post-tool-call | After tool execution | Process output, attach to bead |
post-response | After agent response | Create follow-ups, extract TODOs |
on-error | On task failure | Log failure, attempt recovery |
on-claim | On task claim | Run setup, linting |
pre-close | Before task close | Verify tests, check requirements |
on-block | When task becomes blocked | Notify, reprioritize |
Hook Context
Each hook receives aContext with relevant data:
Hook Result
Hooks return aResult to control flow:
Registering Hooks
Using the API
Using Configuration
Built-in Hooks
safety-guard
Blocks destructive commands:rm -rfgit push --forcegit reset --hard- SQL DROP/TRUNCATE/DELETE
context-injector
Injects repository context:- Project structure
- Recent file changes
- Related beads
- Coding standards
output-truncator
Truncates large tool outputs:- Limits output size
- Preserves key snippets
- Attaches summary to bead
followup-creator
Creates follow-up tasks:- Extracts TODOs from response
- Detects unfinished work
- Creates linked beads
error-logger
Logs failures for learning:- Records to audit trail
- Updates failure count
- Triggers recovery if enabled
Custom Script Hooks
Hook scripts receive JSON on stdin and return JSON on stdout:Input
Output
Example Script
Hook Execution Order
Hooks execute in registration order. If any hook returnsBlock: true, execution stops: