Overview
A review hook on Bash can still miss the first shell command a skill runs. Claude Code executes that command while the skill file is loading, before the model reads the skill, and PreToolUse does not fire for it. The hook that can stop the command is PreSkillShellCommand. Anthropic’s hooks reference says it requires Claude Code 2.1.332 or later, in the terminal, the desktop app, and the VS Code extension.
The changelog dates that version to 25 November 2026. The GitHub release was published at 01:32 UTC the same day. On 2.1.331 and older, putting the new event name in a settings file does not block the command. Each interactive terminal session opens a warning that the hook was ignored, and the command still runs.
The steps below follow Anthropic’s documentation. This article did not run the hook on a machine. Where a message is quoted, it is the message those docs say you should see.
The command runs before the model reads the skill
In the skill file, the command is easy to overlook. A line that begins with an exclamation mark and a backtick, or a fenced block opened with an exclamation mark, is an injected command. Claude Code runs it and pastes the output into the skill, so the model sees the result rather than the command text. The skills documentation calls this dynamic context.
The inline form runs only when the exclamation mark is at the start of a line or immediately after whitespace. If it sits against another character, Claude Code leaves the line as text and does not run it. Substitution happens once, over the original file. A command cannot print a second placeholder for a later pass to expand.
These commands never ask for permission while the skill is rendering. Claude Code checks your permission rules first. A command that matches a deny rule aborts the whole invocation. The message begins Shell command permission check failed for pattern, then quotes the pattern. Outside auto mode, any permission result other than allow also aborts the invocation. You can pre-approve a command in the skill’s allowed-tools list, but a matching deny rule or ask rule still aborts.
The new hook sees only the commands that pass that check. It also runs in bypassPermissions mode. It can block a command. It cannot approve one, and it cannot change the command text.

Check 2.1.332 before you name the hook
In a terminal, run claude --version. You want 2.1.332 or a later release. Anthropic’s settings reference treats claude update as the command that moves a native or npm install forward, and claude update still works when an organization has set a version floor, so you can recover. Update first if the number is lower. If you add the hook name on 2.1.331 or older, the hooks reference says each interactive terminal session opens a dialog reading Unknown hook event "PreSkillShellCommand" was ignored. The injected commands still run. Update, then add the hook, then start a new session so you are not looking at the old binary.
An organization that manages many installs can also set requiredMinimumVersion to 2.1.332 in managed settings. That key makes an older copy exit at startup and tell the person to update through the organization’s approved method. Claude Code ignores the key outside managed settings, and the check itself needs version 2.1.163 or later. It does not install the hook. A session that is already running keeps going, because the check runs at startup only.

