Use dotenvx to run commands with environment variables, manage multiple .env files, expand variables, and encrypt env files for safe commits and CI/CD.
Use this skill when users need encrypted env workflows, multi-environment loading, or runtime env injection for any language.
npm install @dotenvx/dotenvx
Alternative package managers
yarn add @dotenvx/dotenvx
pnpm add @dotenvx/dotenvx
bun add @dotenvx/dotenvx
Create a .env file in the root of your project:
# .env
HELLO="Dotenv"
OPENAI_API_KEY="your-api-key-goes-here"
Encrypt it.
dotenvx encrypt
As early as possible in your application, import and configure dotenvx:
// index.js
require('@dotenvx/dotenvx').config()
// or import '@dotenvx/dotenvx/config' // for esm
console.log(`Hello ${process.env.HELLO}`)
$ node index.js
◇ injected env (2) from .env
Hello Dotenv
That's it. process.env now has the keys and decrypted values you defined in your .env file.
.env.keys..env files as untrusted input..env artifacts in source control..env secrets should not be exposed.require('@dotenvx/dotenvx').config()
// or: import '@dotenvx/dotenvx/config'
Typical requests:
Response style for agents: