Block sensitive-file access inside PreToolUse hooks by exiting with code 2
SmartScope·medium signal
The old `decision/reason` JSON return format for Claude Code hooks is deprecated; the actual blocking mechanism is now an exit code 2 from a PreToolUse hook, which cancels the tool call. A short script can read the tool input via `jq -r '.tool_input.file_path'`, match against patterns like `\.(env|key|pem)$`, and `exit 2` to hard-stop reads/writes — a programmable guard that complements (and is more flexible than) static `permissions.deny` globs.