1 link tagged with all of: ai-agents + agent-hooks + code-generation + ratchet-test + guardrails
Links
The article shows how to use agent hooks in Claude Code to enforce strict, 100% reliable rules during code generation. It walks through a PreToolUse hook to block raw <input> tags and a Stop hook to prevent finishing until a design-system ratchet test passes.
- A PreToolUse hook can grep tool_input.content/new_string for banned patterns like raw `<input>` tags and exit code 2 to block the write entirely, guaranteeing consistent component usage instead of relying on ignorable CLAUDE.md instructions.
- A Stop hook can run a real test (e.g. a design-system ratchet test) before letting the agent end its turn, exiting 2 to force continued work if the test fails, preventing premature "done" claims.
- These hooks intercept actions at the exact moment they happen, making enforcement deterministic rather than dependent on written rules or later lint/CI catches.
- Silent failures are a real risk—an incorrect jq path returns null and lets bad code through unnoticed, so hooks must be validated against actual payloads.
ai-agents
agent-hooks
guardrails
code-generation
ratchet-test