Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Run automatically on Claude Code events. Claude doesn't decide.
1 caution to review before installing
A hook runs when Claude uses the Bash tool
Static checks of hooks, mods, MCP servers and commands. Not a security audit.
1 marketplace, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
claude-secret-mask is a Claude Code plugin with a PostToolUse hook. It redacts secrets, such as .env values, API tokens and passwords, in the results of Read, Bash and Grep before the model reads them.
Claude Code reads files and runs commands for you. When it reads a .env file, or runs a command that prints a token, the secret goes into the model's context. It is also stored in the session transcript and drawn in the terminal.
This plugin replaces the secret with a notice before it gets there. The key name stays, so the model knows a value exists and was hidden on purpose.
Needs Node 22.18 or newer on your PATH. The hook runs the TypeScript sources with Node directly, with no build step.
Inside Claude Code:
/plugin marketplace add ejklock/claude-secret-mask
/plugin install secret-mask@secret-mask
On Claude Code 2.1.275 or later, one step does both:
/plugin install secret-mask --marketplace ejklock/claude-secret-mask
From a shell:
claude plugin marketplace add ejklock/claude-secret-mask
claude plugin install secret-mask@secret-mask
To try it from a local clone without installing: claude --plugin-dir /path/to/claude-secret-mask.
A .env file with fake values:
DATABASE_HOST=db.example.test
API_KEY=fake-api-key-value
APP_NAME=demo
What the model sees when it reads that file:
DATABASE_HOST=[MASKED by secret-mask: original value hidden for security]
API_KEY=[MASKED by secret-mask: original value hidden for security]
APP_NAME=[MASKED by secret-mask: original value hidden for security]
Every value of an env file is masked, not only the ones that look secret.
The rules run in order over every string of a Read, Bash or Grep result.
Env files. Every value in a .env, .env.example or .env.* file is masked. This applies to a Read, to the rows of a Grep in content mode, and to the output of a Bash command that names such a file (a word of the command whose basename is .env or starts with .env.). The file is judged by its path alone.
Token shapes. Well-known token shapes are replaced whole, anywhere in the text: AWS access key ids, GitHub, GitLab, Slack (and Slack webhook URLs), Stripe, Google, Anthropic, OpenAI and npm tokens, JWTs, and private key blocks (a block with no end is masked to the end of the text). In a URL with credentials only the password is hidden. In an Authorization header only the value after Bearer, Basic or Token is hidden. The shapes are a curated subset of the default rules of gitleaks (MIT).
Secret-named assignments. The literal value of an assignment is masked when its name is secret-named, and the name and the operator stay. A name is secret-named when one of its words is secret, token, password, pass, credential, apikey, dsn, salt and similar, or its last word is key. It covers NAME=value, a quoted string after : or = (JSON, YAML, code) and a YAML name: value line. The YAML form is skipped in source-code files, and for type names and values ending in ; or ,. Empty values and references such as $NAME are left alone.
Known values. A secret value held by an env file directly inside the working directory, or by an environment variable of the hook process, is masked wherever it appears in a result, longest first. Only the first 1 MiB of each file is read. A value is selected when:
://, no leading /, ./, ../ or ~/, and mixes at least 3 of lowercase, uppercase, digit and other characters (other counts only characters outside : / . - _ @).References ($NAME, {{ ... }}), PWD, OLDPWD and text inside the notices are never selected. Short ordinary values such as production or localhost stay visible in other files, because masking them everywhere would hide ordinary words. An env file is already masked whole.
Fail closed. If the content of an env-file Read result cannot be read, the whole result is replaced by [WITHHELD by secret-mask: this output could not be checked, so it was hidden for security].
A mask already in the text is never masked again. A result with nothing to hide is left untouched.
Measured on Claude Code 2.1.300 (see how it was verified):
| Surface | Sees the original? |
|---|---|
| The model's context | No |
The session transcript (.jsonl) | No |
| The terminal render | No |
| OpenTelemetry tool spans (per the Claude Code docs) | Yes |
| Other PostToolUse hooks | Yes |
| What you type in a prompt | Yes; a hook cannot rewrite a prompt |
More limits:
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
npx claudepluginhub ejklock/claude-secret-mask --plugin secret-maskPlugins from other owners that cover similar ground