Compare dotenv files and report configuration drift.
Project description
env-drift-report
Compare dotenv files and report configuration drift before missing keys reach a deploy, onboarding guide, or CI job.
Problem
.env.example files often drift away from real local or template configuration. A teammate adds STRIPE_WEBHOOK_SECRET to one file, leaves another template untouched, and the gap only appears after a failed setup. This CLI checks required keys, empty values, duplicate entries, malformed lines, and unexpected extras with output that works for humans or CI logs.
Install
pip install env-drift-report
For local development:
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
CLI Usage
Compare .env against .env.example:
env-drift-report .env
Compare several files against a reference:
env-drift-report --reference .env.example .env .env.production.example
Emit JSON for scripts:
env-drift-report --reference .env.example --format json .env
Write an HTML report for CI artifacts or onboarding handoff:
env-drift-report --reference .env.example --format html --output env-report.html .env .env.local.example
Ignore target-only keys when local files are expected to contain private values:
env-drift-report --ignore-extra .env
Ignore commented KEY=value examples:
env-drift-report --ignore-commented .env
The command exits with:
0when every target file passes1when drift is found2when a file cannot be read
Report Formats
text is optimized for terminal use, json is stable for scripts, and html creates a self-contained report that can be uploaded as a build artifact or shared during setup reviews.
Python Usage
from env_drift_report import compare_env_files
report = compare_env_files(".env.example", ".env")
if not report.ok:
print(report.missing)
Example Output
FAIL .env
Reference: .env.example
Missing:
- REDIS_URL
Empty:
- API_KEY (line 1)
Extra:
- DEBUG_SQL
Duplicates:
- .env:PORT (lines 2, 3)
Supported Dotenv Syntax
The parser intentionally supports the common subset used by templates:
KEY=valueexport KEY=value- commented examples like
# KEY=value - quoted values
- inline comments after unquoted values
It does not evaluate shell expansion or source other files.
Development
Run tests:
PYTHONPATH=src python3 -m unittest discover -s tests
Build the package:
python3 -m build --no-isolation
Contributing
Issues and pull requests are welcome. Keep changes focused, include tests for behavior changes, and update the README when command behavior changes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file env_drift_report-0.2.0.tar.gz.
File metadata
- Download URL: env_drift_report-0.2.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfe5152c01c199d66fa99bbe30886fcc4ddfc5d0b3a3c2ba925d36f9f359731d
|
|
| MD5 |
f93440fd2c1ee4d6e9055e6a2836999e
|
|
| BLAKE2b-256 |
b4bbdf34f58eb107852b9334d7f6a6e8a50eafa55870ae3d7f844e71ff3fbf3a
|
File details
Details for the file env_drift_report-0.2.0-py3-none-any.whl.
File metadata
- Download URL: env_drift_report-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9dc368ca28d8df764e5e8177e393ac52a0f64e56b0b2b40bde03c1bdd6e0498f
|
|
| MD5 |
83d7b9ce06b9ab2440ee8701028c4e95
|
|
| BLAKE2b-256 |
c6967bc1b7056fe3c9e10d4b8f3a8e4cdc762787de376a83f0df2755b6990a0b
|