A tiny CLI that checks your
.envagainst.env.exampleand fails loudly when they drift apart. No dependencies, one job, done well.Маленький CLI, который сверяет твой
.envс.env.exampleи громко падает, когда они разошлись. Без зависимостей, одна задача — сделана хорошо.
You add SECRET_KEY to .env.example, deploy, and the app crashes because the server's .env never got it. Or a teammate pulls, copies the example, and misses a new variable. envguard catches this in one command — locally or in CI.
pip install git+https://github.com/dimaad5017-dotcom/envguard
# or, from a clone:
pip install -e .envguard # compares ./.env against ./.env.example
envguard -e .env.prod -x .env.exampleExample output when something is off:
Missing keys (in example, not in your .env):
- REDIS_URL
Empty values (set but blank):
- SECRET_KEY
Extra keys (in your .env, not in example):
- LEGACY_TOKEN
Exit codes:
| Code | Meaning |
|---|---|
0 |
everything matches |
1 |
mismatch found |
2 |
a file was not found |
| Flag | Description |
|---|---|
-e, --env |
path to the env file (default .env) |
-x, --example |
path to the example file (default .env.example) |
--allow-extra |
don't fail on keys that exist only in .env |
--allow-empty |
don't fail on keys with blank values |
--no-color |
plain output |
- run: pip install git+https://github.com/dimaad5017-dotcom/envguard
- run: envguard -e .env.ci -x .env.exampleA non-zero exit fails the job, so a forgotten variable blocks the merge instead of the deploy.
from envguard import parse_dotenv, check
example = parse_dotenv(open(".env.example").read())
actual = parse_dotenv(open(".env").read())
report = check(example, actual)
if not report.ok:
print(report.missing, report.empty, report.extra)Добавил переменную в .env.example, выкатил — а на сервере её нет, приложение падает. Или коллега скопировал пример и пропустил новую переменную. envguard ловит это одной командой: локально или в CI. Ненулевой код выхода роняет пайплайн до деплоя, а не после.