Claude Code Privacy Guard
🛡️ Stops Claude Code from reading your secrets, not just from you typing them.
A privacy-first plugin for Claude Code. Coding agents don't only see what you type: they read files and run commands on their own, and one cat .env puts your credentials in the model's context. Privacy Guard checks every path a secret can take - your prompts, the agent's tool calls, the files it reads, and the output it gets back - and blocks the leak before it reaches the AI. It keeps protecting in auto mode, where nobody is approving tool calls.

Features
- ✅ Blocks prompts containing secrets or PII before they're sent to Claude
- ✅ Guards tool calls - stops Claude from reading
.env, SSH keys, cloud credential files, or any file whose contents hold a secret, and from dumping the environment through Bash
- ✅ Works in auto mode - where a confirmation prompt would never reach you, it denies instead of asking
- ✅ Warns after the fact - if a secret shows up in tool output, you're told so you can rotate it, and Claude is told not to repeat it
- ✅ Broad detection - about 200 rules from gitleaks plus code-focused checks (
.env lines, high-entropy tokens), and opt-in card, SSN and phone detection
- ✅ Works locally - no network calls, no telemetry; adds roughly 20 ms per check
- ✅ Zero configuration - works out of the box, and documentation addresses like
[email protected] are never flagged
- ✅ Toggle rules and manage allowlists - by hand in
.privacy-guard.json, or via npx claude-code-privacy-guard rules for a local web UI
Installation
# Add the marketplace (if not already added)
/plugin marketplace add datumbrain/claude-code-privacy-guard
# Install the plugin
/plugin install claude-code-privacy-guard
⚠️ Important: Restart Required
After installing the plugin, you must restart your Claude Code session for it to take effect. This is because hooks are registered at session startup - Claude Code doesn't dynamically load new hooks mid-session.
Simply close and reopen Claude Code, or start a new session.
Once restarted, the plugin automatically scans your prompts and Claude's tool calls. To update later, run /plugin marketplace update datumbrain-plugins and restart.
Rules UI without the plugin (npm)
The rules/allowlist web UI also ships as an npm package, so it can be run without installing the Claude Code plugin:
npx claude-code-privacy-guard rules
From a clone, node dist/cli/index.js rules does the same.
What Gets Detected
✅ Secrets
- OpenAI API keys (
sk-..., sk-proj-...)
- Anthropic, OpenRouter, Google AI, Groq, and Perplexity API keys
- Hugging Face API tokens
- AWS credentials
- GCP service account keys
- Azure client secrets (Microsoft Entra ID)
- GitHub tokens (classic and fine-grained PATs)
- GitLab tokens (personal access, deploy, runner, pipeline trigger, service account, CI job)
- Slack tokens
- Stripe keys
- Twilio API key SIDs and account SIDs
- SendGrid API keys
- npm access tokens
- Database connection strings with inline credentials (postgres/mysql/mongodb/redis/amqp, including SQLAlchemy URLs like
postgresql+psycopg2:// and redis://:password@host)
- JWT tokens
- Bearer tokens
- SSH, PEM and PGP private keys, including a key cut off before its
END line
- Generic API key/secret/token assignments in code (
=, :, Go's :=, Ruby/PHP's =>)
- Unquoted
.env-style assignments (API_KEY=..., export SECRET=...)
- Unknown-prefix high-entropy tokens that follow a secret keyword (
token:, api_key=, secret, password, ...). Entropy is never used alone, so git SHAs, UUIDs and hashes without a keyword in front are not flagged. Thresholds live in ENTROPY_CONFIG in src/scanner/entropy.ts.
Plus about 200 service-specific rules converted from gitleaks' MIT-licensed ruleset (data/gitleaks-rules.json, license in data/gitleaks-LICENSE). Like gitleaks, each rule only runs when one of its keywords appears in the text and drops low-entropy matches, which keeps false positives down. See Managing Rules to browse the full list, and scripts/convert-gitleaks-rules.mjs to refresh it.
✅ Personal Information (PII)
- Email addresses (except reserved documentation domains -
example.com, example.org, example.net, and anything ending in .test, .example, .invalid or .localhost - which never belong to a real person, so README and test fixtures don't trip the guard; git SSH remotes like [email protected] and image names like [email protected] are not treated as emails either)