"Come with me if you want to deploy." — A developer should be able to run
npx envinatorin a fresh repo and be operational in seconds.
Envinator is a specialized CLI tool sent back in time to statically analyze your codebase. It identifies all usages of process.env, compares them against your local .env file, and ruthlessly prompts you to populate missing variables.
No more undefined runtime errors. No more asking "What's the API key again?"
You don't even need to install it. Just run it in your project root:
npx envinator-cliEnvinator will:
- Scan your directory for
process.envusages using AST analysis. - Identify discrepancies against your current
.envfile. - Interrogate you to fill in missing values.
- Update your
.env(and optionally.env.example).
- Cybernetic AST Scanning: Uses
ts-morphto parse your code. It won't get fooled by comments or strings like regex would. - Destructuring Detection: Detects complex patterns like:
const { DB_HOST, DB_PORT: port } = process.env; // Targets acquired.
- Secure Input: Automatically masks sensitive keys (PASSWORD, KEY, SECRET, TOKEN) during input.
- Target Location: Shows you exactly where a variable is used (file & line number).
- Skynet Ready (CI/CD): Auto-detects non-TTY environments and switches to lint mode.
- Zero Config: Works out of the box for TypeScript and JavaScript projects.
npx envinator [options]| Option | Alias | Description | Default |
|---|---|---|---|
--dir <path> |
-d |
The directory to scan for code | ./ |
--env <path> |
-e |
Path to your environment file | .env |
--example |
-x |
Update .env.example with new keys | true |
--no-example |
Skip updating .env.example | ||
--dry-run |
Scan and report without writing to disk | false |
|
--lint |
Exit code 1 if variables are missing (CI mode) | false |
Use Envinator to fail your build if a developer forgot to add a new variable:
# In your GitHub Action
- name: Verify Environment Integrity
run: npx envinator --dir ./src --env .env.example --lintEnvinator uses ts-morph to build an Abstract Syntax Tree of your code. It looks for three access patterns:
- Property Access:
process.env.API_URL - Element Access:
process.env['STRIPE_KEY'] - Destructuring:
const { REDIS_URL } = process.env
It ignores dynamic access (e.g., process.env[dynamicVar]) and warns you about them since they cannot be statically determined.
If you want to install it globally or as a dev dependency:
npm install -D envinator
# or
yarn add -D envinator
# or
pnpm add -D envinatorAdd it to your package.json scripts:
{
"scripts": {
"env:check": "envinator --lint",
"env:setup": "envinator"
}
}# Install dependencies
npm install
# Run in development
npm run dev -- --dir ./tests/fixtures --dry-run
# Run tests
npm test
# Build for production
npm run build- Fork the repository
- Create your feature branch (
git checkout -b feature/skynet-upgrade) - Commit your changes
- Push to the branch
- Open a Pull Request
MIT © 2026
"Hasta la vista, undefined."