Free Claude Code hook flags risky prod, data and money commands before they run
A Node.js script can be attached to Claude Code to inspect each Bash command before execution and sort risky ones into three tiers: high risk, warning, and caution. Commands in the high-risk tier cover production or staging changes, data writes, and destructive operations, while warning covers spending on paid services and caution covers recoverable but disruptive local actions. Until the agent writes a risk flag in the chat and re-runs the command with an explicit acknowledgement, the hook denies the command. The hook is installed by saving the script locally and adding two entries to the Claude Code settings file. The parser is quote-aware and follows nested shell invocations, and it allows low-value cleanup like removing build folders without a flag.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in