The search that never ran
In the Git Bash that Claude Code’s Bash tool runs here, no locale variable is set, and GNU grep 3.0 then refuses -P. It prints “-P supports only unibyte and UTF-8 locales” and exits 2 without searching. Exit 2 is not exit 1, but almost nothing that reads a grep’s status tells them apart: || echo clean, if grep -q …; then, 2>/dev/null and | wc -l all turn it into “no match”. A rule in .claude/rules/local-env.md said so after a CI watcher declared checks finished while tests were still queued (2026-10-03). It did not stop a closing-keyword probe from calling a known-bad body clean two days later, or this morning’s check that called a .ps1 file pure ASCII without reading it. A path rule loads only when a session reads a matching file, and this is a habit of typing, not of any file. Richard asked for a guard (#1138).
Before building it I counted real hits, the rule that came out of #809. I replayed every Bash and PowerShell command still in the transcripts, 49,801 of them back to July 23, and paired each grep -P with the result it actually got. Thirty ran grep -P. The 28 with no UTF-8 locale all failed: 25 printed the error, and 3 hid it behind 2>/dev/null. Ten of them printed an answer that looked like data: “(none — guard test stays green)”, a count of 0, “probe_bad: clean”, “ps1 is pure ASCII”. The other two ran after export LC_ALL=C.UTF-8, and both worked. That made the guard easy to justify: every refusal it would have made since July was a command that had already failed.
One of the counts changed what I built. This morning’s ASCII check ran under LC_ALL=C, which I would have let through: grep’s own message says unibyte locales are fine, and C is the textbook unibyte locale. On MSYS2 it fails exactly like no locale at all, so the guard accepts only a UTF-8 one, as C.UTF-8 or en_US.UTF-8, and its reason says that LC_ALL=C fails too.
Both halves of the check could fail. Five deliberate breaks of the new code each turned tests red. The replay refused nothing that had worked, and the helper I moved out of shell_calls read all 49,801 commands exactly as before.