claude-code plugin / open source / local only

Your agent reads more than you type.

One cat .env puts your credentials in the model's context. Privacy Guard checks every path a secret can take, prompts, tool calls, files and output, and blocks the leak before it reaches the AI.

>/plugin marketplace add datumbrain/claude-code-privacy-guard

Then run /plugin install claude-code-privacy-guard and restart Claude Code. Full steps

you    read .env

Read(.env)
  Not run - permission denied
  Privacy Guard: .env usually holds credentials.
  Reading it would put them into the conversation.
  Blocked rather than asked because this session
  is in "auto" permission mode, where a
  prompt would not reach you.

  To allow it, add the path to
  toolGuard.allowedPaths in .privacy-guard.json
Coverage

Four ways a secret gets in. All four are watched.

It keeps working in auto mode, where nobody is approving tool calls. Where a confirmation would never reach you, it denies instead of asking.

  1. Your prompts UserPromptSubmit

    Scanned before they are sent. In the default mode the prompt is rejected and you see exactly what matched and which rule to disable if it is a false alarm.

  2. Tool calls PreToolUse

    The only point where a leak can still be prevented. Reading or grepping .env, SSH keys or cloud credential files, or a Bash command that prints them or dumps the environment, is stopped or put to you first.

  3. Files it reads PreToolUse

    Not just known filenames. Any file whose contents hold a secret is caught, using the same rules as prompts.

  4. Output it gets back PostToolUse

    If a secret shows up in tool output anyway, you are told so you can rotate it, and Claude is told not to repeat it.

~200detection rules, from gitleaks plus code-focused checks
~20 msadded to each check
0network calls and no telemetry
0config needed to start
Privacy Guard blocking a prompt in Claude Code
Detection

Tuned for code, quiet on everything else.

Secrets

  • AI providers OpenAI, Anthropic, Google AI, Groq, Hugging Face and more
  • Cloud AWS, GCP service accounts, Azure client secrets
  • Source hosts GitHub and GitLab tokens, npm access tokens
  • Services Slack, Stripe, Twilio, SendGrid
  • Connection strings Postgres, MySQL, MongoDB, Redis, AMQP with inline credentials, SQLAlchemy URLs included
  • Keys SSH, PEM and PGP private keys (even cut off), JWTs, bearer tokens, .env and in-code assignments
  • High-entropy tokens only after a keyword like token: or password, so SHAs and UUIDs stay quiet

Personal information

  • Email addresses on by default. Documentation domains such as example.com, git remotes and logo@2x.png are never flagged
  • Credit cards opt in. Luhn checksum, real issuer prefix, matching length
  • US SSNs opt in. Dashed format, invalid area, group and serial rejected
  • Phone numbers opt in. E.164 and US formats checked against numbering rules

Every opt-in detector is validated, not just pattern-matched, to keep order IDs and test data from tripping the guard.

Modes

Block, redact, or warn.

block

Default

Rejects the prompt outright. The sensitive data never reaches the AI.

redact

Block, with a clean copy

Also blocks, but hands back a version with placeholders like <EMAIL_1> that you can paste and resubmit.

warn

Visibility only

Lets the prompt through and shows what was detected. Useful while tuning allowlists.

Configuration

Zero config. Tunable when you want it.

Drop a .privacy-guard.json in a repo root or your home directory. Or skip the JSON and run the local rules editor, bound to 127.0.0.1 only.

$ npx claude-code-privacy-guard rules
{
  "mode": "block",
  "allowedDomains": ["acme-corp.io"],
  "disabledRules": [],
  "piiProfile": {
    "creditCard": true,
    "ssn": true,
    "phone": false
  },
  "toolGuard": {
    "preToolUse": "ask",
    "postToolUse": "warn",
    "sensitivePaths": ["secrets/**"],
    "allowedPaths": [".env.test"]
  }
}
Install

Two commands, then restart.

Hooks are registered when a session starts, so close and reopen Claude Code after installing.

  1. Add the marketplace and install

    /plugin marketplace add datumbrain/claude-code-privacy-guard
    /plugin install claude-code-privacy-guard
  2. Restart Claude Code. Prompts and tool calls are scanned automatically from then on. To update later:

    /plugin marketplace update datumbrain-plugins
  3. No plugin? The rules and allowlist editor also runs straight from npm.

    npx claude-code-privacy-guard rules