← ClaudeAtlas

pretooluse-proselisted

A PreToolUse Bash guard reads the whole command string, so it blocks prose that only mentions what it forbids. Use when a hook blocks its own install, or when writing a Bash matcher.
MrBinnacle/skills · ★ 0 · AI & Automation · score 62
Install: claude install-skill MrBinnacle/skills
# PreToolUse Bash Guards Match Prose, Not Just Commands ## Problem A `PreToolUse` hook on the `Bash` matcher receives the **entire command string**. That string routinely contains English: commit messages, `gh issue create` bodies, heredocs, comments. A guard written as `re.search(r"\bgh\s+issue\s+create\b", cmd)` therefore fires on ```bash git commit -F- <<'EOF' Three issues were created with `gh issue create --body-file -`. EOF ``` which invokes no such command. Worse, a guard that blocks a forbidden *phrase* will block the document that quotes the phrase **to forbid it** — so the fix for the anti-pattern cannot be committed. Measured instance, 2026-08-17: a newly written guard blocked the very commit installing it. The message described the CLI it policed and quoted the banned wording as an example. Two independent defects, one commit. ## Context / Trigger Conditions - A hook you just wrote blocks its own installation, its own tests, or its documentation. - `BLOCKED by <your guard>` appears on a `git commit`, `cat`, or `echo` that contains prose. - A guard fires on a heredoc body rather than on a command. - You are writing a `PreToolUse` matcher on `Bash` and your detection regex has no anchor. ## Solution **1. Anchor detection to a command position.** A command starts at the beginning of the string, or after a shell separator, optionally preceded by `VAR=value` assignments. ```python _CMD_POS = r"(?:^|[;&|]{1,2}|\n|\$\()\s*(?:[A-Za-z_]\w*=\S*\s+)*" CREATE_RE =