axsDocs
Guides

Give AI agents passwords securely, without sharing them

How to give Claude Code and other AI agents passwords and API keys without pasting them into chat. Env vars, op run, password manager agent modes and axs cred.

To give an AI agent a password securely, keep the value out of the model's context. Pasting it into chat or a file the agent reads puts it in the transcript and the logs. Inject it at runtime instead: into one command's environment (op run, doppler run, axs cred run) or straight into the login form, so the agent can use it but never reads it.

The problem

An agent like Claude Code works by reading text: your prompt, files, command output, web pages. Whatever it reads is sent to the model and stays in the session transcript. A password that passes through the agent once can turn up in:

  • the conversation history and saved transcripts,
  • tool output the agent prints back, like cat .env or a failed curl -v,
  • a commit, a log file or a summary it writes for you.

The question is not where the secret is stored. It is whether the agent has to see it to use it.

The options

OptionAgent sees the valueGood forLimits
Paste into chatYesNothing you care aboutIn context, transcripts and logs
.env file in the repoYes, once it reads the fileLocal dev with throwaway keysOne cat puts it in context
op run, doppler runNot unless it prints itAPI keys, database passwords in commandsWebsite logins are not covered
Password manager MCP serverYes, for items it readsManaging the vault by chatValues come back through the model
Password manager autofill for agentsNoWebsite logins in a supported browser agentTied to a specific agent and browser
axs credNoWebsite logins and command secrets in Claude CodeClaude Code, Chrome and agent browsers today

Checked November 2026.

Pasting into chat or a .env file

Fast and the worst option. The value is in the model's context from then on. A .env file is not in the prompt, but an agent that opens it or prints the environment has the value in context too. Fine for a test key you would rotate anyway.

Environment variables from a secret manager

1Password CLI resolves op:// secret references at runtime and runs your command in a subprocess with the values set as environment variables:

op run --env-file=./prod.env -- ./deploy.sh

Secrets printed to stdout or stderr are concealed by default. Doppler works the same way with doppler run -- <command>.

If your agent only needs API keys and database passwords for commands, this is often enough. The agent writes the command, the secret manager fills the values. Two gaps remain: an agent can still run a command that prints a value in a form the masking does not catch, and none of this helps with a website login form.

Password manager MCP servers

Bitwarden's MCP server lets an agent list, read, create and edit vault items through the Bitwarden CLI. It runs locally only. Its README warns that access lets the AI read vault items including passwords, and that AI responses may reveal sensitive information. Useful for managing a vault by chat. Not a way to keep values out of context.

Password manager autofill for agents

1Password for Claude works with Claude in Chrome on Mac: when Claude needs to sign in, you approve the request with biometrics and 1Password fills the credential into the page. 1Password says Claude never sees the password or one-time code. If you already use 1Password and Claude in Chrome, start there.

Where axs cred fits

axs cred is a credential vault built for agents. The values never enter the agent's context:

  • Website logins. The agent opens the login page and calls cred_fill. Your device fills login, password and the TOTP code into the tab and submits. The agent gets back only what was filled, and cannot read that tab until it navigates.
  • One command. In a shell command the agent writes a placeholder like {{cred:grafana/password}}. A hook turns it into axs cred run, so the value reaches only that command. Values in its output are masked.
  • Leaks. The hooks deny tool calls whose input carries a stored value and strip stored values from tool output, also base64, URL encoded, hex or reversed. A credential that showed up in output is locked until you change it.
  • Encrypted per device. Credentials are encrypted and signed in your browser. The server stores only public keys, sealed data and signatures. Only devices you confirmed get credentials, and each credential names the devices that may use it.
  • Approvals. Each credential is Auto, Ask once or Ask every time. When it asks, you type approve <code> in the chat yourself.

It also fills into agent browsers like Playwright MCP, and into your own Chrome through axs browser. See Agents and credentials.

When is op run enough? When your agent only runs commands with API keys and you already pay for 1Password. axs cred adds website logins with TOTP, leak checks on every tool call and per credential approvals.

Setup

curl -fsSL https://axs.sh/install | sh
axs login
axs cred enroll

Create your vault in the dashboard under cred, confirm the device there, add a credential, load the axs cred extension in Chrome and start a new Claude Code session. Then ask the agent to log in:

curl -u admin:{{cred:grafana/password}} https://grafana.example.com/api/health

Full steps: How axs cred works.

FAQ

Can Claude Code log in to a website without me sharing the password?

Yes. With axs cred the agent calls cred_fill and your device fills the login form, TOTP included. With Claude in Chrome on Mac, 1Password for Claude does the same after a biometric approval.

Is a .env file safe for AI coding agents?

Only for keys you do not mind leaking. The agent can read the file or print the environment, and then the value is in its context and transcript. Use op run, doppler run or {{cred:name/password}} placeholders instead.

Does op run keep secrets away from the agent?

Mostly. Values go into the command's environment and printed values are concealed by default. The agent can still see a value if a command transforms it before printing. It does not fill website logins.

What does axs cred cost?

axs cred is part of every axs plan: Personal at €12 a month, Team at €20 per person a month, both with a 14 day free trial. See Plans and billing.

On this page