How to Share Environment Variables With Your Team Without Slack or DMs
A new engineer joins on Monday. By lunch they need the staging database URL, the Stripe test key, and the .env file that "just works." Someone pastes it into a DM. It sits in Slack history, gets forwarded to a laptop, and never gets removed.
This is how most teams share environment variables today. It works until it doesn't. This guide lays out a safer pattern that stays fast for the people who need it.
Why chat is the wrong place
Chat tools were built for conversation, not secrets. Messages persist, get indexed, sync to every device, and are copied into notifications. Even if you delete a message, the value may already be in someone's clipboard, a backup, or a search index.
The problem is not that your team is careless. The problem is that the process has no boundary. Anyone who can read the channel can read the value, and nobody can easily answer "who has seen this key?"
What a good setup needs
A workable setup for a small team has five properties:
- One source of truth. Every variable lives in one place, not in five
.envfiles. - Encryption at rest. Values are stored encrypted, so a database leak does not expose plain text.
- Scoping by project and environment.
DATABASE_URLfor staging is not the same record asDATABASE_URLfor production. - Role-based access. Engineers get the environments they need. Contractors get less. Departing members lose access in one step.
- A low-friction way to pull values. If the secure path is slower than pasting into Slack, people will paste into Slack.
A practical workflow
Start by inventorying what your team actually shares. Most projects have fewer variables than people expect. For each one, answer three questions:
- Which environments use it?
- Who needs to read it?
- Who needs to change it?
Then move the values into a single encrypted store, organized by project and environment. Give each person access by role. Engineers who work on the app get read access to local and staging. Only a small group touches production.
For local development, have each engineer pull the values they need into a local file that git ignores:
# Pull the development environment for this project into .env
envly pull --env development > .env
Nobody copies the value by hand. Nobody needs it in a message. A new engineer gets access, runs the pull command, and starts working.
Handling the hard cases
A teammate needs one value, once. Give them access for that environment rather than sending the value. If you must share a one-time value, rotate it afterward.
A key was already pasted into chat. Treat it as leaked. Rotate the credential at the provider, update the store, and then delete the message. Deleting first gives you nothing if the value was already read.
Someone leaves the team. Remove their access to the store. Rotate any shared credentials they had access to, especially production ones. Access removal should take one step, not a scavenger hunt through old DMs.
Contractors. Scope their access to the projects and environments they need, and set a reminder to review it at the end of the engagement.
What to tell your team
Make the rule short enough to remember:
- Secrets live in the store, not in chat, email, or tickets.
- Pull what you need into a local file that git ignores.
- Ask for access, not for a copy of the value.
- If a value leaks, rotate it first and clean up second.
Checklist
- Every shared variable is in one encrypted store
- Access is granted by project, environment, and role
- Local
.envfiles are in.gitignore - A pull command or equivalent replaces manual copying
- Offboarding removes access and rotates shared credentials
- Chat history has been searched for pasted values, and any found were rotated
Sharing secrets should feel calm and handled. When the process is clear, nobody needs to paste a key into a thread to get work done.
