env-harvester
v1.0.2
Published
Automatically discover environment variables used across your codebase and generate professional `.env` and `.env.example` files with contextual placeholders and developer guidance.
Readme
Env Harvester
Automatically discover environment variables used across your codebase and generate professional .env and .env.example files with contextual placeholders and developer guidance.
Overview
Env Harvester is an AI-powered CLI tool that scans JavaScript and TypeScript projects, detects environment variable usage, and generates ready-to-use environment configuration files.
Instead of manually creating .env files, Env Harvester analyzes your codebase, identifies required variables, and uses Gemini AI to provide:
- Realistic placeholder values
- Provider-specific setup instructions
- Usage location tracking
- Automatic
.envand.env.examplegeneration
Features
- Automatic environment variable discovery
- Supports JavaScript, TypeScript, React, Next.js, and Node.js projects
- Generates both
.envand.env.example - Tracks where each variable is used
- AI-generated setup instructions
- Safe file creation logic
- Zero configuration setup
- Smart handling of existing environment files
Installation
Global Installation
npm install -g env-harvesterUsing NPX
npx env-harvesterRequirements
- Node.js 18 or later
- Gemini API Key
You can generate a Gemini API key from Google AI Studio.
Setting Up GEMINI_API_KEY
Windows (Command Prompt)
Temporary (current terminal session only):
set GEMINI_API_KEY=your_api_key_herePermanent:
setx GEMINI_API_KEY "your_api_key_here"Verify:
echo %GEMINI_API_KEY%Windows (PowerShell)
Temporary:
$env:GEMINI_API_KEY="your_api_key_here"Permanent:
[Environment]::SetEnvironmentVariable(
"GEMINI_API_KEY",
"your_api_key_here",
"User"
)Verify:
$env:GEMINI_API_KEYmacOS (zsh)
Temporary:
export GEMINI_API_KEY="your_api_key_here"Permanent:
echo 'export GEMINI_API_KEY="your_api_key_here"' >> ~/.zshrc
source ~/.zshrcVerify:
echo $GEMINI_API_KEYLinux (bash)
Temporary:
export GEMINI_API_KEY="your_api_key_here"Permanent:
echo 'export GEMINI_API_KEY="your_api_key_here"' >> ~/.bashrc
source ~/.bashrcVerify:
echo $GEMINI_API_KEYUsing a .env File
You may also create a .env file:
GEMINI_API_KEY=your_api_key_hereUsage
Navigate to your project directory and run:
env-harvesterThe CLI will:
- Crawl your project files
- Detect environment variables
- Track usage locations
- Consult Gemini AI for contextual placeholders
- Generate configuration files
- Add setup instructions for each variable
Example Output
Generated .env file:
# Used in: src/config/database.js
# How to get: Create a MongoDB Atlas cluster and copy the connection string.
MONGODB_URI=mongodb+srv://username:[email protected]/db
# Used in: src/server.js
# How to get: Standard local development port.
PORT=3000
# Used in: src/services/stripe.js
# How to get: Stripe Dashboard → Developers → API Keys.
STRIPE_SECRET_KEY=sk_test_xxxxxxxxxxxxSmart File Handling
Scenario 1
Existing files:
.env
.env.exampleResult:
No changes made.Scenario 2
Existing files:
.envResult:
Creates only .env.exampleScenario 3
Existing files:
NoneResult:
Creates both .env and .env.exampleScenario 4
Existing files:
.env.exampleResult:
Creates only .envSupported File Types
.js
.jsx
.ts
.tsxIgnored Directories
node_modules
.git
dist
build
generated
.next
coverageExample Workflow
cd my-project
env-harvesterOutput:
✔ Crawling project directory...
✔ Scanning files and tracking usage locations...
✔ Consulting AI to infer context and safe fallbacks...
✔ Writing configuration files...
✔ Success! Harvested 12 variables. Created both .env and .env.example.Security Notice
Env Harvester never generates real secrets or production credentials.
All generated values are placeholders intended to help developers configure their projects quickly and safely. Actual credentials should always be obtained directly from the corresponding service provider.
Current Detection Support
Currently detects:
process.env.MY_VARIABLE;Planned Improvements
- Support for
import.meta.env - Support for destructured environment variables
const { API_KEY } = process.env;- Support for bracket notation
process.env["API_KEY"];
process.env["API_KEY"];- Monorepo support
- Interactive mode
- CI/CD integration
- VS Code extension
- Secret validation
Contributing
Contributions, suggestions, and bug reports are welcome.
Please open an issue before submitting major changes.
Author
Sujal Dey
License
Copyright (c) 2026 Sujal Dey
All Rights Reserved.
Permission is granted to use this software.
You may not:
- Modify the software
- Create derivative works
- Redistribute the software
- Publish modified versions
- Sell, sublicense, or repackage the software
- Remove copyright notices
This software is provided "as is" without warranty of any kind.
