On this page · 6 sections
A Claude Code hook that quietly fixed my Bash commands got 236 calls refused by auto mode in three days. Auto mode reviews each call before it runs; my hook changed the command after that review, so the review no longer covered what would run. Switching the hook from fixing to refusing, with the fix in the message, made the auto mode refusals stop.
TL;DR
- Under auto mode, each call is reviewed before it runs. A hook that changes the command after that review gets the call refused: the review no longer covers what would run.
- Let the hook allow or refuse. Don't let it edit.
- Put the fix in the refusal, so the retry the model has to make anyway has something to act on.
The issue
Over 30 days my main Claude Code sessions (subagents not counted) ran 11,515 Bash calls. 4,587 of them started with a cd, and 894 of those went into the folder the call was already running in. A second habit: 90 sleeps of 30 seconds or more, about six hours of waiting.
An earlier hook of mine, three days old, already blocked some of them, and every block cost a turn while the model read the refusal and tried again. So on 10 November I wrote shell-hygiene, a small Claude Code plugin with two hooks: one that runs on every Bash call (tool.call), and one on agent.spawn that records which subagents share the session's folder. A subagent in a worktree runs somewhere else, so its cd is real and stays.
First try: rewrite the command
The first version didn't block. It dropped the cd and ran the rest, which looked cheaper. Twenty-nine minutes after it went live, auto mode started refusing calls:
a hook changed this call's input after auto mode reviewed it, so the review does not cover what would run.
The classifier, the part of auto mode that does the review, is right. It reviewed the command it saw, and the hook was about to run a different one. Each refusal cost a retry, and when the retry kept the cd it was refused again: 236 refusals over three calendar days (44, then 170, then 22), including in the sessions that built posts for this blog. The rewrite didn't make the habit go away either. On the day with the most refusals, subagents started about 173 calls with a same-folder cd, and nothing in a rewrite tells the model to stop.
The fix: refuse, with a hint
On 12 November I switched the hook to refuse, with the fix in the message:
shell-hygiene: drop the leading `cd <folder>`: Bash already runs in that folder. Re-run the rest of the command as is.
A foreground sleep of 60 seconds or more gets the same treatment: refused, with the Monitor tool or a background run offered instead. Shorter sleeps still run.
The change needed no restarts. Saving the plugin's manifest reloaded it in 11 open sessions, each with one line:
shell-hygiene: plugin.json changed — reloaded (modules: hooks/register.ts unchanged; 2 hooks: agent.spawn, tool.call)
The result
Update, 18 November: the classifier refusals stopped with the change. The last one came on 12 November, about half an hour before the new version's first refusal, and there have been none since. The habit faded but didn't go away. In subagents, calls that opened with a cd into the folder they already ran in fell from 8.1% of Bash calls on 10 and 11 November to 2.2% from 13 to 18 November. Each of those is now refused before it runs: 20 to 35 on a busy day.
How this helps you
- Under auto mode, allow or refuse; don't edit. Lydia Hallie's talk Rethinking Claude Code Best Practices puts it plainly: an instruction in the prompt is not a guarantee, so what must hold goes into the harness, as deny rules and hooks. Under auto mode I add one condition: the hook decides yes or no, and the command it decides on is the one that runs. When each hook fires was one of my lessons from studying for the Claude Certified Architect exam.
- Put the fix in the refusal. The retry costs the same turn either way; one sentence the model can act on gives that turn a use.
- Keep a log of what goes wrong. Three sessions wrote the same symptom to the papercuts log before a triage session traced the cause to my own hook.
One more thing
On 12 November, /doctor cut one project's CLAUDE.md from 88 to 73 lines and flagged a SessionStart hook taking six seconds at the median. The talk mentions a prompt audit in /doctor; I ran the plain one.



