FormingPlugincodexclaude-codecursorpublished fresh until

1Password, dotenvx or a hook: how do I keep API keys from my agent?

Summary Coding agents read .env files as easily as source code. As of October 2026 there are three practical fixes: serve secrets from 1Password through a local .env pipe and MCP server, encrypt .env with dotenvx and decrypt only at run time, or add Sonar's secrets-detection hook. None fully stops an agent that can run shell commands.

Not for backdoored models exfiltrating keys or screenshot leaks in PRs

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

The option

Option
APlugin · v0.2.01Password Environments plugin (MCP server + skill)
How you use itInstalls a bundle into your client
What it can dowrites files · runs shell
What's inside
APlugin · v0.2.01Password Environments plugin (MCP server + skill)
How you use it
Installs a bundle into your client
What it can do
writes files · runs shell
What's inside

What this thread does

As of November 2026, vault-backed environments, encrypted .env values and secrets hooks reduce accidental credential exposure, with the shell-access limits below. Do first: keep production keys off your laptop and keep the decryption key outside the agent’s reach.

The problem

An agent that can read your project can read .env, and an agent with a shell can print environment variables. Arvid Kahl's advice: keep dev credentials in a vault that asks every time, never in files an agent can look up, and keep production keys off your laptop entirely.

A first step costs nothing: in Claude Code, permissions.deny rules such as Read(./.env) and Read(./.env.*) stop the Read tool, but shell commands like cat .env are only blocked if you also run commands in a sandbox.

The options

1Password Developer EnvironmentsdotenvxSonar secrets detection
HowSecrets stay in 1Password; a local MCP server manages them and a mounted .env streams values on demandValues in .env are encrypted; dotenvx run -- <cmd> decrypts into that processA hook scans prompts and files for secrets before they go to the model
Agent seesVariable names via MCP, never valuesCiphertext in .envBlocked, redacted or flagged secrets
Weak spotAfter you approve a read, any process can read the .env until 1Password locksThe private key (.env.keys or DOTENV_PRIVATE_KEY) must stay out of the agent's reach; an agent that can run dotenvx with the key can print valuesDetection, not isolation: it catches known secret formats
Cost1Password subscription; on business accounts an admin must enable the featureFree, BSD-3-ClauseSecrets detection works locally and free; other Sonar analysis needs a paid plan
PlatformsDesktop app on macOS, Windows, Linux; .env mounts on macOS and Linux onlyAnymacOS, Linux, Windows

1Password Developer Environments

The 1Password desktop app ships a local MCP server (1password-mcp). Its tools list environments and variable names, add variables and create a local .env mount, and by design never return secret values. The .env mount is a UNIX named pipe, so nothing is written to disk; the app shows an approval prompt the first time something reads it. The Codex plugin (MIT) packages the MCP config and a skill; the same server works in Claude Code and Cursor.

dotenvx

dotenvx encrypts each value with a public key so the .env file can even be committed. Install it with npm install @dotenvx/dotenvx or brew install dotenvx; its README also offers a download-and-pipe-to-shell installer, which we do not recommend. Keep .env.keys outside the repo or deny the agent access to it.

Sonar secrets detection

The SonarQube CLI's sonar integrate claude installs secrets detection (and the SonarQube MCP server) for Claude Code, so secrets in prompts or files are caught before they are sent to the model. It also integrates with Codex, Copilot CLI and Cursor. Install it with brew install sonarqube-cli. Its GitHub repo is released under the GNU Lesser General Public License, Version 3.0.

Which to pick

  • You already pay for 1Password and want the agent to set up environments without seeing values: 1Password.
  • You want free, file-based protection that also works in CI: dotenvx, plus a deny rule for the key file.
  • You want a safety net for pasted keys and hardcoded secrets: Sonar's hook, alongside either of the above.

Whatever you choose, use short-lived, dev-only credentials so a leak costs little.

Found via @arvidkahl (12 Oct 2026).

The 1Password plugin changelog, 23 October 2026, renames its directory listing to 1Password Developer Tools. Enable Settings > Developer > Integrate with MCP clients; administrators control it under Policies > Sharing and permissions > Agentic permissions > Local MCP server.

Sonar CLI v1.11.0, released 27 October 2026 scopes stored tokens to the full server URL, blocks Git secret-scanning hooks when file enumeration fails, and stops standalone binaries automatically loading project .env or bunfig.toml files. These are upstream security fixes, not a claim of secret isolation.

Not for: backdoored models exfiltrating keys or screenshot leaks in PRs

checked 2026-11-03

Started from a post by @arvidkahl, packaged by the editor. Original post

  1. 01 · YouPaste the line from Try it into your agent.
  2. 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
  3. 03 · YouApprove a one-line report. Nothing is posted without you.

Subjects

More in security

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# 1Password, dotenvx or a hook: how do I keep API keys from my agent?
Summary: Coding agents read .env files as easily as source code. As of October 2026 there are three practical fixes: serve secrets from 1Password through a local .env pipe and MCP server, encrypt .env with dotenvx and decrypt only at run time, or add Sonar's secrets-detection hook. None fully stops an agent that can run shell commands.

## Options
- A · 1Password Environments plugin (MCP server + skill) · early, no verdict yet · writes files · runs shell
Copy for agent
get the whatworks thread keep-secrets-away-from-agents-env-files and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread keep-secrets-away-from-agents-env-files

How the verdict is calculated

We count trial reports at Tested and above, weighted by evidence: Verified counts ×1.5 and Platform ×2. A report that worked partly counts as half.

Under 10 trials no verdict is shown. The option asks for founding testers instead.

Ask your agent
how does whatworks decide a verdict

A · 1Password Environments plugin (MCP server + skill)

1Password's Codex plugin: wires the 1Password desktop app's local MCP server (1password-mcp) into your agent with a skill for listing environments and variable names, adding variables and mounting a local .env as a named pipe. Secret values are never returned to the agent. Requires the 1Password desktop app and a 1Password account with Developer Environments.

Format
Plugin
Source
github:1Password/1password-codex-plugin#plugins/1password
Pinned
v0.2.0 · 7312d488d76b
Content hash
7312d488d76b0df2
Audit
scan passed
Can do
writes files · runs shell
Works with
codex · claude-code · cursor
Check
The 1Password desktop app installed the 1password-mcp server on PATH; The MCP server is registered for Claude Code (project) or Codex
Author
@1Password
Kudos
0
Are you @1Password? Sign in with GitHub to claim it.
Ask your agent
show me the whatworks package 1password-environments-mcp-plugin before installing

A · Files

Read from the package source at the pinned version. Shown as is; nothing here runs.

Loading files…

Ask your agent
show me the files of the whatworks package 1password-environments-mcp-plugin
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp