The CLAUDE.md ### Token hygiene section is the headline rule plus the canonical env-var name; this file is the full spec and the surrounding placeholder / cross-repo-path conventions.
Never emit the raw value of any secret to tool output, commits, comments, or replies. The .claude/hooks/token-guard/ PreToolUse hook blocks the deterministic patterns (literal token shapes, env dumps, .env* reads, unfiltered curl -H "Authorization:", sensitive-name commands without redaction). When the hook blocks a command, rewrite — don't bypass.
Behavior the hook can't catch: redact token / jwt / access_token / refresh_token / api_key / secret / password / authorization fields when citing API responses. Show key names only when displaying .env.local. If a user pastes a secret, treat it as compromised and ask them to rotate.
Full hook spec in .claude/hooks/token-guard/README.md.
Tokens belong in env vars (CI) or the OS keychain (dev local) — nowhere else. Never in .env / .env.local / .envrc / ~/.sfw.config / ~/.config/socket/* / any dotfile. Dotfiles leak via accidental commits, file-indexers, backup clients, shell-history dumps. Enforced by .claude/hooks/no-token-in-dotenv-guard/.
- Initial setup:
node .claude/hooks/setup-security-tools/install.mts(prompts + persists via macOS Keychain / Linux libsecret / Windows CredentialManager). - Rotation:
node .claude/hooks/setup-security-tools/install.mts --rotate— TTY-muted prompt, overwrites the keychain entry unconditionally, ignores stale dotfile / env-var lookup. This is the ONLY correct rotator. Suggesting any other path (socket login, hand-editing~/.sfw.config,export SOCKET_API_TOKEN=…in a shell rc) is a token-hygiene violation.
The Stop-hook flags broken sfw shims, free-vs-enterprise edition drift, and 401-rejection patterns from the last assistant turn (enforced by .claude/hooks/setup-security-tools/).
Four entrypoints share the umbrella installer library for operators who want partial installs:
.claude/hooks/setup-firewall/— sfw only,--rotatehonored..claude/hooks/setup-claude-scanners/— AgentShield + zizmor..claude/hooks/setup-basics-tools/— TruffleHog + Trivy + OpenGrep + uv..claude/hooks/setup-misc-tools/— cdxgen + synp + janus.
security find-generic-password (macOS), secret-tool lookup (Linux), Get-StoredCredential (Windows PowerShell), keyring get (cross-platform) all surface a UI auth prompt on the user's screen — and that prompt fires per call, so a hook chain that reads the keychain three times costs three prompts. The token is already cached in process memory after the first resolution (see api-token.mts module-scope cache); read it from findApiToken() or process.env.SOCKET_API_KEY / SOCKET_API_TOKEN instead.
Writes (security add-generic-password, secret-tool store, New-StoredCredential) and deletes are allowed — they happen during operator-driven setup / rotation, never on hot paths. Bypass: Allow blind-keychain-read bypass (enforced by .claude/hooks/no-blind-keychain-read-guard/).
When a doc / test / comment needs to show an example user-home path, use the canonical platform-specific placeholder so the personal-paths scanner recognizes it as documentation: /Users/<user>/... (macOS), /home/<user>/... (Linux), C:\Users\<USERNAME>\... (Windows). Don't drift to <name> / <me> / <USER> / <u> etc. — the scanner accepts anything in <...> but a fleet-wide audit relies on the canonical strings being grep-able. Env vars ($HOME, ${USER}, %USERNAME%) also satisfy the scanner.
Two layers, on purpose:
-
Fleet-canonical name (forward-looking) —
SOCKET_API_TOKEN. This is what new.env.examplefiles, fleet docs, workflow inputs, actionenv:blocks, and CI secrets target.SOCKET_SECURITY_API_TOKENandSOCKET_SECURITY_API_KEYremain accepted aliases for one cycle (deprecation grace period). -
Local-dev primary slot —
SOCKET_API_KEY. Every Socket tool (CLI, SDK, sfw, fleet scripts) readsSOCKET_API_KEYwithout a fallback chain, so picking it as the one stored / exported slot means a single read covers the whole surface. The setup-security-tools install hook stores the token under keychain accountSOCKET_API_KEYand exportsSOCKET_API_KEYfrom the~/.zshenvshell-rc-bridge block. Bootstrap hooks read both —SOCKET_API_KEYfirst,SOCKET_API_TOKENas a forward-canonical fallback — so a consumer setting either works.
Don't confuse any of these with SOCKET_CLI_API_TOKEN (socket-cli's separate setting).
../<fleet-repo>/... (relative escape) and /<abs-prefix>/projects/<fleet-repo>/... (absolute sibling-clone) are both forbidden. Either form hardcodes a clone-layout assumption that breaks in CI / fresh clones / non-standard checkouts. Import via the published npm package (@socketsecurity/lib/<subpath>, @socketsecurity/registry/<subpath>) — every fleet repo is a real workspace dep. The cross-repo-guard PreToolUse hook blocks both forms at edit time; the git-side scanCrossRepoPaths gate catches commits/pushes too.