During last week's AIS+ Chill, Chat & Chaos session, there was an intense and insightful discussion on governance while using AI agents - how can we ensure that the rules that we set for the agents are indeed followed.
After the session i went back and had a deeper look into a multi-agent dev pipeline that I am working on, and this stopped being theoretical fast.
The case that made it concrete: a "bug-fix" agent whose entire job is turning a failing test green. Left unconstrained, the fastest path from red to green is always deleting the test - and it looks exactly like success.
Here's the split I ended up with:
→ A markdown instruction (a CLAUDE.md, an AGENTS.md, a system prompt) is read by the model and usually followed. It's advisory - under context pressure, compaction, or a judgment call the model makes in the moment, it can be skipped, and nothing tells you that happened. → A hook is executed by the platform itself, not the model. It fires every time the trigger condition happens, independent of what the model decides.
In Claude Code that's a PreToolUse/PostToolUse/SessionStart/Stop hook, configured once, outside the model's control.
Rule of thumb I landed on: if the condition is binary and mechanically checkable - a file path, a line count, whether a file exists, a command pattern - hook it. If it needs judgment about intent, it has to stay a markdown instruction, and you accept that it's probabilistic.
Back to the bug-fix agent: "don't touch the tests" has to be a hook, not a prompt instruction - because the one time it matters most is exactly the time you can't verify it happened just by reading the output.
Curious how others are drawing this line - where do you find yourself reaching for a hook instead of an instruction?