Open source project / 2026
EnvDoctor
A zero-dependency Python tool for checking .env files, synchronizing templates and finding undocumented environment variables in code.
The problem
A variable added locally but forgotten in .env.example crashes production on deploy; stale variables linger because nobody knows what is still needed.
Approach
EnvDoctor checks the .env ↔ .env.example contract, syncs missing placeholders safely, and audits the codebase with AST analysis to find variables that are used but undocumented.
System architecture
Python standard library only; handles multiline quoted values and emits JSON output for CI pipelines.
Decisions & outcome
Strict mode fails the build on any contract violation — configuration drift is treated as a build error, not a warning. Available on PyPI as envdoctor-cli. Its check, sync and audit commands compare configuration files, add masked placeholders to templates and search source code for environment-variable usage; JSON output supports automation.
Use Cases & CLI Reference
- Catching missing or stale keys between .env and .env.example before deployment in Python and full-stack repositories.
- Auditing source code with Python AST analysis to surface undocumented environment variables read via os.getenv or os.environ.
- Enforcing the .env contract in CI/CD pipelines with strict exit codes and machine-readable JSON output.
# Install and validate .env contract
pip install envdoctor-cli
envdoctor check --strict
# Sync .env.example with masked placeholders and run AST audit
envdoctor sync
envdoctor audit --format json