Stop Copy-Pasting .env Files Between Projects
You know the drill. New project, new repo, and someone on Slack goes “hey can you send me the .env for staging?” Then you dig through old messages, find something that’s probably outdated, paste it in, and hope for the best.
Or maybe you’re the person who keeps a secrets.txt file on your desktop. No judgment. We’ve all been there.
The problem isn’t laziness, it’s that there hasn’t been a good workflow for this. Until now.
The API Stronghold CLI
The CLI connects directly to your API Stronghold vault and generates .env files on demand. No copy-pasting. No stale secrets. No Slack messages you’ll regret later.
Install it in one line:
curl -fsSL https://www.apistronghold.com/cli/install.sh | sh
Then authenticate:
api-stronghold-cli login
That’s it. You’re in.
Generate .env Files in Seconds
Here’s the basic workflow. You have a project, it needs environment variables, and those variables live in a deployment profile on API Stronghold.
# See what deployments you have
api-stronghold-cli deployment list
ID Name Provider Environment Project ID
abc123 my-app-prod vercel prod proj_123
def456 my-app-staging github staging proj_123
ghi789 my-app-dev cloudflare dev proj_123
Now pull the one you need:
api-stronghold-cli deployment env-file staging .env
Done. Your .env file gets generated with every secret from that deployment, decrypted and properly formatted:
# Generated by API Stronghold CLI
# Generated on: 2026-02-26 14:30:45
API_KEY=sk-1234567890abcdef
DATABASE_URL=postgresql://user:pass@localhost:5432/db
SECRET_TOKEN="complex value with spaces"
No asking around. No guessing if the values are current. They come straight from the vault.
If you’re still storing secrets in .env files on developer laptops, that’s a whole separate problem, but the CLI fixes it either way.
It Remembers Your Preferences
This is the part that actually makes daily life better.
The first time you run deployment env-file staging .env in a project directory, the CLI might ask you to pick which staging deployment you mean (if you have several). After that? It remembers.
It drops a small .api-stronghold-deployment file in your project root:
{
"environment_mappings": {
"staging": "def456-...",
"prod": "abc123-..."
}
}
Next time you run the same command, it skips the selection and goes straight to generating. Different project directory? Different preferences. Each repo gets its own mapping.
Want to start fresh? Just add --reset-config.
Multiple Codebases, No Confusion
If you’re running a few services, a web app, a mobile API, a backend, they probably all have “staging” and “prod” environments. The env/name syntax keeps things clear:
# Web app secrets
api-stronghold-cli deployment env-file staging/web-app .env
# Mobile API secrets
api-stronghold-cli deployment env-file staging/mobile-api .env
# Backend service
api-stronghold-cli deployment env-file staging/backend-service .env
No ambiguity. The command itself documents what you’re pulling.
Skip the File Entirely
Sometimes you don’t want a file at all. Maybe you’re in a CI/CD pipeline, or you just want the variables in your current shell session.
eval $(api-stronghold-cli deployment env-file staging --stdout)
Variables load directly into your shell. No temp files, no cleanup.
This works great in GitHub Actions, too:
- name: Load secrets
run: |
eval $(api-stronghold-cli deployment env-file prod --stdout)
# Your secrets are now available as environment variables
Sync to Providers Directly
Beyond generating files, the CLI can push your secrets directly to external platforms:
api-stronghold-cli deployment sync <deployment-id>
This syncs your deployment’s secrets to wherever they need to go, GitHub Actions secrets, Vercel environment variables, Cloudflare Workers secrets. One command, and every platform has the current values.
When you rotate a key in API Stronghold, run sync again. Every downstream service gets the update. If you’re not rotating keys regularly, here’s why you should be.
Zero-Knowledge, Even on the Command Line
A quick note on security, because it matters here.
The CLI uses the same zero-knowledge encryption as the rest of API Stronghold. Your master password decrypts secrets locally, they’re never sent over the wire in plaintext. The server literally can’t read your keys.
Tokens refresh automatically (if you enable it), passwords are encrypted with PBKDF2 + AES-GCM, and failed auth attempts trigger automatic credential cleanup. Paranoid? Good. So are we.
# Lock down your config
chmod 700 ~/.api-stronghold
chmod 600 ~/.api-stronghold/config.yaml
The Workflow, Start to Finish
Here’s what a typical day looks like once you’re set up:
- Clone a repo or
cdinto a project - Run
api-stronghold-cli deployment env-file dev .env - Start coding
That’s the whole thing. Three steps, and you’ve got fresh secrets from the vault without bothering anyone.
When you onboard a new developer, they install the CLI, run login, and pull whatever environments they need. No more “ask Sarah for the staging keys” or hunting through Confluence pages that haven’t been updated since 2024. We wrote a whole post about how broken first-day key handoffs are, the CLI is the fix.
Getting started: Install the CLI with curl -fsSL https://www.apistronghold.com/cli/install.sh | sh, then run api-stronghold-cli login to authenticate. You’ll be generating .env files in under a minute.
What’s Next
We’re working on deployment aliases, default environment mappings, and tighter CI/CD integrations. The goal is simple: managing secrets across projects should be as easy as git pull.
If your team is still passing .env files around manually, give the CLI a try. It takes about two minutes to set up, and you’ll wonder why you didn’t do it sooner.
Get started with API Stronghold →
📚 Related Reading
- Stop Storing API Keys in .env Files on Developer Laptops, Why local .env files are a security risk and what to do instead
- Your First-Day API Key Handoff Is Broken, How the CLI fixes developer onboarding
- From Manual Copy-Paste to One-Click Deploy, Automating your entire secrets workflow
- Why Your GitHub Secrets Aren’t as Secure as You Think, The CI/CD side of the secrets problem
- Why API Key Rotation Matters, And how the CLI makes rotation painless
Still managing secrets across Slack messages and shared drives? Start your free trial and see how the CLI changes your workflow.