Skip to main content

Automatically generate documented .env.example files by scanning your codebase.

Project description

dotguard

Auto-generate documented .env.example files from your codebase.

Auto-generate documented .env.example files from your codebase.

Ever had a deploy fail because someone added os.getenv("NEW_VAR") but forgot .env.example? dotguard fixes that - automatically.

dotguard scans your codebase and automatically generates a fully documented .env.example - grouped, commented, and ready to commit.

Features

  • โšก Zero dependencies โ€” pure Python (installs in ~1s)
  • ๐ŸŒ Language agnostic โ€” Python, JS, TS, shell, YAML, TOML
  • ๐Ÿง  Smart grouping โ€” auto-groups variables by prefix
  • ๐Ÿ” Secret detection โ€” flags _KEY, _SECRET, _PASSWORD, _TOKEN
  • ๐Ÿค– CI-ready โ€” --check fails if .env.example is outdated

Demo

dotguard in action

Install

pip install dotguard-scan

Usage

dotguard scan                    # scan current directory โ†’ .env.example
dotguard scan ./backend          # scan specific folder
dotguard scan --output prod.env  # custom output filename
dotguard scan --check            # CI mode: exit 1 if undocumented vars found
dotguard diff                    # compare .env vs .env.example, show missing keys
dotguard audit                   # show all vars, which files use them, flag secrets

Quick Demo

๐Ÿ” Scanning ./myproject...

  โœ” 23 files scanned
  โœ” 11 environment variables found
  โš   3 secrets detected (SECRET_KEY, DB_PASSWORD, AUTH_TOKEN)
  โœ” .env.example written

  Variables by group:
  DATABASE  โ–ˆโ–ˆโ–ˆโ–ˆ  3 vars
  SMTP      โ–ˆโ–ˆ    2 vars
  APP       โ–ˆโ–ˆโ–ˆโ–ˆ  4 vars
  SECRETS   โ–ˆโ–ˆโ–ˆ   3 vars  โš 

Generated Output

dotguard produces a clean, grouped .env.example with comments showing where each variable is used:

# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
# SECRETS  โš ๏ธ  Never commit real values
# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

# Used in: config.py:4
SECRET_KEY=your-secret-here

# Used in: auth.py:9
AUTH_TOKEN=your-secret-here


# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
# DATABASE
# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

# Used in: db.py:12, config.py:3
DATABASE_URL=postgresql://user:password@localhost:5432/dbname

# Used in: cache.py:8
REDIS_HOST=localhost


# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
# APP
# โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

# Used in: settings.py:3
DEBUG=true

CI Integration

Add dotguard scan --check to your CI pipeline. It exits with code 1 if any environment variable in your code is missing from .env.example:

# GitHub Actions example
- name: Check env docs
  run: dotguard scan --check

Supported Patterns

Pattern Language
os.getenv("KEY") Python
os.environ["KEY"] Python
os.environ.get("KEY") Python
process.env.KEY JavaScript
$KEY / ${KEY} Shell
getenv("KEY") Generic

License

Licensed under The MIT License.

โญ Support & Contributing

If you find this project useful, consider:

  • โญ Starring the repository
  • ๐Ÿ‘ค Following me for more projects
  • ๐Ÿ› ๏ธ Contributing to improve the tool

Contributions are always welcome! Feel free to open issues or submit pull requests.

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

dotguard_scan-0.1.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

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

dotguard_scan-0.1.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file dotguard_scan-0.1.0.tar.gz.

File metadata

  • Download URL: dotguard_scan-0.1.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for dotguard_scan-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c2c01f8aaf32cefd12d0094fdcf411dd6507f3b4cd91fe8e49682ab22533d530
MD5 38cadb10835bf6bf43a76faa8d65905a
BLAKE2b-256 56294d43708aaa961b34f19b44b0482af29a49e4fcc0e1694f85062d16ec178b

See more details on using hashes here.

File details

Details for the file dotguard_scan-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dotguard_scan-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for dotguard_scan-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a9175417f33e7e9bc6c8e814398e888586952c6275116a325e8abeda392c4549
MD5 5e3f36de98efaf445d7467c734b2be66
BLAKE2b-256 c3fe465621d6e1172ab3ebaf9d5095fe2fd836242eb4356d5ba2a6c56d2c44a5

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