Put the same review on the load step
Define the hook in a settings file you control, such as the project’s .claude/settings.json, your user settings, or managed settings. A plugin can define it too. Do not rely on a hook that lives only in the skill’s own frontmatter. On the first load in a session, and on loads inside a subagent, Claude Code runs the skill’s injected commands without those frontmatter hooks. A forked skill also skips hooks in its own frontmatter and in its subagent’s definition.
Match both Bash and PowerShell. Those are the two tools that run injected commands. Which one you get depends on the shell key in the skill and on the machine. A skill that asks for bash on Windows without Git Bash fails before any command runs, and the message says Git Bash was not found. Every other combination uses Bash when bash is available, and PowerShell when it is not.
Use a command, HTTP, or MCP tool hook, and do not mark it async, because an async hook cannot block. A prompt hook or an agent hook on this event cannot run. Claude Code then blocks every command that hook matches. That is a blanket stop, not a review of the command text.
Set onFailure to block. If the hook crashes or times out and that field is missing, the command runs. The hooks reference notes one Windows exception: without Git Bash, a shell-form hook on this event that fails with onFailure unset can block the action instead. In a Code Mode session where code has already run, a timeout blocks the command by default.
Anthropic’s documented entry for macOS and Linux points the hook at a script in the project. Paste it into the settings file, and change the script path if your review script lives somewhere else. On Windows, use the command and args from the Windows example on the same page rather than pasting a shell path.
{
"hooks": {
"PreSkillShellCommand": [
{
"matcher": "Bash|PowerShell",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/block-rm.sh",
"args": [],
"onFailure": "block"
}
]
}
]
}
}
If one script should serve both PreToolUse and this event, leave hookEventName as PreToolUse in the JSON it prints. A script used only here can set hookEventName to PreSkillShellCommand. Exit code 2 blocks the command. So does permissionDecision set to deny, or a top-level decision of block. Put the reason on stderr when you exit 2, or in permissionDecisionReason. While Remote Control is connected, the hook still blocks, but neither you nor Claude sees the reason. It goes to the debug log.
The hook’s input is enough to make the review specific. Besides the command text in tool_input.command, the payload includes command_name, such as the skill you typed, and command_source, which can be user settings, project settings, policy settings, a plugin, or a builtin skill. invoked_by says whether you typed the skill, Claude or a scheduled task invoked it, or something else did, such as a subagent preloading the skill. A script can block plugin skills and leave a project skill alone. That split is in the hooks reference. It is not a script this article ran.
What a successful block looks like
Anthropic’s published check does not delete files. Create a skill file at .claude/skills/hook-test/SKILL.md and put this single line in it. The echo command prints the words rm -rf. It does not remove anything.
!`echo 'rm -rf'`
Open a new terminal session in that project and type /hook-test. The hooks reference says the terminal should show this line:
Not run in /hook-test: echo 'rm -rf' (blocked by hook: Destructive command blocked by hook)
That line is the check. The skill still loads. In place of the command output, Claude reads a note that begins [not run: blocked by hook: ], with your reason after the colon. When you type the skill name yourself, the terminal reports a Not run in / line for the blocked command.
If you instead see Ran anyway in /, the command ran because the hook failed or timed out. Fix the script, keep onFailure set to block, and start a new session.
A few answers do not mean what they mean on PreToolUse. An allow decision lets the command run unless another hook blocks it. An ask decision, a defer decision, or any attempt to rewrite the command is treated as a deny. You cannot edit the command from this hook. Setting continue to false stops the whole invocation. The message begins Operation stopped by hook. None of the skill’s injected commands run, because Claude Code collects every hook answer before it runs the first command.
What still gets through
Auto mode is the gap that still needs the older hook. If a command would have needed approval, auto mode does not run it while the skill loads, and it does not abort the skill. The skill loads with an instruction telling Claude to run the command first. That later call is a normal tool call. It fires PreToolUse, not PreSkillShellCommand. Keep the script registered on both events.
Two cases still abort instead of deferring. A forked skill that sets an agent aborts. A session that does not have the shell tool those commands use also aborts. A failed command is a different stop. The invocation aborts, Claude never sees the skill content for that attempt, and the message begins Shell command failed for pattern, with the command output included. With the default bash shell, exit code 1 from the search and comparison commands listed in the tools reference counts as a normal result. Other non-zero exits fail. Exit codes of 2 or higher fail even for those search commands.
Some skills never run these commands, so a missing hook is not the problem. In the terminal and in VS Code, a skill synced from a claude.ai account does not run exclamation-mark commands. That has been true since version 2.1.228. The line reaches Claude as literal text, or as the policy placeholder if shell execution is turned off. In a Cowork session on the desktop, Claude Code replaces every such command in a skill you supply with that same placeholder.
Turn every load command off
If you want this class of command stopped, rather than reviewed one by one, set disableSkillShellExecution to true in settings. Claude Code replaces each inline command from user, project, plugin, or additional-directory skills and custom commands with the text [shell command execution disabled by policy]. It does not run them. Bundled skills, and skills deployed through managed settings, are not affected. A true value in managed settings cannot be turned off by a false value in a user or project file. The default is unset, which means the commands run.
{
"disableSkillShellExecution": true
}
The switch is broader than the hook. The hook can allow a command you wrote, such as git status inside your own skill, and block one you did not expect. The switch stops all of them from those sources. To undo the switch, remove the key or set it to false in a file that is allowed to override it. To undo the hook, delete that event from the settings file and start a new session. Neither change rewinds files a skill already edited.
Conclusion
Run claude --version before you trust a Bash review hook with a skill. On 2.1.332 or newer, add the same script to PreSkillShellCommand, match Bash and PowerShell, set onFailure to block, and leave the script on PreToolUse for the auto mode case. Then run the documented hook-test skill. A Not run in /hook-test line means the load command was blocked. A warning dialog, or a Ran anyway line, means it was not.
If you would rather not review these commands, turn on disableSkillShellExecution, and remember that bundled and managed skills still run theirs. Installing a Claude artifact as an app is a separate choice about which files that app can open, covered in How to Install a Claude Artifact as an App Without Giving It Your Files.


