PluginInstalls cleanly

Keep API keys out of your commits

leak-guard

Free MIT plugin that stops Claude Code writing an API key into a file git would commit, and blocks a commit or push that adds one. Keys in .env are fine.

Works with
Claude Code
Good for
Security testing, Build an app

What it does

When an assistant writes code fast, an API key can end up in a normal source file instead of .env, and then it gets committed and pushed. leak-guard checks for that before it happens.

Before each file write by the assistant, it looks for text shaped like a credential: sixteen fixed patterns (GitHub, Stripe, OpenAI, Anthropic, AWS, Slack and other keys, private key blocks, signed JWTs, database links with a password) plus one guess-based rule for lines like password = "...". Then it asks git one question: would this file be committed? If yes, the write is refused and the assistant is told how to fix it: read the value from the environment and keep the real key in .env. A write into .env or any other file git ignores is allowed without comment.

Before git commit it checks the staged changes, and before git push the commits that would go out. When a key appears inside a shell command, it asks you first. Found keys are always shown shortened, never in full.

Example prompts

  • "Connect the site to Stripe using my secret key."
  • "/leak-scan"
  • "My write was blocked for containing a credential. Fix it the right way."
  • "I think I already pushed a key. What should I do?"

How to install

/plugin marketplace add ShendLlapashtica/leak-guard
/plugin install leak-guard@leak-guard-marketplace

How to use it

Nothing to type: it checks the assistant's file writes, git commits and git pushes. Run /leak-scan to sweep the project, or /leak-scan --staged before a commit.

Check it works

Ask the assistant to write a made-up Stripe-style key into a normal tracked file such as config.js. The write should be refused with a "leak-guard: this write contains a credential." message.

Common problems

Other assistants

What to watch out for

  • Adds a PreToolUse hook on Write, Edit, MultiEdit, NotebookEdit and Bash that runs node hooks/guard.mjs (15 s timeout) before each of those actions; it runs git ls-files, check-ignore and diff locally and makes no network calls
  • It fails open by design: if the script throws, git fails or Node.js 18+ is missing, the action goes through, so it is a safety net, not a guarantee
  • A .leakguard.json in the project (or LEAK_GUARD_MODE) can set mode to off or warn, so a cloned project that ships one switches the guard off for that folder
  • The commit check reads only what is already staged when the command starts, and the push check is skipped when the branch has no upstream and origin/HEAD is not set
  • It only watches the assistant's tool calls: commits you make in your own terminal, and keys already in git history, are not checked; /leak-scan reads the working tree, not past commits
  • The /leak-scan command pre-approves Bash(node:*), Read and Grep while it runs
  • Plugin 1.0.0 with no GitHub release or tag; updates come from the main branch

Licence and author

Licence
MIT
Author
Shend Llapashtica (ShendLlapashtica)
Source code
github.com/ShendLlapashtica/leak-guard

How we tested it

We installed it on an empty test computer on 4 Nov 2026. Installed and started in a clean test system. Not yet used in a real AI session.

Test level

Not yet used on real work.

Technical details of the test
Date
4 Nov 2026
Method
Intake sandbox run on 2026-11-04 in a clean container with no account: cloned the repository and checked its skill, agent and plugin files; installed leak-guard@leak-guard-marketplace with the Claude Code command line.

Checked again on 4 Nov 2026

Alternatives

  • cc-safety-net — blocks dangerous shell commands rather than leaked keys
  • Hookify — write your own hook rules, for example to block a file pattern
  • Snyk Agent Scan — scans your agent setup for security problems
  • Trail of Bits Skills — security review skills you run on demand

FAQ

  • Q: Does it send my code anywhere? A: No. The hook and scanner run git on your computer and make no network calls; the README says the same.
  • Q: Will it stop me using .env? A: No. Files git ignores are always allowed.
  • Q: Does it remove a key I already pushed? A: No. Rotate the key first; the bundled secret-hygiene skill explains the order of steps.
  • Q: Does it check commits I make myself? A: No, only the assistant's commands. You can add lib/cli.mjs --staged to your own pre-commit hook.

Sources

  • github.com/ShendLlapashtica/leak-guard
  • github.com/ShendLlapashtica/leak-guard/blob/9d221d01e7cd1908cd5afe9ee0fcc60b7fe04ce5/hooks/hooks.json
  • github.com/ShendLlapashtica/leak-guard/blob/9d221d01e7cd1908cd5afe9ee0fcc60b7fe04ce5/hooks/guard.mjs
  • github.com/ShendLlapashtica/leak-guard/blob/9d221d01e7cd1908cd5afe9ee0fcc60b7fe04ce5/commands/leak-scan.md
  • github.com/ShendLlapashtica/leak-guard/blob/9d221d01e7cd1908cd5afe9ee0fcc60b7fe04ce5/.claude-plugin/plugin.json