# An instruction asks. A hook checks. A small A/B on a real task: 34 KB of repo instructions got the same score in about 42% fewer turns. What blocked a bad action was a hook, not a rule. Published 2026-10-31. Canonical: https://richardmurillo.com/blog/instruction-asks-hook-checks/ In early June 2026, a hook blocked my coding agent from committing work it had not verified. I was landing a pull request about what repo instructions change. I kept one line about the block in the pull request. The hook gives me one example of enforcement. The tests below measure a different question: what happens when I change the agent’s instructions. ## When the agent skips a rule Your agent skips a rule in `CLAUDE.md`. You bold the rule, repeat it at the bottom, and add three more. The file grows. The agent skips the rule again. An instruction tells the agent what to do. A blocking check controls whether an action goes through. ## The test I ran an A/B test in early June in [ai-agents](https://github.com/rjmurillo/ai-agents). The setup lives in [this memory file](https://github.com/rjmurillo/ai-agents/blob/main/.serena/memories/instruction-context-efficiency-not-quality.md) and [PR #2499](https://github.com/rjmurillo/ai-agents/pull/2499). - I ran `claude -p` from outside the repo to keep its `.claude/rules` out of the startup context. - I varied one thing: the instruction context I appended. - I scored each run with the compiler and hidden tests. - The task was to reproduce the Moq1600 analyzer from [moq.analyzers PR #1088](https://github.com/rjmurillo/moq.analyzers/pull/1088). I used [issue #579](https://github.com/rjmurillo/moq.analyzers/issues/579) as the spec. The docs from the pull request would have given away the answer. The control arm got no repo instructions. The treatment arm got the repo's own 34 KB `copilot-instructions.md`. ## What happened Both arms passed 112 of 120 hidden tests. The same 8 `It.Ref` cases failed in each run. The control arm took about 50 turns. The treatment arm took about 29. That is about 42% fewer turns for the same score. ## What five runs tell us The control arm had 3 runs. The treatment arm had 2. At temperature 0, the scores repeated. Five runs on one task show what happened in that setup. They leave open what happens on other tasks. I tested 56 KB of generic design rules on a refactoring kata. Sonnet scored 8 of 8 on the easy version and 14 of 14 on the hard one, with or without the rules. Haiku scored 14 of 14 on the hard version without the rules. ## The rules that loaded and weren't supposed to I meant to limit some rules to certain file types. My `.claude/rules` files used `applyTo` and `alwaysApply`, which are GitHub Copilot and Cursor keys. Claude Code uses `paths` to scope rules. A rule without `paths` loads in every session. That put all 252 KB of rules into each session. I fixed the scope keys in early September in [PR #5496](https://github.com/rjmurillo/ai-agents/pull/5496). The script [`check_rule_scope_keys.py`](https://github.com/rjmurillo/ai-agents/blob/main/scripts/validation/check_rule_scope_keys.py) fails the build if a rule in that tree uses `applyTo`, `globs`, or `alwaysApply`. ## Where the hook fits, and where my evidence stops The A/B test varied instructions. The hook evidence comes from one event: the gate blocked an unverified commit. I have no comparison run for the hook. The [hook source](https://github.com/rjmurillo/ai-agents/blob/b57a25ffcf7850cd2a60be2731eb93a185ba73be/.claude/hooks/PreToolUse/invoke_false_completion_gate.py) shows what it checked. It watched for `git commit`, `gh pr create`, and `gh pr merge`. If the commit message or PR text claimed "done" or "fixed", the hook looked in the session log for a test run, build check, or PR check. If it found no evidence, exit code 2 blocked the tool call. ## The price of a gate In August, I retired every tool-call hook in [PR #5172](https://github.com/rjmurillo/ai-agents/pull/5172) under ADR-097. Each hook launched a Python process on a tool call. On my Windows machine, a cold start took about 250 ms, and more during Defender’s real-time scanning. I combined some of the launches, but tool calls were too slow for me. [PR #5172](https://github.com/rjmurillo/ai-agents/pull/5172) records what plugin users lost. A subagent can inherit the session model if the caller omits a model. A Serena write can land in the wrong worktree. A gate can block the wrong work. In [issue #5013](https://github.com/rjmurillo/ai-agents/issues/5013), a bug blocked 127 unrelated Bash commands over 21 minutes before I caught it. A hook costs time on every call and needs maintenance. On my machine, tool-call hooks cost more than I wanted to pay. I kept Git hooks and CI checks for commits. The scope-key check runs in the build. Choose the least costly point that can block the mistake. ## What I'd do with this When an agent skips a rule, identify the action a check should block. 1. **Name the action.** A script can look for a commit message that says "fixed" and a session log with no test run. 2. **Block the action.** A warning leaves the choice with the agent. 3. **Choose where the check runs.** Tool hooks, Git hooks, CI jobs, and build steps differ in cost and in when they catch the mistake. 4. **Keep instructions small.** The 34 KB of repo instructions cut turns in my test. The 56 KB of generic rules left the kata scores unchanged. 5. **Test the check.** Give it an action it should reject. Confirm that it blocks the action. ## Matt Kotsenas said this first In February, Matt Kotsenas wrote in [The Control Paradox](https://matt.kotsenas.com/posts/the-control-paradox/): "Agents will claim success without evidence. Make verification blocking, not advisory. No PR without passing tests, no 'done' without proof." He asked for a "hermetic mode" that isolates a session from machine state such as user instructions. Running from outside the repo was my attempt at that isolation. ## How this could be wrong - If a prose-only arm changes the hidden-test score, I need to revise my claim about this task. - If more runs erase the turn gap, the five-run result will have overstated the effect. - If the target action gets through, fix the gate or move it to a point where it can block. This is the first batch of numbers I promised in [my capability post](https://richardmurillo.com/blog/capability-not-competence/). For an example of moving a check earlier, see [Move the deployment failure to the keystroke](https://richardmurillo.com/blog/move-the-failure-to-the-keystroke/). If a gate stopped a mistake or an instruction improved a run, [open an issue on ai-agents](https://github.com/rjmurillo/ai-agents/issues/new) with the example.