fastsecrets

For AI agents and the people who run them

You use credentials. You never see them.

An agent keeps everything it reads in a transcript, so the rule is that an agent never has a value printed at it. fastsecrets hands secrets to the program that needs them and prints nothing.

The rules

Paste these into your agent's instructions: a system prompt, CLAUDE.md, AGENTS.md or a rules file.

- Read secrets only with: fastsecrets run --mask NAME... -- COMMAND
- Never run a bare fastsecrets get. Its output is the value, and it lands in your transcript.
- One run per step, with every name the step needs.
- Never put a value on a command line, in a file, a commit, a log, a memory or a message.
- To store a value, tell the user to run: fastsecrets set NAME (in their own terminal).
- If a value shows up in a transcript or log, say so. The user rotates it at the provider.

How an agent uses a secret

  1. Find the name: fastsecrets list shows names and scopes, never values. Website logins: fastsecrets login list.
  2. Use it: fastsecrets run --mask NAME -- COMMAND. The value goes into the command's environment as $NAME. It is never printed and never on a command line.
  3. Several at once: fastsecrets run --mask A B C -- COMMAND. One call with five names costs about what one name costs.
  4. Another variable name: fastsecrets run --mask GH_TOKEN=GITHUB_TOKEN -- gh api user.

Always pass --mask

It replaces any secret the command prints with [secret:NAME] before the output reaches the agent. It turns on by itself when the shell sets a known agent variable (CLAUDECODE, CODEX_THREAD_ID, GEMINI_CLI, CURSOR_AGENT, OPENCODE, AI_AGENT, ...) or SECRETS_AGENT=1, but do not rely on being recognized.

The filter matches exact values only. Do not run a command whose purpose is to print, encode or transform the secret (env, printenv, base64, curl -v). If the marker shows up, the command echoed a secret: do not try to get around it.

A tool wrapper that starts fastsecrets with a clean environment must pass --mask or SECRETS_AGENT=1.

Storing a new secret

The common way a key leaks is a command shape that puts the value on the command line, where it lands in the transcript and in shell history. So the user stores it, in their own terminal window, not through the agent's shell.

Never suggest NAME=value, fastsecrets set NAME value or echo key | ... typed into a chat. fastsecrets set shows its hidden prompt only when stdin is a terminal.

Give the user this, word for word

  1. Open a terminal.
  2. Type: fastsecrets set EXAMPLE_API_KEY and press Return.
  3. Paste the key at "Value for EXAMPLE_API_KEY:" (nothing shows), Return, paste again at "Again:", Return.
  4. Check: fastsecrets list shows the NAME (never the value).

A short-lived credential: fastsecrets set NAME --ttl 2h. A website login: fastsecrets login set example.com --user NAME, which prompts for the password. If a value ever appears in chat or a log, say so plainly; the user revokes or rotates it at the provider, then stores the new one.

No MCP server needed

fastsecrets is a command-line program. Any agent that can run a shell command can use it as it is, with no server to install and no tool schema to load.

The agent never calls a "get secret" tool that returns a value into its context. It runs the program that needs the key under fastsecrets run, and the program gets the value in its environment.

# the agent's shell tool runs:
fastsecrets run --mask OPENAI_API_KEY -- python scripts/summarize.py
fastsecrets run --mask GH_TOKEN=GITHUB_TOKEN -- gh pr list
fastsecrets run --mask DATABASE_URL -- npm run migrate

Inside a script, v="$(fastsecrets get NAME)" assigned to a variable is fine, and fastsecrets get A B prints NAME=value lines, all or nothing. The agent never runs a bare get itself.

The voice-agent pattern

A voice agent has a person on the line, and every pause is one they hear. Read every key the engine needs in one call, when the engine starts, and hand them over with run.

fastsecrets run --mask ANTHROPIC_API_KEY OPENAI_API_KEY -- python voice_agent.py

Batch every name

One run with five names costs about what one costs. Five separate calls cost five process starts and, with a chip key, five chip operations that queue behind each other.

Read at start

In our simulated test, wrapping the start command cost about 3 ms at startup and 0 ms per turn, because the key was read once.

Keep logins off the hot path

A website login spec (VAR=login:SITE) moves the whole call to the slower helper scripts, which read each value separately.

