Hard-enforcement dependency install guard for AI coding agents and developers.
AI coding agents install packages before anyone reviews them. Attach Guard intercepts package installation commands and evaluates them against policy before execution.
attach-guard evaluates:
[email protected] FAIL (published 1 hour ago, minimum age is 48 hours)
[email protected] PASS (30 days old, supply chain score 92)
Result: ASK + rewritten command
npm install [email protected]
Most security tools just say "no." Attach Guard says "no, but here's a safe alternative."
Package is safe
Install proceeds normally
Latest is risky, older version is safe
Shows safe alternative, user confirms
All versions fail (malware, all too new, etc.)
Blocked with clear explanation
Not an advisory scanner. A hard enforcement boundary that sits directly in front of npm install and blocks risky packages before execution.
When a risky version is blocked, attach-guard finds the newest version that passes policy and offers it as a replacement. Your flow doesn't stop.
When the risk provider is unavailable, attach-guard denies in CI and asks in local mode. No silent pass-throughs.
Every decision is logged to a local JSONL audit trail with timestamps, scores, and reasons. Complete accountability.
Attach Guard is a Claude Code hook, not a skill or MCP server. The distinction matters:
Hooks
Run automatically on every matching tool call. Enforce rules deterministically — Claude cannot skip or override them.
Skills
Instructions Claude follows when invoked. They guide behavior but cannot block actions.
MCP Servers
Provide advisory context. They inform but do not enforce.
Every package goes through an ordered policy evaluation:
# Build and install
go build -o attach-guard ./cmd/attach-guard
sudo mv attach-guard /usr/local/bin/
# Set your Socket.dev API token
export SOCKET_API_TOKEN="your-token"
# Initialize default config
attach-guard config init
# Add the Claude Code hook to .claude/settings.json
{ "hooks": { "PreToolUse": [{ "matcher": "Bash", "hooks": [{ "type": "command", "command": "attach-guard hook" }] }] } }
Intercepts npm install, npm i, pnpm add, and their variants.
Works as a PreToolUse hook. Claude cannot skip or override the guard.
Every allow, ask, and deny decision logged with full context for compliance.
Open source, local-first, zero config. Get Attach Guard running in under five minutes.