Validate .env files against .env.example — catch missing variables before they crash production
Project description
dotenvguard
Validate .env files against .env.example — catch missing variables before they crash production.
$ dotenvguard check .
dotenvguard
┏━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Variable ┃ Status ┃ Default ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ DATABASE_URL │ ok │ postgres://localhost:5432/mydb │
│ API_KEY │ ok │ │
│ SECRET_TOKEN │ empty │ │
│ REDIS_URL │ MISSING │ redis://localhost:6379 │
│ STRIPE_KEY │ MISSING │ │
└──────────────┴─────────┴────────────────────────────────┘
2 missing variables out of 5 required
Install
# pip
pip install dotenvguard
# uv (recommended)
uv tool install dotenvguard
# pipx
pipx install dotenvguard
Usage
# Check current directory (auto-detects .env and .env.example)
dotenvguard check
# Check a specific directory
dotenvguard check /path/to/project
# Use custom file paths
dotenvguard check --env .env.local --example .env.example
# Show extra variables not in .env.example
dotenvguard check --extra
# JSON output for CI/scripts
dotenvguard check --json
# Don't warn about empty values
dotenvguard check --no-empty-warning
CI Integration
dotenvguard exits with code 1 when variables are missing — drop it into any CI pipeline:
# GitHub Actions
- name: Validate environment
run: pip install dotenvguard && dotenvguard check
Pre-commit Hook
# .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: dotenvguard
name: dotenvguard
entry: dotenvguard check
language: python
additional_dependencies: [dotenvguard]
pass_filenames: false
What it Checks
| Status | Meaning |
|---|---|
ok |
Variable exists in .env with a value |
MISSING |
Variable in .env.example but not in .env |
empty |
Variable exists in .env but has no value |
extra |
Variable in .env but not in .env.example |
Supported .env Formats
# Standard key=value
DATABASE_URL=postgres://localhost/db
# Quoted values (single or double)
SECRET="value with spaces"
# Export prefix
export API_KEY=sk-1234
# Inline comments (outside quotes)
DEBUG=true # enable debug mode
# Values with equals signs
CONNECTION_STRING=postgres://user:pass@host/db?sslmode=require
Why dotenvguard?
Every project with a .env file has this problem: someone adds a new environment variable, updates .env.example, and forgets to tell the team. The next deploy crashes with a cryptic KeyError or connects to the wrong database.
Existing solutions are either too heavy (full config management) or too manual (eyeballing the diff). dotenvguard is one command that answers one question: does my .env have everything it needs?
License
MIT
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 dotenvguard-0.1.0.tar.gz.
File metadata
- Download URL: dotenvguard-0.1.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c2b99b75e9b9d12754e0fb0e98560c724c353d14279894ef82a540879ed3949
|
|
| MD5 |
43760b2c404d3e4476ac1965134e3aeb
|
|
| BLAKE2b-256 |
ddc391cf8d089fdb51a1c94c39b46ddf45da02b50ffa479edd0602682d714867
|
File details
Details for the file dotenvguard-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dotenvguard-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f17866bf7f82ca981f8beb780ee5529c73ec41673aca6be0d0a990cf445dad3
|
|
| MD5 |
4a1ec4c81d4994106ba7efef983ba83f
|
|
| BLAKE2b-256 |
54c8512acde750ccacfc783ded447e032d5ba231e656bc02afbadf081983c192
|