Keep API keys out of .env files
A coding agent working in your project can open any file you can, .env included. passkeyvault.ai keeps each key encrypted until you approve a request for it, then gives the value to one command instead of leaving it in the folder.
Updated 7 November 2026
Why .env files and coding agents mix badly
A .env file is plain text in your project folder. An agent that can read files or run commands there can read it, and so can any script or package it runs as you.
.gitignore keeps the file out of your repository. It does nothing to stop a program on your machine opening it.
Once an agent has read a key, the key is part of that conversation and goes to the model with it. Deleting the file afterwards does not take it back.
A .env file and passkeyvault.ai side by side
| .env file | passkeyvault.ai | |
|---|---|---|
| Where the key is kept | Plain text in your project folder | Encrypted in your browser before Raq.com stores it |
| Who can read it | Anything running as you that can open the folder | You, with your passkey. An agent only after you approve its request |
| What an agent sees | The value, if it opens the file | The name. Each value needs its own approved request |
| How your code gets it | Loaded from the file | Set as an environment variable for one command |
| How long access lasts | Until you delete or rotate the key | One command by default. Up to 24 hours if the agent asks Nature Work to keep a session copy |
| Stopping access | Delete the file and rotate the key | Freeze one secret or the whole vault. Approved values not yet collected are refused too |
Move a key from .env into the vault
-
Set up your vault
Create a free Raq.com account, create your vault, register a passkey and save the recovery code.
-
Add the key under a name
For example "Stripe test key". Saving asks for your passkey, and your browser encrypts the value before it is stored.
-
Take it out of .env
If an agent has already read the file, rotate the key with the provider as well. Moving an exposed key does not make it secret again.
-
Run the command through Nature Work
Your agent requests the key by name, you approve it, and nw-agent vault exec runs the command with the variable your code already reads, such as STRIPE_API_KEY.
What changes for your code
The key arrives as an environment variable in the one command that needs it, so code that reads process.env or os.environ works as before. Code that opens the .env file itself won't find the key there.
The command runs with no input and its output comes back when it finishes, with the key and its base64, hex, URL-encoded and JSON forms replaced by [REDACTED_SECRET]. It is stopped after 10 minutes unless the agent sets a longer limit, up to 24 hours.
That suits scripts, migrations, deploys and API calls. It is a poor fit for a dev server you leave running, because nothing comes back until the command ends.
Questions
Does .gitignore stop an AI agent reading my .env file?
No. It only stops git committing the file. Anything that can read files in your project can still open it.
Can I just tell the agent not to open .env?
You can, and it may listen, but the file is still there for the agent, its scripts and its packages. With the key in your vault there is no readable copy in the folder at all.
Does this stop a command leaking the key?
No. The command the agent runs with the key gets the real value. Scrubbing catches the key appearing in output by accident, not a command written to send it somewhere or print it in another form.
Which agents keep the key out of the chat?
Claude Code and Codex running in Nature Work on your Mac. Other agents connected to Raq.com can request a key too, but they open it themselves, so the value passes through them.
Set up your vault
Create a Raq.com account, register a passkey and save the recovery code before adding your first secret. It's free, with no charge per secret or per release.
- Store API keys, tokens and other secrets
- Approve or deny each agent request
- Register passkeys on more than one device
- Freeze one secret or the whole vault
- Add it to your phone's home screen