keyshroud

Secrets for AI coding agents

Your agents use the keys. They never see them.

keyshroud keeps API keys in an encrypted vault on your machine (or your own Vaultwarden, or the secret manager your team already runs) and injects them into the commands your AI coding agent runs. Any secret value that shows up in tool output is replaced with <redacted:NAME> before the model reads it.

$npm i -g keyshroud

Free, MIT-licensed, no account, no telemetry. Node.js 18.19+ on macOS, Linux and Windows.

$ keyshroud run -- ./deploy.sh
> POST /v1/deploy HTTP/1.1
> Authorization: Bearer ghp_DEMOdemo0123456789demo<redacted:GH_TOKEN>
< HTTP/1.1 200 OK
deployed acme-app to production
$ echo $GH_TOKEN
ghp_DEMOdemo0123456789demo<redacted:GH_TOKEN>

The command got the real token and the deploy worked. The transcript holds only its name. (The token shown is fake.)

Works with Claude Code · Codex · Cursor · Cline · OpenCode · Gemini CLI · pi · omp · any MCP client · any shell

The problem

A key only has to be printed once

Whatever an agent reads goes to the model provider and stays in the transcript. These are the usual ways a key gets there, and what keyshroud does about each.

> here is my token: ghp_9fK2…

Pasted into the chat

It is in the transcript, the provider’s logs and every later context window.

✓keyshroud add takes the value in a masked prompt or a desktop dialog, never through the chat.

$ cat .env STRIPE_KEY=sk_live_4e…

Read from .env

Agents read it to debug. .gitignore stops commits, not reads.

✓Values live in the vault. .env.refs holds names you can commit.

get_secret("stripe") → "sk_live_4eC3…"

Returned by a vault tool

Most vault MCP servers hand the plaintext straight to the model.

✓keyshroud’s MCP tools run the command for the model. None returns a value.

> Authorization: Bearer acme_7c1e… curl: (22) error: 401

Printed on failure

Claude Code cannot rewrite the output of a command that fails.

✓keyshroud claude-guard masks what every Bash command prints, failed ones included.

How it works

Names in, masked output out

The agent works with names. The command gets the value. Whatever the command prints is masked before the model reads it.

Your vaultA local encrypted file, your Vaultwarden, or your team’s secret manager.
value
keyshroudResolves GH_TOKEN to its vault item and puts the value in the command’s environment. Never in its arguments.
env
Your commandgh, npm publish, curl, a deploy script. It runs with the real key.
output
The modelReads <redacted:GH_TOKEN> wherever the value was printed.
1 · wire

A secret gets a name

keyshroud add --env GH_TOKEN stores the value and wires the name. Config files and .env.refs hold only names and references.

2 · inject

The command gets the value

keyshroud run -- <command> reads what the command needs from the vault and starts it with those variables set.

3 · redact

The model gets the name

Output streams through a redactor. Hooks in Claude Code and pi mask tool results of commands you did not wrap, too.

More detail, with the pieces and what each one touches: how it works.

Demo

Watch Claude use a key it never sees

A real Claude Code session, recorded in one take. The prompt never mentions keyshroud: the plugin tells Claude which secret names exist, and Claude runs the check through keyshroud on its own. The API gets the key. Claude gets its name.

Claude Code

What Claude was told

keyshroud: vault secrets are available by name only: ACME_API_KEY, GH_TOKEN, DATABASE_URL. Run every command that uses one through `keyshroud run --only NAME -- <command>` …

From the plugin’s SessionStart hook when the session starts. Names only.

What Claude saw

> Authorization: Bearer <redacted:ACME_API_KEY>
< HTTP/1.1 200 OK
{"ok":true,"account":"acme-demo"}

The script runs curl -v, which prints the header it sends. keyshroud masked the key before Claude Code got the output: it appears 0 times in Claude Code’s saved transcript.

What the API received

200 Bearer acme_DEMO_not_a_real_key_4f9c2e7a1b

Last line of the API’s log from the same run. The key arrived, so the call worked.

Recorded in November 2026 in one take with vhs, at normal speed, no cuts: Claude Code 2.1.309 (Haiku 5.5, reached through OpenRouter) with the keyshroud 0.12.1 plugin (/plugin install keyshroud@keyshroud). The setup runs off screen and is published: agent-shell.sh, claude.tape. The key is fake, and the API is a local mock that accepts only that key. keyshroud keeps keys out of what Claude reads by accident; it is not a sandbox against an agent that sets out to steal one (threat model).

Read the session as text
Open the text version

Over MCP

The MCP entry

{ "mcpServers": { "keyshroud": { "command": "keyshroud", "args": ["mcp"] } } }

Claude Desktop takes the same entry in claude_desktop_config.json. None of the server’s tools return a secret value: secrets_run, secrets_list, secrets_request, vault_status.

What Claude saw

exit: 0
--- stdout ---
> Authorization: Bearer <redacted:ACME_API_KEY>
< HTTP/1.1 200 OK
{"ok":true,"account":"acme-demo"}

--- stderr ---

The secrets_run result. The server put the key into the command’s environment and masked it in the output.

