| name | dotenvx |
| description | Use dotenvx to run commands with environment variables, manage multiple .env files, expand variables, and encrypt env files for safe commits and CI/CD. |
dotenvx
dotenvx is a secure dotenv workflow for any language.
Use this skill when you need to:
- run commands with env vars from
.env files
- load multiple environment files (
.env, .env.production, etc.)
- encrypt
.env files and keep keys out of git
- use env files safely in CI/CD
Quickstart
Install:
npm install @dotenvx/dotenvx --save
Node usage:
require('@dotenvx/dotenvx').config()
CLI usage (any language):
dotenvx run -- node index.js
Core Commands
Run with default .env:
dotenvx run -- <command>
Load a specific file:
dotenvx run -f .env.production -- <command>
Load multiple files (first wins):
dotenvx run -f .env.local -f .env -- <command>
Make later files win:
dotenvx run -f .env.local -f .env --overload -- <command>
Encryption Workflow
Encrypt:
dotenvx encrypt
dotenvx encrypt -f .env.production
Run encrypted envs by supplying private key(s):
DOTENV_PRIVATE_KEY_PRODUCTION="<key>" dotenvx run -f .env.production -- <command>
Git rule:
.env.keys
Commit encrypted .env* files if needed, but never commit .env.keys.
Variable Expansion
Example:
USERNAME="alice"
DATABASE_URL="postgres://${USERNAME}@localhost/mydb"
dotenvx run resolves ${...} expressions at runtime.
CI/CD Pattern
Set private keys as CI secrets, then run through dotenvx:
env:
DOTENV_PRIVATE_KEY_PRODUCTION: ${{ secrets.DOTENV_PRIVATE_KEY_PRODUCTION }}
run: dotenvx run -f .env.production -- node index.js
Agent Usage
Install this repo as an agent skill package:
npx skills add motdotla/dotenv
Typical requests:
- "set up dotenvx for production"
- "encrypt my .env.production and wire CI"
- "load .env.local and .env safely"
References