Skip to main content

Keep your .env files honest: catch drift, sync examples, find leaks. Zero dependencies.

Project description

envtidy

Keep your .env files honest — catch drift, sync examples, find leaks.

zero dependencies python license

Every team has lived this bug: someone adds REDIS_URL to their local .env, forgets to update .env.example, and the next person to clone the repo burns an hour debugging a crash that was really just a missing variable. Or worse — someone's staging.env was never gitignored and ships to GitHub with live credentials inside.

envtidy is a tiny CLI that catches both. Pure Python stdlib, zero dependencies, single-purpose.

envtidy demo

Install

pipx install git+https://github.com/nidhisebastian008/envtidy
# or
pip install git+https://github.com/nidhisebastian008/envtidy

Usage

envtidy check — catch drift

Compares .env against .env.example (also auto-detects .sample, .template, .dist):

$ envtidy check
envtidy check  .env vs .env.example
  missing  REDIS_URL  (in example, not in env)
  extra    DEBUG  (in env, not in example)
  empty    SMTP_HOST  (declared but has no value)

3 issues found (1 missing, 1 extra, 1 empty)

Exits 1 when drift is found, 0 when clean — drop it straight into CI or a pre-commit hook:

# .pre-commit-config.yaml
- repo: local
  hooks:
    - id: envtidy
      name: envtidy check
      entry: envtidy check
      language: system
      pass_filenames: false

envtidy sync — regenerate the example file

Rewrites .env.example from your real .env, stripping every value but preserving comments, blank lines, and key order:

$ envtidy sync
created .env.example (4 keys, values stripped)

Use --dry-run to preview without writing.

envtidy scan — find files that leaked (or are about to)

Walks a directory tree, finds every env file, and checks each one against git — including the full git history. Deleting a committed .env doesn't remove it; anyone with a clone can still recover it. scan catches that:

$ envtidy scan
envtidy scan  ~/code/myapp
  ignored  .env
  exposed  staging.env  (not in .gitignore — one `git add .` from leaking)
  TRACKED  api/.env.production  (committed to git — rotate these secrets)
  HISTORY  old/.env.local  (deleted, but still in git history — rotate + scrub)

3 files at risk
hint: scrub history with `git filter-repo --sensitive-data-removal --invert-paths --path <file>`
  • ignored — safely gitignored, never committed ✅
  • exposed — exists but not gitignored; one git add . away from a leak
  • TRACKED — committed right now; treat those secrets as compromised and rotate them
  • HISTORY — not in the working tree or index anymore, but recoverable from git history; rotate the secrets and scrub the history

Alternatives

Prior art exists — pick the right tool for your job:

  • dotenv-linter — fast Rust linter for .env style (duplicate keys, ordering, quoting), with a compare command for key diffs. No git awareness, no example generation.
  • sync-dotenv — Node tool doing what envtidy sync does.
  • gitleaks / trufflehog / detect-secrets — heavyweight content-level secret scanners with rules and entropy checks. Use them for full audits; use envtidy scan for the quick file-level answer to "are my env files safe in this repo?"

envtidy's niche: all three jobs (drift check, example sync, git-aware leak scan) in one zero-dependency CLI with no config.

Details

  • Understands export KEY=value, quoted values, inline # comments
  • Respects NO_COLOR; colors auto-disable when piped
  • Skips node_modules, .venv, .git, build dirs while scanning
  • Exit codes: 0 clean · 1 issues found · 2 usage error

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

envtidy-0.2.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

envtidy-0.2.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file envtidy-0.2.0.tar.gz.

File metadata

  • Download URL: envtidy-0.2.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for envtidy-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4e6f19c88d3c6547f18fc9d63adbdb5e9233a945b0d3a8bc4fd6da5d8519aff6
MD5 ac91ff49449c81e55dab211837114659
BLAKE2b-256 da76edcdb90ca0d632b8ed62a10aa05af13bf5c8784f926369445fb0308ecc42

See more details on using hashes here.

File details

Details for the file envtidy-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: envtidy-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for envtidy-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 51cc6a178d5ca43f9055ca4d3f6b6da44e7cc0c46834b8ab9b675b6565d5d450
MD5 0c639dfbefd744a375e7eb2262cfa9f8
BLAKE2b-256 8fc95bae47568b508564c015d6dbf2fb9c6f99923cbbf2d786c862f6b4791871

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page