Hooks
Execute custom actions before and after agent operations, similar to Windsurf’s Cascade Hooks. Configure hooks via JSON or register Python callables programmatically.Quick Start
Hook Events
| Event | Trigger | Use Case |
|---|---|---|
pre_read_code | Before reading a file | Access logging |
post_read_code | After reading a file | Content validation |
pre_write_code | Before writing to a file | Linting, validation |
post_write_code | After writing to a file | Formatting, git add |
pre_run_command | Before running a command | Security checks |
post_run_command | After running a command | Logging, cleanup |
pre_user_prompt | Before processing user input | Input sanitization |
post_user_prompt | After processing user input | Response logging |
pre_mcp_tool_use | Before using an MCP tool | Permission checks |
post_mcp_tool_use | After using an MCP tool | Result logging |
Configuration File
Create.praison/hooks.json in your project:
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | true | Enable/disable all hooks |
timeout | integer | 30 | Global timeout in seconds |
hooks | object | {} | Map of event names to commands |
Per-Hook Options
| Option | Type | Default | Description |
|---|---|---|---|
command | string | required | Script or command to run |
timeout | integer | global | Override global timeout |
enabled | boolean | true | Enable/disable this hook |
block_on_failure | boolean | false | Block operation if hook fails |
pass_input | boolean | true | Pass context as environment variables |
Python Callable Hooks
Register Python functions as hooks:Script Hooks
Scripts receive context as environment variables:Environment Variables
| Variable | Description |
|---|---|
PRAISON_HOOK_FILE_PATH | File path (if applicable) |
PRAISON_HOOK_CONTENT | Content being written |
PRAISON_HOOK_COMMAND | Command being run |
PRAISON_HOOK_CONTEXT | Full context as JSON |
Exit Codes
| Code | Meaning |
|---|---|
0 | Success |
1 | Failure (blocks if block_on_failure is true) |
| Other | Failure |
Hook Results
Blocking Operations
Useblock_on_failure to prevent operations when hooks fail:
Statistics
Best Practices
Keep hooks fast
Keep hooks fast
Hooks run synchronously. Keep them fast (under 5 seconds) to avoid slowing down operations. Use
timeout to prevent hanging.Use block_on_failure sparingly
Use block_on_failure sparingly
Only block operations for critical checks like security scans. Most hooks should log or modify without blocking.
Handle errors gracefully
Handle errors gracefully
Hooks should catch exceptions and return meaningful error messages. Don’t let hooks crash the main operation.
Use Python hooks for complex logic
Use Python hooks for complex logic
Script hooks are good for simple tasks. Use Python callable hooks for complex validation or transformation logic.