Recorded in November 2026 with keyshroud 0.12.1 in Claude Code 2.1.309 (Haiku 5.5, reached through OpenRouter) with its built-in tools turned off and keyshroud’s MCP server as its only tools: the same server, tools and results Claude Desktop gets from this entry. Claude Desktop itself is not shown. Same fake key and local mock as the Claude Code take: claude-mcp.tape.

Read the session as text
Open the text version

A failed command

Claude Code cannot rewrite the output of a command that fails, so a hook alone leaves it unmasked. keyshroud claude-guard makes Claude Code start its shell through a small launcher that masks what the command prints as it is written, and keeps its exit status. There is no agent in this take: the last command is what Claude Code’s Bash tool runs once the guard is on, in a shell started through keyshroud run the way keyshroud run -- claude starts Claude Code. Recorded in November 2026 with keyshroud 0.12 from guard.tape and tour-shell.sh. The key is fake, and the API is a local mock that refuses the call. macOS and Linux.

Team vault & scope

A secret is read from a real HashiCorp Vault 2.2.2 dev server on localhost and used masked; nothing is copied out of Vault and keyshroud never writes there. Then the project is narrowed to its own names, a command that asks for another project’s token is refused, and the local vault is copied into one file under a passphrase of its own. No agent in this take. Recorded in November 2026 with keyshroud 0.12 from team.tape and tour-shell.sh. The token, passphrase and secrets are made up.

Terminal

No agent here: on a new machine, keyshroud stores a token through a masked prompt, masks it in a command’s output and finds a copy that leaked into a log. Recorded in November 2026 with keyshroud 0.12.1 and vhs from demo.tape. The token is fake.

Quickstart

Up and running in three steps

You need Node.js 18.19+. No account, no server: the first secret creates an encrypted vault on your machine.

Install

npm i -g keyshroud

One CLI that agents call from their shell, plus plugins for Claude Code and pi. An MCP server covers clients without a shell.

Store a secret

keyshroud add --env GH_TOKEN \
  --item "GitHub token"

Typed into a masked prompt, or a dialog when an agent starts it. The vault’s key goes to the macOS keychain, the Linux Secret Service or Windows DPAPI. Already have a .env? keyshroud import moves it.

Use it

keyshroud run -- gh auth status

The command gets the token; what it prints shows <redacted:GH_TOKEN>. In Claude Code, install the plugin: /plugin marketplace add dinhkarate/keyshroud

Or let your agent set it up

Paste this into Claude Code, Codex, Cursor, OpenCode or pi. The agent follows install.md and leaves typing secrets (and any vault password) to you.

Read https://keyshroud.dev/install.md and set up keyshroud for me.

Where secrets live

Keep them where you already keep them

A reference names its vault, so all three work side by side. keyshroud has no service of its own to sign up for.

Default

A local vault

keyshroud://

An AES-256-GCM file on your machine. No account, no server, works offline.

  • Key in the macOS keychain, Linux Secret Service or Windows DPAPI
  • Touch ID on a Mac, or a passphrase, if you want to be asked
  • keyshroud backup writes one file that restores anywhere
The local vault →
Several machines

Vaultwarden or Bitwarden

bw://

The same secrets everywhere, in the Vaultwarden you host or a Bitwarden account.

  • Passwords, usernames, notes, TOTP codes, URIs and custom fields
  • A separate account for agents, so they never open your whole vault
  • Machines that used keyshroud 0.7 keep Vaultwarden
Sync setup →
Your team’s

The secret manager at work

vault://infisical://op://awssecrets://awsssm://gcpsecrets://azurekeyvault://

HashiCorp Vault, OpenBao, Infisical, 1Password, AWS, Google Cloud and Azure, read where the secrets already are.

  • Read-only: nothing is copied, and keyshroud never writes there
  • Uses the sign-in you already have
  • Masked in output like any other secret
Team secret managers →

Features

Built for agents, not just shells

Every feature works with names and references, never with values.

Masked output

keyshroud run streams stdout and stderr through a redactor. A secret that arrives split across two chunks is still masked. Masking is always on, in a terminal too, because some agents run commands on one; --no-mask hands the terminal to an interactive program. Output that is not text passes through byte for byte.

Hooks on tool output

pi tool_result and Claude Code PostToolUse hooks scrub tool results, including commands the agent ran without keyshroud.

The guard

Claude Code can't rewrite a failed call, so keyshroud claude-guard masks what every Bash command prints as it is written, failed ones included.

MCP server

For clients without a shell, keyshroud mcp gives them secrets_run, secrets_list and secrets_request. None of them return values.

Committable references

Write GH_TOKEN=keyshroud://GitHub token in a .env.refs file you can commit. keyshroud import converts an existing .env.

Paste-to-create

When an agent needs a new key it runs keyshroud add, and a hidden-input dialog opens on your desktop. You paste; the chat never sees it.

Inject & scan