No value appeared in argv, in files or in the replay output. The key was visible in the child's environment to ps run by the same user, which run does not prevent. More on the home page.

Research footnote

Startup cost +3.2 ms median, about +4 ms with masking. The test was a simulated replay of 60 turns per condition on one Mac (echo brain, fake speech output, real Whisper speech-to-text), with a software key and reader version 0.3.1. It does not show a live model turn.

Copy-paste SKILL.md

A ready-made agent skill with the rules, what each error means and the exact steps for storing a new key.

Save it as SKILL.md in a folder named fastsecrets in your agent's skills folder. From a clone of the fastsecrets repository, link it instead:

ln -sfn "$PWD/skill" ~/.claude/skills/fastsecrets

Source: skill/SKILL.md.

---
name: fastsecrets
description: Use whenever a task needs an API key, token, password or website login, whenever a credential must be stored or read, or whenever you are about to tell the user how to save a key. Exact commands for the age-encrypted fastsecrets store and the rules that keep values out of chat, transcripts, command lines and logs.
---

# Using secrets with fastsecrets

`fastsecrets` keeps secrets in a git store (default `~/.config/fastsecrets`) encrypted with
[age](https://github.com/FiloSottile/age), a small, widely used open-source file encryption tool.
`fastsecrets help` lists every command; `fastsecrets help run` explains one.

You use credentials. You never see them.

## Using a secret

- Find the name: `fastsecrets list` (names and scopes, never values).
  Website logins: `fastsecrets login list`.
- Use it: `fastsecrets run --mask NAME -- COMMAND`. The value goes into the command's
  environment as `$NAME`. It is never printed and never on a command line.
  - Different variable name: `fastsecrets run --mask GH_TOKEN=GITHUB_TOKEN -- gh api user`
  - Website login: `fastsecrets run --mask P=login:example.com U=login:example.com:username -- ./script`
  - Several at once: `fastsecrets run --mask A B C -- COMMAND`
- **Prefer `run` over `get`.** `run` hands values to the command; `get` prints them, and
  whatever is printed can land in your transcript.
- **Batch the names a step needs into one call.** One `run` with five names costs about
  what one name costs (one decrypt per scope file). Five separate calls cost five process
  starts and, with a Secure Enclave key, five chip operations that queue behind each
  other. For a voice agent or any hot path: one `fastsecrets run` per step, every name in it.
  A website login spec (`VAR=login:SITE`) moves the whole call off the fast native path to
  the slower helper scripts, so keep login specs out of a hot path.
- Always pass `--mask`. It replaces any secret the command prints with `[secret:NAME]`
  before the output reaches you. (It turns on by itself when the shell sets a known agent
  variable such as `CLAUDECODE` or `CODEX_THREAD_ID`, or `SECRETS_AGENT=1`, but do not rely
  on being recognized.) If you see that marker, the command echoed a secret: do not try to
  get around it. Use `--no-mask` only when the command is meant to write the value
  somewhere (rendering a config file to disk), and never when its output comes back to you.
- The filter matches exact values only. Do not run a command whose purpose is to print,
  encode or transform the secret (`env`, `printenv`, `base64`, `curl -v`).
- Inside a script, `"$(fastsecrets get NAME)"` assigned to a variable is fine, and
  `fastsecrets get A B` prints `NAME=value` lines, all or nothing. Never run a bare
  `fastsecrets get NAME` or `fastsecrets login get NAME` yourself: its output is the value,
  and it lands in your transcript.

## Never

- Never print, echo, log or write a value. Never pass one as an argument. Never put one
  in a commit, a memory file, a chat message, an issue, or any external service.
- Never read `store/*.age` with `age` directly, the machine key (`~/.config/age/key.txt`),
  or the macOS keychain with `security`. Go through `fastsecrets run`.
- Never run `fastsecrets export`, `fastsecrets recovery` or `fastsecrets edit` (it opens
  every value in an editor). They are for the user at their own terminal, and two of them
  refuse an agent's shell anyway.
- Never use `set -x` or `bash -x` around a command that holds a secret.

## Storing a new secret

The common way a key leaks is a command shape that puts the value on the command line,
where it lands in the transcript and in shell history.

1. **Never give a command shape where the value goes on the command line.** No
   `NAME=value`, no `fastsecrets set NAME value`, no `echo key | ...` typed into a chat.
2. **Use `fastsecrets set NAME`.** It prompts twice with hidden input and never takes the
   value as an argument. `--scope S` picks the scope (default `all`).
3. **The user does it in their own terminal window**, not through an agent's shell
   passthrough: `fastsecrets set` shows its hidden prompt only when stdin is a terminal.
   Give this instruction verbatim:
   - Open a terminal.
   - Type: `fastsecrets set EXAMPLE_API_KEY` and press Return.
   - Paste the key at "Value for EXAMPLE_API_KEY:" (nothing shows), Return, paste again at
     "Again:", Return.
   - Check: `fastsecrets list` shows the NAME (never the value).
4. **A short-lived credential:** `fastsecrets set NAME --ttl 2h` stops being served after
   the limit on every machine.
5. **A website login:** `fastsecrets login set example.com --user NAME` in the user's
   terminal. It prompts for the password.
6. **If a value ever appears in chat or a log:** tell the user plainly, have them revoke or
   rotate it at the provider first, then store the NEW one with rule 3. Do not repeat the
   value back. Do not write it to any file or memory.

## When something fails

| Message | Meaning | Do |
|---|---|---|
| `not found` | no secret of that name on this machine | check `fastsecrets list`; ask the user to store it |
| `expired at ...` | it was stored with a time limit | ask the user to set it again if still needed |
| `more than one readable scope` | the name exists twice | tell the user; they remove one with `fastsecrets rm NAME --scope S` |
| `cannot push to the store's remote` | this machine has read-only access | make the change on a machine that can push |
| `decrypts none of the scope(s)` | this machine's key is not a recipient | tell the user; see "Enrolling a new machine" in the README |
| `helper scripts, which are not installed` | a `cargo install` without the bash side | the user runs `fastsecrets setup-libexec` |
| `no age identity` | no key on this machine yet | first machine: the user runs `fastsecrets init`; a machine joining an existing store: "Enrolling a new machine" in the README, not `init` |

`fastsecrets verify` checks that this machine's copy is sound and current. Run it when a
secret looks stale or missing, and report its `problem:` lines to the user rather than
fixing them by editing the store yourself.

Other commands: `fastsecrets rm NAME`, `fastsecrets load` (pull and refresh this machine),
`fastsecrets sync status`, `fastsecrets log [NAME]` (who read what, names only).

The whole file is in the box above; scroll inside it to read on, or copy it with the button.

AGENTS.md snippet

For a coding agent working in any project that uses fastsecrets. Paste it into the project's AGENTS.md.

Source: the first section of AGENTS.md, which also has the rules for working on fastsecrets itself.

## Using fastsecrets (any project)

- Read a secret only through `fastsecrets run --mask NAME... -- COMMAND`. The value goes to
  COMMAND's environment; it is never printed and never on a command line.
- Never run a bare `fastsecrets get` or `fastsecrets login get`: the value is the output, and
  the output lands in your transcript. In a script, assign it: `v="$(fastsecrets get NAME)"`.
- Ask for every name a step needs in one `run` call (one decrypt per scope file, however many
  names). For voice and other hot paths, one call per step.
- Never put a value in a command line, a file, a commit, a log, a memory or a message. Never
  read `store/*.age`, the key file or the keychain directly. Never run `edit`, `export` or
  `recovery`: they are for the user at their own terminal.
- To store a value, tell the user to run `fastsecrets set NAME` in their own terminal. Never
  ask them to paste a value into the chat.
- If a value appears in a transcript or log, say so plainly; the user rotates it at the
  provider, then stores the new one.
- Full rules for an agent: `skill/SKILL.md`.

What the rules do not cover

  • The program you hand a secret to holds the value and can print or send it in any form. --mask catches exact values only.
  • Another process running as the same user can read the program's environment while it runs, and can run fastsecrets itself with this machine's key.
  • The agent's own shell tool decides what it sees. If it runs env inside a run, the value is in its output (masked only when it matches exactly).

The whole site for agents: llms.txt (a short index) and llms-full.txt (every page as Markdown).