Skip to main content

envexample-guard

Catch the classic "works on my machine" bug: someone added STRIPE_KEY to .env.example, but your .env never got it (or vice versa).

envexample-guard compares a .env file against its .env.example template and reports missing, extra, and empty keys. It has zero dependencies and returns non-zero exit codes, so it drops straight into CI or a pre-commit hook.

Install

pip install envexample-guard

Usage

envexample-guard                         # compares ./.env against ./.env.example
envexample-guard --env .env.local --example .env.template
envexample-guard --strict                # also fail on keys not in the example
envexample-guard --no-empty              # also fail on required keys with empty values
envexample-guard --json                  # machine-readable output
envexample-guard --write-example         # regenerate .env.example from .env (values stripped)

Example output:

✗ missing (in .env.example, not in .env): DATABASE_URL, STRIPE_KEY
! extra   (in .env, not in .env.example): OLD_FLAG

Exit codes

code meaning
0 in sync
1 drift detected (missing keys; extra keys with --strict; empty values with --no-empty)
2 a file could not be read

In CI (GitHub Actions)

- run: pip install envexample-guard
- run: envexample-guard --env .env.ci --example .env.example --strict

Python API

from envexample_guard import parse_dotenv, compare

report = compare(parse_dotenv(".env"), parse_dotenv(".env.example"))
print(report.missing, report.extra, report.empty)

Parsing rules

Supports KEY=value, export KEY=value, single/double quoted values (with \n escapes in double quotes), multi-line quoted values, inline # comments after unquoted values, blank lines and comment lines.

License

MIT

Metadata

Release files for envexample-guard 0.1.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 envexample-guard 0.1.0
File Size Uploaded Provenance Actions
envexample_guard-0.1.0.tar.gz 6.1 kB Without provenance Details for envexample_guard-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for envexample-guard 0.1.0
File Interpreter ABI Platform Actions
envexample_guard-0.1.0-py3-none-any.whl Python 3 none any Details for envexample_guard-0.1.0-py3-none-any.whl

Total release size: 12.6 kB

Release files / envexample_guard-0.1.0.tar.gz

Download URL envexample_guard-0.1.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b0b23a2ba200f9f80af4ec93ba4feff4863de9b0b7cfa6d8a2d309bd8fab961a
BLAKE2b-256 checksum
How to use checksums
6749aaf73fece5207e35b6fca46ddb5a94c1363706574e729cb0887594d37126
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / envexample_guard-0.1.0-py3-none-any.whl

Download URL envexample_guard-0.1.0-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c6a82e3bf5703e4cbe73740428a330bb9ae9dbf10b868d6f2db9ff692f2944fd
BLAKE2b-256 checksum
How to use checksums
74538e232361c460b192f1edcdd023146a62b70119a25385fbb6e583fb18514d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for envexample-guard 0.1.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.1.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