inject renders {{ keyshroud://… }} templates into files only you can read (mode 0600). scan finds leaked values in your repo before you commit.

A project's own secrets

A .keyshroud.json in a repo, such as { "only": ["STRIPE_*"] }, narrows what keyshroud run and the agent get there to the names that project needs.

Names-only audit log

audit.jsonl records which names were used, when and by which command, so you can see what an agent reached for. Never a value.

Agents

Works with your agent

One vault, every coding agent you use. Setup for each is in the docs. Watch it in Claude Code and over MCP.

Least privilege

Give each project only its own keys

By default a command gets every wired secret. Narrow that per project or per command. These are defaults against accidents, not walls: see the threat model.

Per project

A scope file in the repo

In that directory, keyshroud run, the MCP tools and the names an agent is told are narrowed to the names in scope. Masking still covers every value.

$ keyshroud scope --only 'DB_*,ACME_*'
$ keyshroud run --only GH_TOKEN -- gh auth status
Secret unresolved: GH_TOKEN is outside this project's scope (~/acme-app/.keyshroud.json)

Project scope →

Per command

Name what a command needs

--only gives a command just the names you list. With Vaultwarden, keyshroud setup gives agents an account of their own, so they never open your whole vault.

$ keyshroud run --only GH_TOKEN -- gh pr list
# gh gets GH_TOKEN and no other secret

Least privilege →

Compare

Four ways to give an agent a secret

The tools in this space take one of four approaches. keyshroud masks what the model reads whether or not you wrapped the command, and keeps the vault on your side.

ApproachDoes the model see the value?A command you did not wrapCovers
Names in, masked output out
keyshroud
No. Tool output is masked. Masked too in Claude Code (hook, plus the guard for failed commands) and pi/omp. Other agents rely on keyshroud run. Any secret a command reads from its environment or a file. Free, MIT, no account.
A wrapper that masks its own child
1Password op run, dotenvx run --redact, varlock run, secretspec run
Not from the wrapped command. Not masked. The same, for the commands you wrap. op run needs a paid 1Password account.
A vault MCP server
Bitwarden MCP, HashiCorp Vault MCP, Doppler MCP, Infisical MCP (by default)
Yes. The tool returns it. Not masked. Looking a secret up, with the value in the context from then on.
An egress proxy with placeholders
Infisical Agent Vault, OneCLI, fnox proxy, 1Password for NVIDIA OpenShell, Claude Code’s sandbox.credentials mask
No. The agent holds a placeholder. Nothing to mask: the real value is never in the shell. HTTP(S) credentials for hosts you allow. Needs a proxy that can read the requests.

An egress proxy is the stronger tool against a hostile or prompt-injected agent, for the credentials it covers; keyshroud also covers database passwords, SSH and signing keys and every CLI that reads a variable. They combine. As we read each project’s documentation on 2026-11-15; corrections are welcome in an issue.

Security

An honest threat model

Redaction is defense in depth, not a sandbox. Every guarantee we test for and every known limit is in the security model.

Protected

  • Secret values entering the model's context through tool output, a failed command’s included (in Claude Code, with keyshroud claude-guard on)
  • Secrets at rest: the local vault is AES-256-GCM, its key in the OS keychain
  • Secrets pasted into chat while being stored (keyshroud uses a masked prompt instead)
  • Plaintext in agent config and auth.json (only references are stored)
  • Secret values accidentally committed to your repo (caught by keyshroud scan)

Not protected

  • A malicious or prompt-injected agent that encodes a value or sends it over the network
  • Other programs running as your user: they can read the vault’s key from the keychain (create the vault with a passphrase to be asked instead)
  • In Claude Code with the guard off: what a failed command prints, unless it ran through keyshroud run (the hook can’t rewrite a failed call)
  • A project scope and the guard are defaults against accidents, not walls: a program running as you can change them
  • Values shorter than 6 characters (not redacted, to avoid noise)

FAQ

Questions people ask first

The long list, with CI, Docker, Windows and upgrading, is in the FAQ.

Do I need Vaultwarden or any server?

No. Secrets live in an encrypted file on your machine by default, with its key in the OS keychain. Vaultwarden or Bitwarden is optional, for the same secrets on several machines.

Can the agent still use the key?

Yes. The command gets the real value in its environment; only the text the model reads is masked.

Is this a sandbox?

No. It stops accidental disclosure. A hostile or prompt-injected agent can still send a value it can use somewhere else; for that threat use an egress proxy with placeholder credentials and keep a human approving commands.

Doesn’t Claude Code do this itself?

Partly, and differently. Claude Code can deny reads of files such as .env, and its sandbox can show a command a placeholder for a credential and put the real value on requests to hosts you allow. It has no secret store and does not rewrite what a tool prints. keyshroud is the store, works the same across agents, and masks output; the two combine.

Why not just .gitignore my .env?

That stops commits, not reads. Agents read .env to debug, and whatever they read goes to the model provider.

We use HashiCorp Vault, AWS or 1Password at work. Do I have to move the secrets?

No. keyshroud reads them where they are, with the sign-in you already have, and never writes there.

Does it work on Windows?

Yes, tested on Windows 10 with Node 22. The local vault keeps its key with DPAPI. The guard for failed commands is macOS and Linux only.

Stop pasting API keys into chat

Every key you paste lives on in the transcript, the provider’s logs and every future context window. Give your agent the name instead.

$npm i -g keyshroud

No account · No telemetry · MIT