Coding agents run commands as you, read files in your home folder, and send what they read to a model. A key in ~/.zshrc, a .env file or a prompt is a key the agent can see, and possibly repeat. The goal is that agents can use keys without reading them, and that what they can reach is limited and logged.
Rules that hold whatever you use
- Never paste a key into a prompt,
CLAUDE.md,AGENTS.mdor a skill. Put it in Fishmem and refer to it by name. - Keep keys out of files the agent can read. Follow Move keys out of .zshrc, .env and notes first; that removes most of the exposure on its own.
- Give agents their own vault. A vault with only the keys agent work needs, preferably development keys with low limits. Not your production database.
- Inject into the command, not the conversation. Have the agent run
fishmem run -- npm test, so the key goes to the test process as an environment variable and never appears in the agent's context. - Install the pre-commit hook (
fishmem scan --install-hook), so a key an agent writes into code is stopped before it reaches git.
Today: run commands through fishmem run
Tell the agent how to run things in your instructions file, without any values:
<!-- CLAUDE.md or AGENTS.md -->
## Secrets
Secrets are in Fishmem, never in files. To run anything that needs them, prefix the
command with `fishmem run --`, for example `fishmem run -- npm test`.
Do not print environment variables, and do not run `fishmem secrets get`.With a .fishmem.json in the repository pointing at the agent's vault ({"vault": "agents"}), fishmem run -- npm test injects that vault into the test process only.
This is a convention, not a boundary. An agent that runs as you, on a machine where your vault is unlocked, could also run fishmem secrets get or print its child's environment. Instructions make that unlikely; they don't make it impossible. If that matters for the keys involved, use the isolated setup below.
Stronger: a service token in an isolated environment
Run the agent in a container, VM or cloud sandbox that has no vault at all, only a service token for one vault:
# on your machine, once
fishmem secrets create agents
fishmem secrets set OPENAI_API_KEY -p agents
fishmem secrets token create -p agents --name sandbox --expires 7d # shown once# inside the sandbox
export FISHMEM_TOKEN=fmst_…
fishmem run -- npm testWhat this gives you:
- A hard boundary. The token can read that one vault and nothing else: no other vaults, no passwords, no files, no history.
- An expiry. Here, seven days. You can also revoke it at any time with
fishmem secrets token revoke sandbox, from the app, or in the Dashboard's Settings › Devices. - An audit trail. Every read is in
fishmem secrets log agents, with time, IP address and client.
Service tokens come with Premium. See Plans and billing.
Agent mode
Preview. Agent mode is built and in review, and isn't in a release yet. The commands below are what will ship.
Agent mode is for agents that run on your own machine. You approve once, in your own terminal, for one vault and a limited time. After that the agent keeps using plain fishmem run, and it never handles a value:
# in your terminal, not in the agent
fishmem agent grant -p myapp --ttl 8h
# lists the key names and the expiry; confirm with y (a vault whose name contains prod, production, live or prd: type its name)
# --keys OPENAI_API_KEY,DB_URL only some keys
# --cmd npm,node,pytest only these programs
# in the agent, unchanged
fishmem run -- npm testHow it works:
grantunlocks the vault the usual way and hands only that vault (or the keys you listed) to a background process, which keeps it in memory, never on disk. The default is 8 hours, the maximum 7 days.- When an agent runs
fishmem run, the background process starts the command, puts the keys in that child's environment, and streams the output back with every value replaced by[fishmem:NAME]. The agent receives masked output, never plaintext. - Inside an agent (detected from variables such as
CLAUDECODEthat Claude Code, Codex, Gemini CLI, Cursor and others set), the CLI refuses to unlock the vault, sofishmem secrets getand other commands that print values fail, and an agent can't grant itself access: the confirmation is read from your terminal, not from input the agent controls. fishmem agent status,agent lsandagent logshow what's granted and every command run with your keys.fishmem agent revokeends a grant early.
Claude Code and Codex
fishmem agent setup claude-code # installs a skill and the Fishmem MCP server for Claude Code
fishmem agent setup codex # adds the MCP server and instructions to CodexThe MCP server offers two tools, fishmem_status and fishmem_run, and goes through agent mode, so plaintext in the output is masked the same way.
What masking does and doesn't do
Masking stops a key from accidentally ending up in the conversation, the model provider's logs, code the agent writes, a commit or a log file. It can't stop code that is deliberately written to leak: the child process has the real value (that's its job), so an agent that runs base64 <<< $KEY or sends a value over the network gets past it. Keep grants narrow (--keys, --cmd, a short --ttl, no production vaults) and read fishmem agent log. The agent detection is a guard rail, not a security boundary; for the strictest setup, protect the vault with a passphrase (fishmem init --passphrase) so only grant can open it.
Cloud agents (Claude Code cloud and similar)
Preview. This is being built together with agent mode and isn't in a release yet.
Agents such as Claude Code on the web and Codex cloud run on the platform's machines: each session is a new machine with no vault on it. Instead of storing a key or a token in the platform's settings, you approve each session on your phone, and the keys are sealed to that one machine.
Once, in Fishmem's Settings › AI Agents › Cloud agents, copy the three lines into the platform's environment settings (for Claude Code: setup script, allowed domains, environment variables):
Setup script: curl -fsSL https://fishmem.com/install.sh | sh && fishmem agent setup claude-code
Allowed domains: fishmem.com
Environment: FISHMEM_ACCOUNT=fma_…fma_… is your account's agent address. It only routes requests to you and opens nothing; if someone sends you unwanted requests with it, replace it on the same screen.
In each session:
- The agent runs
fishmem run -- npm test. The machine has no keys yet, so fishmem sends a request and the agent tells you a two-digit number, then waits withfishmem agent wait. - Fishmem on your phone or computer shows the request: which agent, where it came from (as the server saw the connection), and what the machine calls itself. Type the number from the chat (one try: a wrong number denies the request), pick the vault, optionally only some keys, and 1, 8 or 24 hours, then approve.
- The agent runs the command again. It runs with the keys injected and the values masked as
[fishmem:NAME], exactly as in agent mode, until the time is up.
Without FISHMEM_ACCOUNT, the agent shows a code such as KX4F-9QPT instead of a number; enter it in the same Cloud agents screen. Requests expire after 10 minutes. The screen also lists the last 30 days of requests, and End stops an approval: the machine checks before every command. On an iPhone signed in to Fishmem the request arrives as a notification (it names the agent and where it came from, never the number or a key); the Mac app shows one while it is open, and Android shows requests when you open the app.
Keep in mind: once approved, the keys are on the platform's machine, and anything running there can read them. Masking keeps them out of the conversation, not out of the machine. Fishmem's server sees that a request was made, from where, and the vault and key names; never the values. For jobs that run with nobody there to approve (CI, schedules), use a service token instead.
Checklist
- No keys in shell profiles,
.envfiles, prompts or instruction files - A separate vault for agent work, with development keys only
- Commands that need keys go through
fishmem run - Pre-commit scan installed in every repository the agent touches
- Agents on your machine: a narrow, short
fishmem agent grant(once agent mode ships) - For sensitive keys: sandbox plus a short-lived service token, and review
fishmem secrets log