Prevent environment variable drift with Pydantic schema validation, pre-commit hooks, and dotenvx encryption
Project description
envdrift
Prevent environment variable drift between dev, staging, and production.
🚧 Under Active Development - Core features coming in v0.1.0
The Problem
Environment variable drift is a silent killer of deployments:
- A missing
DATABASE_URLin production causes a 3am outage - Staging has
NEW_FEATURE_FLAG=truebut production doesn't - Someone copies the wrong
.envfile and chaos ensues - "It works on my machine!" becomes your team's motto
In 2024 alone, 24 million secrets were leaked on GitHub. Knight Capital lost $460 million in 45 minutes due to a configuration deployment error.
The Solution
envdrift treats your environment variables with the same rigor as your code:
- Schema Validation: Define expected variables with Pydantic, catch mismatches at startup
- Drift Detection: Compare
.env.devvs.env.prodand see exactly what differs - Pre-commit Hooks: Block commits if your
.envdoesn't match your schema - CI/CD Integration: Fail fast in pipelines before bad config reaches production
- Encryption Support: Works with dotenvx for secure, committable
.envfiles
Installation
pip install envdrift
# or
uv add envdrift
Quick Start
Validate your .env against a schema
envdrift validate .env --schema myapp.config:Settings
Compare environments
envdrift diff .env.dev .env.prod
Generate a Settings class from existing .env
envdrift init .env --output settings.py
Install pre-commit hook
envdrift hook --install
Planned Features (v0.1.0)
-
envdrift validate- Validate .env against Pydantic schema -
envdrift diff- Compare two .env files -
envdrift init- Generate Settings class from .env -
envdrift hook- Pre-commit hook integration - Rich terminal output with clear error messages
- dotenvx encryption detection and support
- CI mode with proper exit codes
Why envdrift?
| Feature | python-dotenv | dynaconf | pydantic-settings | envdrift |
|---|---|---|---|---|
| Load .env | ✅ | ✅ | ✅ | ✅ |
| Type validation | ❌ | ⚠️ | ✅ | ✅ |
| Schema enforcement | ❌ | ⚠️ | ✅ | ✅ |
| Cross-env diff | ❌ | ❌ | ❌ | ✅ |
| Pre-commit hook | ❌ | ❌ | ❌ | ✅ |
| Encryption support | ❌ | ❌ | ❌ | ✅ |
Development
# Clone the repo
git clone https://github.com/jainal09/envdrift.git
cd envdrift
# Install dev dependencies
make dev
# Run checks
make check
License
MIT License - see LICENSE for details.
Author
Jainal Gosaliya - gosaliya.jainal@gmail.com
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 envdrift-0.0.1.tar.gz.
File metadata
- Download URL: envdrift-0.0.1.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e974a00952e4de3b5905dffbb70aaf679168bebe069968e866a80476d5e6470f
|
|
| MD5 |
b86d7566d9a454600221bf31d48c6e8a
|
|
| BLAKE2b-256 |
f0f285ee7356b37b58755731674a2b9a7774c4229253884ee9e9907595afb2de
|
File details
Details for the file envdrift-0.0.1-py3-none-any.whl.
File metadata
- Download URL: envdrift-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1f327028969d37f45355b5a7db86059c15ea5dd7398c9aca78ec80a67016363
|
|
| MD5 |
2016c7af69c59409501821115f942e9f
|
|
| BLAKE2b-256 |
e4e51faeae012d168083efe3a2c52def99065a79beffd67a08bc8a7def3a432b
|