Agent Hooks as Guardrails
TrialFactorial rates Agent hooks as Trial (2026). Our rule of thumb: if something must always hold, it belongs in a hook or a permission allowlist, not in a prompt.
Coding agents such as Claude Code can run shell scripts at fixed points of a session: when it starts, when a prompt is submitted, before and after a tool call, and when the agent stops. A hook can block a command, rewrite it, add context or run a check, and it does so every time, regardless of what the model decides.
Hooks complement agent context files and skills: instructions tell the model what it should do, hooks guarantee what must happen. Typical uses are blocking destructive commands, running formatters and linters after edits, injecting project context and compressing command output.
Updates
Our rule of thumb: if something must always hold, it belongs in a hook or a permission allowlist, not in a prompt. Some of us route shell commands through RTK with a hook to cut token use, add context when a session starts or a prompt is submitted, and keep allowlists for the read-only commands an agent may run without asking. We distribute hooks with the skills in our company plugin. The open question is how far to push them: every hook runs on every step, so a slow or overly strict hook gets in the way quickly.