
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
@akshitkrnagpal/env-doctor
Advanced tools
A .env file auditor for developers — detect unused vars, missing vars, hardcoded secrets, env drift, and more
A .env file auditor for developers. Detect unused variables, missing variables, hardcoded secrets, environment drift, and more across your entire codebase or monorepo.
.env but never referenced in code.env.env.development vs .env.production and find inconsistencies.env has all variables from .env.example.env.example from an existing .env (values stripped).env.example.env is gitignored, tracked, or leaked in git history.env files showing added, removed, and changed values.envdoctorrc.json or package.jsonenv-doctor scans for environment variable usage across multiple languages:
process.env.VAR, process.env['VAR'], process.env["VAR"]os.environ['VAR'], os.environ.get('VAR'), os.getenv('VAR')ENV['VAR'], ENV.fetch('VAR')os.Getenv("VAR")env::var("VAR"), std::env::var("VAR")getenv('VAR'), $_ENV['VAR'], $_SERVER['VAR']System.getenv("VAR")${VAR} references# Using npm
npm install -g @akshitkrnagpal/env-doctor
# Run without installing
npx @akshitkrnagpal/env-doctor
# Using bun
bunx @akshitkrnagpal/env-doctor
# Run all audits (default command)
env-doctor
# Individual commands
env-doctor unused # Find unused env vars
env-doctor missing # Find missing env vars
env-doctor drift # Compare env files across environments
env-doctor secrets # Scan for hardcoded secrets
env-doctor validate # Validate .env file format
env-doctor sync # Check .env against .env.example
env-doctor init # Create .env.example from .env
env-doctor fix # Auto-fix common issues
env-doctor git-check # Check git safety for .env files
env-doctor diff <a> <b> # Detailed diff between two .env files
env-doctor report # Generate markdown audit report
env-doctor completion # Generate shell completions
-v, --verbose Verbose output with extra details
-q, --quiet Suppress non-essential output
--no-color Disable color output
--json Output as JSON (for CI integration)
-d, --dir <path> Target directory (default: cwd)
-e, --env-file <path> Specific .env file (default: .env)
--ignore <patterns...> Directories/files to ignore
Auto-fix common .env file issues:
# Preview fixes without writing
env-doctor fix --dry-run
# Apply all fixes (remove duplicates, sort, add missing)
env-doctor fix
# Selective fixes
env-doctor fix --no-sort # Skip sorting
env-doctor fix --no-remove-duplicates # Keep duplicates
env-doctor fix --no-add-missing # Don't add from .env.example
The fix command:
.env.example with placeholder valuesCheck git safety for .env files:
# Run standalone
env-doctor git-check
# Also included in the default check command
env-doctor check
The git-check command:
.gitignore -- warns if .env is not listed in .gitignore.env files are tracked by git.env.example -- suggests adding .env.example to git if missing.env filesShow a detailed diff between two .env files:
# Compare two env files
env-doctor diff .env.development .env.production
# Show unchanged keys too
env-doctor diff .env.local .env.staging --verbose
# JSON output
env-doctor diff .env .env.example --json
The diff shows:
--verbose)Generate a markdown audit report:
# Print report to stdout
env-doctor report
# Write report to a file
env-doctor report --output audit-report.md
# JSON output
env-doctor report --json
The report includes:
# Bash (add to ~/.bashrc)
eval "$(env-doctor completion bash)"
# Zsh (add to ~/.zshrc)
eval "$(env-doctor completion zsh)"
# Fish (save to completions dir)
env-doctor completion fish > ~/.config/fish/completions/env-doctor.fish
env-doctor loads settings from .envdoctorrc.json or the "env-doctor" key in package.json. CLI flags always take precedence over config file values.
.envdoctorrc.json{
"ignore": ["vendor", "tmp", "generated"],
"envFile": ".env.local",
"secretPatterns": [
{
"name": "Custom Internal Token",
"regex": "INTERNAL_[A-Z0-9]{32}",
"severity": "high"
}
]
}
package.json{
"env-doctor": {
"ignore": ["vendor"],
"envFile": ".env.local"
}
}
| Option | Type | Description |
|---|---|---|
ignore | string[] | Glob patterns to ignore when scanning |
envFile | string | Path to the .env file (relative to root) |
secretPatterns | array | Additional secret patterns with name, regex, severity |
# Scan a specific project directory
env-doctor -d ./my-project
# Use a specific env file
env-doctor -e .env.local
# JSON output for CI pipelines
env-doctor --json
# Ignore certain directories
env-doctor --ignore vendor tmp
# Compare specific env files
env-doctor drift .env.staging .env.production
# Generate .env.example
env-doctor init -o .env.example
# Verbose output for debugging
env-doctor missing -v
# Fix issues in dry-run mode
env-doctor fix --dry-run
env-doctor exits with code 0 when no issues are found and code 1 when issues are detected, making it suitable for CI pipelines.
name: Env Audit
on: [push, pull_request]
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bunx @akshitkrnagpal/env-doctor --json
# Install dependencies
bun install
# Run in dev mode
bun dev
# Run tests
bun test
# Type check
bun run typecheck
# Build for npm
bun run build:npm
MIT
FAQs
A .env file auditor for developers — detect unused vars, missing vars, hardcoded secrets, env drift, and more
The npm package @akshitkrnagpal/env-doctor receives a total of 4 weekly downloads. As such, @akshitkrnagpal/env-doctor popularity was classified as not popular.
We found that @akshitkrnagpal/env-doctor demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.