Don't rely on instructions; use Agent Hooks to enforce guardrails
9 hours ago
- #Guardrails
- #Deterministic Checks
- #Agent Hooks
- Agent Hooks enforce guardrails deterministically during agent workflow, unlike CLAUDE.md instructions which agents may ignore.
- PreToolUse hook blocks raw <input> tags by checking content before writing, ensuring use of custom components.
- Stop hook prevents agent from finishing until a design-system ratchet test passes, avoiding premature completion.
- Hooks are invoked at specific workflow points (e.g., before tool use or at stop) and can block actions or continue work based on exit codes.
- Hook implementations use JSON input via stdin, parsed with tools like jq, and require careful testing to avoid silent failures.