It's a new developer's first day. They clone the repo, run the install, and the app crashes: missing DATABASE_URL. Someone on the team sends them the .env file. Usually in a Slack DM.
That DM now contains every secret the app uses, stored forever in Slack and on both laptops. Multiply that by every new hire and every contractor, and your production database password is sitting in dozens of chat histories.
Here's a better way.
Why the usual methods are risky
Slack or Teams DMs. Messages are kept indefinitely, synced to every device, included in exports, and searchable by anyone who later gets into either account.
Committing it to git. Even in a private repository, every clone, fork and CI runner gets a copy, and it stays in the history forever. If the repository ever becomes public, or a laptop is lost, every secret is exposed. Keep .env in .gitignore.
Email or shared drives. Same problem as chat: permanent, searchable copies in places you don't control.
A .env.example with real values. It happens more than you'd think. Example files should only contain placeholders.
The quick fix: send the file as a one-time link
For a one-off handoff, send the .env file through a link that works once.
In the browser:
- Go to dropzone.sh and drop in the
.envfile. - Copy the link and send it to your teammate.
- They open it, click Reveal, and the file downloads. It's then deleted from Dropzone's servers.
From the terminal (encrypts on your machine):
curl -fsSO https://dropzone.sh/dropzone.mjs
node dropzone.mjs send .env # prints a one-time linkYour teammate runs:
node dropzone.mjs open "$LINK" -o .env # writes the file, onceThe Slack DM now only contains a dead link. Nothing in the chat history can be used against you later.
The better long-term setup
One-time links fix the handoff. For a team that's growing, it's worth not handing .env files around at all.
1. Keep a .env.example with placeholders
# .env.example
DATABASE_URL=postgres://user:password@localhost:5432/app
STRIPE_SECRET_KEY=sk_test_xxxIt documents which variables exist without containing any of them.
2. Give developers their own development credentials
A local database, test-mode API keys, personal sandbox accounts. If a laptop is lost, you revoke one person's dev keys, not production.
3. Pull shared secrets from a secrets manager
Tools like Doppler, Infisical, 1Password, AWS Secrets Manager or your hosting provider's CLI can write a .env from a central store. Access is per person and can be revoked, and there's an audit log.
# Example with the Vercel CLI
vercel env pull .env.local4. Use one-time links for everything else
Bootstrapping the secrets manager itself, a contractor who won't get vault access, a single key from a third-party dashboard: those handoffs are where one-time links fit.
Sharing .env files with AI coding agents
If you work with Claude Code, Cursor or another coding agent, don't paste the .env into the chat. Send the agent a one-time link and have it write the file directly, so the secrets never appear in the transcript. See Give your coding agent a .env file for the full setup.
Checklist
-
.envis in.gitignore -
.env.examplecontains only placeholders - Developers use their own dev and test credentials where possible
- Shared secrets come from a secrets manager
- Any
.envthat must be handed over goes through a one-time link - Production secrets are rotated when someone leaves
Related: How to share API keys securely · How AI agents should handle secrets