#!/usr/bin/env bash # Claude Code PreToolUse hook (Bash): package installs in this repo must go # through Socket Firewall (sfw), which checks every package -- transitive ones # included -- against socket.dev before npm downloads it. set -uo pipefail cmd=$(jq -r '.tool_input.command // ""' 2>/dev/null) # A bare npm install/add/update/ci, not already wrapped in sfw. if grep -Eq '(^|[;&|(]|\s)npm\s+(install|i|add|update|up|upgrade|ci)(\s|$)' <<<"$cmd" && ! grep -Eq '(^|[;&|(]|\s)sfw\s+npm\s' <<<"$cmd"; then echo "Package installs in this repo go through Socket Firewall: use 'sfw npm …' or 'npm run deps:install' / 'npm run deps:add -- ' / 'npm run deps:update'." >&2 exit 2 fi exit 0