Free resources · Rules and hooks
How to stop Claude from stating a guess as fact
Why Claude hands you a confident cause with nothing behind it, the CLAUDE.md rule we tested, and a short Stop hook you can test by hand in two minutes.
Why does Claude state a guess as fact?
Guessing pays. Most tests used to grade language models score a guess above an honest "I don't know", so models learn to guess when unsure. It sounds as calm as a checked fact: "the restarts are caused by a memory leak" reads the same whether or not Claude saw your logs.
Does a rule in CLAUDE.md stop it?
A rule helps, and a specific rule is followed more consistently than a vague one. Claude Code loads CLAUDE.md at the start of each session as context, with nothing forcing Claude to obey it. In our view, "Never guess" gives Claude nothing concrete to do. This rule, in your project's CLAUDE.md, gives it a sentence to write and a next step:
Never state a guess as fact. When you have no evidence for a cause, write "no verified cause" and name the command or data that would give one.
In our test, four of the five replies with the rule that we read by hand opened with "No verified cause." and listed what to collect, such as each restart's exit code.
What is a Stop hook?
A Stop hook is a script Claude Code runs each time Claude finishes a reply, with the reply's text as input.
If the script ends with exit code 2, Claude does not stop. An exit code is the number a script returns when it ends, and 0 means all is well. Claude reads what the script wrote to its error output, called stderr, as the reason to keep going. On that second pass the input's stop_hook_active field is true, and the script's first check lets the reply through, so each reply goes back once at most.
What did our test find?
We asked Claude Haiku 5.5 ten debugging questions it could not answer without data, such as why a service keeps restarting. Each was asked three times with no rule, with the rule above, and with the rule plus a Stop hook that sent a reply back once if it held one of 16 guess phrases, such as "probably".
- The rule mostly changed the wording. Replies that said the cause was unverified went from 11 of 30 to 28 of 30, a count that includes the rule's own phrase "no verified".
- With the hook, none held one. Replies holding a guess phrase went from 7 of 30 with no rule and 5 of 30 with the rule alone to 0 of 30 with both.
- Softer words did not take their place. Ones such as "could be" and "perhaps" fell from 0.4 per reply to 0.1 with the rule and stayed at 0.1 with the hook.
We tested one model, with no built-in tools and our own phrase lists, so unlisted soft words went uncounted. And with 30 replies each, the hook's drop from 5 to 0 could still be chance.
What can a phrase list not catch?
It misses a confident wrong answer that uses no guess word. "The cause is a memory leak." holds none of them, so it passes. Smooth wording does not prove it is right. In our view the hook catches easy slips; only reading a few replies yourself catches the rest.
How do you try a guess hook in two minutes?
The script below is our own wording, untested in Claude Code: a short bash version of the test hook with four of its 16 phrases.
- Make a new folder and save this in it as guess-gate.sh, as plain text (in TextEdit, choose Format > Make Plain Text first). Open Terminal there: type cd and a space, drag the folder onto the window, and press Return.
#!/bin/bash # Stop hook: sends a reply back once when it holds a guess phrase. input=$(cat) if echo "$input" | grep -q '"stop_hook_active": *true'; then exit 0 fi if echo "$input" | grep -qiE 'probably|most likely|i think|i suspect'; then echo "That reply guesses. Check the fact, or write no verified cause and name the data that would give one." >&2 exit 2 fi exit 0
- Run these two lines. Each feeds the script a sample reply and prints the exit code:
echo '{"stop_hook_active": false, "last_assistant_message": "The restarts are probably a memory leak."}' | bash guess-gate.sh; echo "exit code $?"
echo '{"stop_hook_active": false, "last_assistant_message": "No verified cause. The exit code and signal of each restart would give one."}' | bash guess-gate.sh; echo "exit code $?"- The "probably" sample exits 2 with the reason; the other exits 0 in silence. This tests the script by hand; it does not yet turn it on in Claude Code.
- Then run the first echo line with a real reply of yours in place of the sample, private details and any apostrophes (') removed, since they end the quoted text early. If the prompt changes to dquote> or >, press Control-C and try again. It exits 2 only on the four phrases.
Where is the full answer?
- Why a script holds where a rule slips: hooks that beat written guidelines.
- When the guess is about a document: ask Claude to quote your document first.
- Before you tighten your rule: how tight a reply rule can be.
Check that your hook blocks
- First sample: one line, "That reply guesses. Check the fact, or write no verified cause and name the data that would give one.", then "exit code 2".
- Second sample: nothing from the script, then "exit code 0".
- If you see "No such file or directory", you are in the wrong folder, or the file name is not exactly guess-gate.sh.
- "exit code 2" with any other message, such as "command not found", means the file was not saved as plain text.