A CLAUDE.md file is not a control, because Anthropic's documentation says Claude treats it as context, not enforced configuration. Treat governance as three tiers: advisory files and skills, hooks that enforce through exit codes, and CI gates. Anything that must never happen belongs in a PreToolUse hook, not in the instruction file.
The instruction file feels like control
You have written a careful CLAUDE.md, or the equivalent instruction file for whatever agent you run. It states the rules plainly. Never touch this directory. Always run the tests before claiming a task is done. Ask before deleting anything. The agent reads it every session. Most of the time it follows it. That feels like control, and for a single short session, it mostly is.
It stops feeling like control the moment a build runs unattended for longer than an afternoon.
The probabilistic reality
An instruction file is a prompt, and a prompt is read probabilistically, not enforced deterministically. Anthropic's Claude Code memory documentation says Claude treats CLAUDE.md files "as context, not enforced configuration", and points to a PreToolUse hook for blocking an action regardless of what Claude decides. Three drift modes are worth naming individually. A rule gets ignored mid-execution because something else in the moment felt more pressing. A rule gets forgotten as the context window fills up and eventually compacts. That takes detail with it. A rule gets skipped, because the model judges, in that specific instance, that it does not apply.
None of that makes the instruction file worthless. It makes it the wrong tool for anything that must never fail.
Three tiers, not one
Treat agent governance as three separate tiers, and never let anything load-bearing rely on tier one alone.
Tier one is advisory. CLAUDE.md and skills both live here. A skill is a folder with a SKILL.md file that the agent loads on its own when a task description matches. That is genuinely useful for procedural knowledge you do not want to keep re-explaining every session, and without permanently spending context on it. But a skill still teaches. It shapes what the model is likely to do. It does not change what the model can do, and that distinction is the whole tier.
Tier two is hooks. A hook is a shell command the agent's own runtime executes at a fixed point in its lifecycle. It receives the event as JSON on stdin and answers with an exit code, entirely outside the model's own judgement. This is enforcement rather than persuasion, and it is where anything that must never happen actually has to live.
Tier three is gates. CI blocking a merge until a check passes. That only counts as a control once it has been proven to fail on a deliberately planted defect. The failure to guard against is a check that is green because it measures the wrong thing. An assertion that every database table has a security policy attached, for example, says nothing about whether any of those policies can ever be evaluated. Plant a deliberate defect and confirm the gate fails on it. The wider case for governing unattended builds in tiers is in architecting autonomous AI builds.
The hook mechanics that actually matter
PreToolUse fires before any tool call executes. Exit 0 and the call proceeds. Exit 2 and the call is blocked, with the stderr message handed back to the agent as the reason it was refused. Three details catch people the first time they wire one up.
Exit 1 does nothing useful. It reads as the natural choice, since it is the conventional Unix failure code. But Claude Code treats it as a non-blocking error, and the action proceeds anyway. Anything security-critical needs an explicit exit 2. Exit 0 is the intended code when a hook prints structured JSON. On exit 2, the stderr text is what the agent receives, so the real reason has to be written there, and any JSON fields printed alongside cannot override the block. Blocking is not the same everywhere. PreToolUse denies a call outright so it never runs at all. A Stop hook exiting 2 prevents the current turn from ending. It sends the agent back to work with a reason, but the action itself has already happened. That makes it a strong prompt rather than a wall.
That last distinction decides where a rule belongs. Anything that must never happen under any circumstance goes in PreToolUse. Anything that is a strong preference the agent should reconsider can live in a Stop hook instead, anything it might occasionally have a legitimate reason to override. Confusing the two is how a team ends up with a rule they believed was absolute. They discover only afterwards that it was a suggestion the whole time.
Where this leaves the instruction file
Keep CLAUDE.md. It is still the fastest way to teach house conventions, and most of what an agent does in a session is exactly the kind of judgement call. An instruction file is good at shaping that. Just stop asking it to be the reason a security boundary holds. A rule that only lives in a document the agent reads is a rule the agent can fail to follow, and still believe it did, on a bad day inside a long compaction cycle.
The harder discipline sits one tier up from hooks, in how you prove a gate is actually catching anything rather than passing by accident. That failure mode is its own separate problem, a check that has never once failed. It is covered here: why a control that has only ever passed is not a control. For the full setup, with advisory files, hooks and gates in three tiers, read the longer write-up on the Lead Source blog about architecting autonomous AI builds.
| Tier | What it is | Does it enforce? |
|---|---|---|
| Advisory | CLAUDE.md and skills | No: it shapes what the model is likely to do, not what it can do |
| Hooks | A shell command the runtime executes at a fixed point in the lifecycle | Yes: it answers with an exit code, outside the model's judgement |
| Gates | CI blocking a merge until a check passes | Only once proven to fail on a deliberately planted defect |
Written by the team at Lead Source, where the day job is lead source tracking: working out which marketing actually brings customers.