Hooks
Lifecycle hooks ensure that agent-generated modifications adhere to continuous formatting, linting, and security audits automatically.
Agent lifecycle hooks
Hooks are synchronous or asynchronous shell scripts triggered automatically during agent workflow steps. If a pre-hook exits with a non-zero code, execution halts immediately for security.
Available event types
| Event | Trigger Moment | Common Usage |
|---|---|---|
pre_tool_call | Before tool execution | Sanitizing sensitive arguments & paths |
post_tool_call | After tool execution | Auto-formatting modified files (Prettier/Biome) |
post_turn | After agent turn completes | Running TypeScript typechecks & linters |
on_error | On build or test failure | Feeding error stack traces back to agent |
Configuring hooks in plannix.json
{
"hooks": {
"post_tool_call": [
{
"matcher": "write_to_file",
"command": "npx prettier --write ${TARGET_FILE}"
}
]
}
}