Urgent.News

What's breaking now, across thousands of outlets.

AI

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.

Read the original at dev.to →

More in AI

More from Monday 2 November →