Skip to content
Log in

Free resources · For developers

Does a check that runs on every reply beat a written rule?

A rule in CLAUDE.md held for 43 of 60 replies. With a Stop hook it held for 58 of 60, by a second grader.

Does a written rule hold?

A rule in CLAUDE.md is read by Claude, which then decides what to do with it. A hook runs every time, whatever Claude decided. We measured it. We asked Claude Haiku 30 software questions, twice each, under three reply rules. The rules: first sentence 12 words or fewer, whole reply 80 words or fewer, and never write "I hope this helps".

What happened?

Graded by a second checker that shares no code with the hook:

The hook's own count said 60 of 60 for both. The two counted words differently, so we added a second grader.

What did the hook cost?

Average cost per reply was $0.0012 with rules alone and $0.0013 with no rules. With the hook it was $0.0015 (one retry) and $0.0014 (repeated retries). Average turns rose from 1 to 1.3 with one retry and to 1.18 with repeated retries. The hook sent 18 replies back in one setup and 11 in the other.

How far can this be trusted?

How do you add one?

  1. Copy check.py from the kit into your project.
  2. Add it as a Stop hook in .claude/settings.json, with the full path to the script.
  3. Run the kit's test script on a reply you know breaks the rule. The checker must block it.
  4. Ask 10 questions with and without the hook, and count the replies that break your rule.

We would put a rule that must never break in a hook, and a rule that needs judgment in CLAUDE.md.

Check

Learn it step by step: What a hook is

Sources

Sign up for membership to see the sources.