Skip to main content

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:

  • 0 when every target file passes
  • 1 when drift is found
  • 2 when 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=value
  • export 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.

Metadata

Release files for env-drift-report 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for env-drift-report 0.2.0
File Size Uploaded Provenance Actions
env_drift_report-0.2.0.tar.gz 9.9 kB Without provenance Details for env_drift_report-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for env-drift-report 0.2.0
File Interpreter ABI Platform Actions
env_drift_report-0.2.0-py3-none-any.whl Python 3 none any Details for env_drift_report-0.2.0-py3-none-any.whl

Total release size: 18.3 kB

Release files / env_drift_report-0.2.0.tar.gz

Download URL env_drift_report-0.2.0.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bfe5152c01c199d66fa99bbe30886fcc4ddfc5d0b3a3c2ba925d36f9f359731d
BLAKE2b-256 checksum
How to use checksums
b4bbdf34f58eb107852b9334d7f6a6e8a50eafa55870ae3d7f844e71ff3fbf3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release files / env_drift_report-0.2.0-py3-none-any.whl

Download URL env_drift_report-0.2.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9dc368ca28d8df764e5e8177e393ac52a0f64e56b0b2b40bde03c1bdd6e0498f
BLAKE2b-256 checksum
How to use checksums
c6967bc1b7056fe3c9e10d4b8f3a8e4cdc762787de376a83f0df2755b6990a0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Security for env-drift-report 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page