Claude Code hooks on Windows: when a Bash matcher sees nothing
A reader spotted a Windows gap in my earlier article about blocking destructive shell commands in Claude Code. The hook matched Bash . On a machine where Claude uses its PowerShell tool, that hook can miss the command entirely. The previous article now includes the correction . This follow-up explains the two configuration issues involved: which tool triggers the hook, and what happens if the…
This follow-up article addresses two configuration issues related to blocking destructive shell commands in Claude Code on Windows. The first issue is that the hook can miss the command entirely when Claude uses its PowerShell tool on a machine where Bash is not registered. The second issue is that the original guard.py only understands POSIX-style commands, so PowerShell commands remain outside its coverage.
To correct these issues, the matcher should be updated to match both Bash and PowerShell tools. The hook needs to be able to run successfully, which means checking that the Python executable is installed, the script path is correct, and the process does not crash. If the hook fails to start, setting onFailure to block will prevent the triggering action from proceeding through the normal permission flow.
However, this configuration does not provide coverage for PowerShell commands as the original guard.py only understands POSIX-style command syntax. Adding PowerShell to the matcher does not teach the script to understand PowerShell grammar, aliases, parameter binding, or command composition. PowerShell coverage requires an appropriate implementation and separate verification.
The settings change does not provide this additional coverage. It is important to verify each boundary with harmless commands before relying on this setup. This setup should be considered a POSIX guard with corrected routing and failure handling until PowerShell analysis is implemented and verified.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.
This story
This is one outlet's version. Read the fullest account.
- I recorded 87 Claude Code sessions to find out where the money goes dev.to
- Gemini is replacing Gems with Skills, so I moved my Claude Code skills over to test them xda-developers.com
- Anthropic confirms new Claude Code limits to prevent game cloning — users report Opus 5.5 is also actively blocking reverse engineering tasks tomshardware.com