By Valo

Keep API Keys Out of Claude Code: Stop Your AI Reading Your .env File (2026)

Pasted a key into the chat, then got told to change it? How Valo's Keyguard lets your AI use your passwords and API keys without ever seeing them, on Claude Code and Codex alike, free.

Your project needs a key. It might be for publishing a website, sending an email or using an online service. The AI asks for it, so you paste it into the chat. A minute later, the same AI tells you to go and change that key, because it now sits in your chat history for good.

Or you never pasted anything. The key was sitting in a settings file, the kind people call a .env file, and the AI opened it to "check the setup". Every key in that file is now part of the conversation and travels to the AI company along with the rest of the chat.

Both problems have the same cause: the AI has to see a password in order to use it. Valo removes that step.

Disclosure: this is the Valo blog, and Valo is the app we make.

Your AI uses the key, but never sees it

Valo, the first and only workspace for AI, has a password vault built in. It's called Keyguard, and it's free.

  • You save a key once. When the AI needs one, a small Save a password card appears above your message box with the name already filled in. You paste the key there, not into the chat. It goes straight into the vault, and the AI is told only that it was saved.
  • The AI uses it by name. When it's time to publish or deploy, the AI asks Keyguard for "the website key". Keyguard gives the key to the one command that needs it, then removes it from whatever that command prints, so it doesn't land in the chat.
  • It's encrypted and stays on your computer. One vault serves every project, locked with a password only you know.
  • Nothing to rotate. The key never entered the conversation, so there's nothing to clean up afterwards.

You don't need to know what an API key is to use this. (It's a password one program uses to talk to another.) Your assistant asks for the key, you paste it into the card, and the work goes on.

Already have a .env file full of keys?

Most projects start that way. In Valo, you don't have to copy keys out by hand, and the AI doesn't have to read the file.

Ask your assistant to move the keys into the vault. Valo reads the file itself and saves each key, and the AI gets back only the names. Once every key is safely stored, the assistant can erase the file. The erase refuses while any key in the file is missing from the vault. Throwing away an old key that isn't worth keeping asks you first, by default.

Until then, Valo's Secret Files guard watches for the AI trying to open a secrets file like .env and stops it before it runs. That guard is always on and has no off switch. Even so, the best place for a key is the vault, not a file.

You decide which keys ask first

Some keys matter more than others. A key that can spend money or publish to the world might deserve a second look.

In the Passwords panel, every key has an Ask? switch. Turn it on, and Valo shows you an Allow or Deny card each time the AI is about to use that key. That holds in every permission mode, even the one that silences ordinary prompts, and in Claude and Codex chats alike.

Deleting is guarded by default, too. If the AI tries to remove a key from the vault, Valo asks you first, with Keep it and Delete.

What Claude Code offers on its own

Claude Code lets you write rules into its settings files that block its file tools from opening a file such as .env. Anthropic explains how in its permissions docs, and notes that these rules don't cover every way a command can reach a file. Either way, the key still lives in a file, and the next new key usually still gets pasted into the chat.

Valo starts from the other end: the key goes into the vault, the AI works with its name, and the value stays out of the conversation.

Everything else in Valo

Keyguard is one piece. The whole is the point:

  • Permissions you set once: routine work runs, the risky things stop for you, and what needs you comes to your phone after a wait you choose. How Valo handles permissions.
  • Your private folders stay private: put them Off Limits, and the AI is blocked from what's on that list.
  • Context control: a lighter AI that thinks clearer and lasts longer. Per tool, per skill, per agent. Too many tools?
  • Human-like memory: your AI is reminded of a past lesson when the work touches it. Claude Code memory, done like yours.
  • Streamer Mode: hides secrets on screen while you share your work.
  • Built-in support: just tell your assistant what's wrong or what you want, and it sends it straight to the Valo team. No GitHub, no forms.

You never need to learn how it works: your assistant knows Valo inside out. New to all this? Start with Claude Code for non-coders.

Frequently asked questions

How do I keep API keys out of Claude Code's context?

Keep them out of the chat and out of files the AI can open. In Valo, you save each key in Keyguard's vault through a card, not the chat, and the AI uses it by name without ever seeing the value. Without Valo, you can block Claude Code from reading files like .env in its settings, as Anthropic's permissions docs explain, but new keys still tend to get pasted into the chat.

How do I stop Claude Code reading my .env file?

In Valo, the Secret Files guard is always on. It checks what the AI asks to do and stops attempts to open a .env file before they run. The lasting fix is to move the keys out of the file: your assistant can store them in the vault without reading them, then erase the file once every key is safe.

I already pasted a key into the chat. What now?

Treat it as exposed. Create a new key with the service it belongs to, cancel the old one there, and save the new key in Valo's vault so it doesn't happen again.

Does Keyguard protect every file on my computer?

No. It protects the passwords and keys stored in the vault. For private folders, use Off Limits, which blocks the AI from what's on that list. For keys, the safest place is the vault.

Does Keyguard work with Codex too?

Yes. The vault, the Ask? switches and the delete check work the same in Claude and Codex chats, because they live in Valo, not in the AI.

Is Keyguard free?

Yes. Keyguard is part of Valo's free core. Pro is $12.99 a month and adds deeper workspace tools, with a 14-day trial that starts inside the app, no card or email needed. See pricing.

Sources

All checked on November 23, 2026.