{
"hooks": {
"PostToolUse": [
{ "command": "npm run lint && npm test" }
]
}
}{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"command": "./.agent/hooks/format.sh"
}
]
}
}The matcher runs the hook only after file edits, and a fast format script replaces a slow full test run on every step.
Instructions are suggestions the model may skip. Hooks are scripts the harness always runs on an event, so they suit rules that must never be skipped.
Common events are session start, prompt submit, before a tool call, after a tool call and when the agent stops. Names differ between tools.
Yes, they run shell commands with your permissions. Review hooks in shared settings and plugins like any other code.