Skip to main content

Secure, centralized environment variable management for AI coding era - SOPS + age encryption for multi-project .env files

Project description

๐Ÿ” EnvSeal

Secure, centralized environment variable management for the AI coding era

Python Version PyPI License Code style: ruff

English | ไธญๆ–‡


๐Ÿค– Why EnvSeal for AI Coding?

The reality of AI-powered development: project explosion

Working with Claude Code, Cursor, Gemini CLI, or Windsurf? You know the drill:

  • ๐Ÿš€ Today: 3 new demos
  • ๐ŸŽฏ Tomorrow: 5 more repos
  • ๐Ÿ“‚ Each one: .env, .env.dev, .env.prod

Then what happens?

  • ๐Ÿ’” Migration Pain: Switching machines? The hardest part isn't codeโ€”it's "where are all those .env files?"
  • ๐Ÿ”€ Sync Chaos: Updated DATABASE_URL in project A, forgot about project B
  • โš ๏ธ Leakage Risk: AI screenshots, logs, and shares easily expose secrets
  • ๐Ÿšซ Onboarding Nightmare: New developer clones in 30 seconds, spends 3 hours hunting for credentials

EnvSeal's Solution:

Scan repos โ†’ Normalize .env โ†’ Encrypt with SOPS โ†’ Unified Git vault โ†’ One-command recovery

๐Ÿ“– What is EnvSeal?

EnvSeal is a CLI tool that helps you manage .env files across multiple repositories with end-to-end encryption. It scans your projects, normalizes environment files, and syncs them to a Git-backed vault using SOPS encryption.

Key Benefits:

  • ๐Ÿ”’ Secure: SOPS + age encryption (modern, battle-tested)
  • ๐Ÿ“ฆ Centralized: One vault for all secrets across unlimited projects
  • ๐Ÿ” Safe Diffs: Key-only diffs never expose values
  • ๐Ÿ”„ Version Control: Full Git history for audit and rollback
  • ๐Ÿš€ Simple: One command to sync everything
  • ๐Ÿ’ป Multi-Device: Restore entire dev environment in minutes

๐Ÿงญ Architecture at a Glance

graph LR
  Dev((Developer))
  CLI[EnvSeal CLI]
  Repos[[Projects<br/>.env* files]]
  Vault[(Private secrets-vault<br/>Git repo)]
  Dev -->|init / push / pull| CLI
  CLI -->|scan & normalize .env*| Repos
  CLI -->|encrypt via SOPS+age| Vault
  Vault -->|pull decrypt| CLI
  CLI -->|write .env to temp or project| Dev

๐ŸŽฏ Use Cases

  • ๐Ÿค– AI Coding / Vibe Coding: Using Claude Code/Cursor? Manage 10+ projects without env chaos
  • ๐Ÿ’ป Multi-Device Development: Work laptop โ†” Home desktop โ†” GitHub Codespaces
  • ๐Ÿ”„ Environment Migration: New machine? One command restores all project secrets
  • ๐Ÿ‘ฅ Team Collaboration: Share secrets securely via private vault (supports multiple age keys)
  • ๐Ÿ” Secret Rotation: Git history tracks "who changed what key and why"

โšก Quick Start

๐Ÿ“‹ Complete First-Time Setup (Beginner-Friendly)

Step 1: Create Your Secrets Vault Repository

  1. Go to GitHub and create a new private repository

    • Repository name suggestions: secrets-vault or my-secrets
    • โš ๏ธ Must be Private
    • Don't add README, .gitignore, etc. (create empty repo)
  2. Clone it locally:

    # Replace USERNAME with your GitHub username
    # Replace secrets-vault with your repository name
    cd ~/Github  # Or wherever you keep your code
    git clone git@github.com:USERNAME/secrets-vault.git
    

Step 2: Locate Your "Projects Root Directory"

This is the folder that contains all your projects, for example:

~/Github/                    โ† This is your "root directory"
โ”œโ”€โ”€ my-api/                 โ† Project 1 (has .env files)
โ”œโ”€โ”€ my-web/                 โ† Project 2 (has .env files)
โ”œโ”€โ”€ my-worker/              โ† Project 3 (has .env files)
โ””โ”€โ”€ secrets-vault/          โ† Your vault repo you just created

Step 3: Install and Initialize EnvSeal

Continue with the steps below ๐Ÿ‘‡

Prerequisites

# macOS
brew install age sops

# Verify installation
age-keygen --version
sops --version

Installation

# Install with pipx (recommended)
pipx install envseal-vault

# Or with pip
pip install envseal-vault

# Verify
envseal --version

Initialize

# Navigate to your "projects root directory" (the folder containing all your projects)
cd ~/Github  # Replace with your actual directory, e.g., ~/projects or ~/code

# Run initialization
envseal init

During initialization, it will:

  1. โœ… Generate an age encryption key
  2. ๐Ÿ” Scan current directory for all Git repositories (finds my-api, my-web, etc.)
  3. ๐Ÿ“ Create configuration at ~/.config/envseal/config.yaml
  4. ๐Ÿ—‚๏ธ Ask for your vault path (enter: ~/Github/secrets-vault)

Sync Secrets

# Push all .env files to vault (encrypted)
envseal push

# Commit to YOUR secrets vault (the private repo you created)
cd ~/Github/secrets-vault  # Your vault repo, NOT the envseal tool repo
git add .
git commit -m "Add encrypted secrets"
git push

Check Status

envseal status

Output:

๐Ÿ“Š Checking secrets status...

my-project
  โœ“ .env       - up to date
  โš  .env.prod  - 3 keys changed

api-service
  + .env       - new file (not in vault)
  โœ“ .env.prod  - up to date

Update Changed Secrets (Interactive)

# Interactively select and update changed secrets
envseal update

# Only show changes for specific environment
envseal update --env prod

The update command will:

  1. Scan all repositories for changed .env files
  2. Show an interactive selection menu
  3. Let you choose which repos to update
  4. Push selected changes to the vault
  5. Show next steps for git commit/push

๐Ÿ“š Commands

Command Description Options
envseal init Initialize configuration and generate keys --root DIR
envseal push [repos...] Encrypt and push secrets to vault --env ENV
envseal status Show sync status for all repos -
envseal update Interactively update changed secrets to vault --env ENV
envseal diff REPO Show key-only changes --env ENV
envseal pull REPO Decrypt and pull from vault --env ENV, --replace, --stdout

๐Ÿ”„ Push / Status Flow (Key-Only)

sequenceDiagram
  participant Dev
  participant CLI as EnvSeal CLI
  participant SOPS
  participant Vault as secrets-vault repo
  Dev->>CLI: envseal push
  CLI->>CLI: scan repos & map env files
  CLI->>SOPS: normalize .env* and encrypt (age)
  SOPS-->>CLI: encrypted files
  CLI->>Vault: write secrets/<repo>/<env>.env
  Dev->>Vault: git add/commit/push (manual)

๐Ÿš€ New Machine? Restore Everything in 10 Minutes

Just 4 steps:

  1. ๐Ÿ“‹ Copy age private key (from password manager)
  2. ๐Ÿ“ฆ Clone your secrets vault repository
  3. ๐Ÿ”ง Install EnvSeal: pipx install envseal-vault
  4. โฌ‡๏ธ Pull secrets: envseal pull <project> --env <environment> --replace

See detailed steps in the "Multi-Device Setup" section below ๐Ÿ‘‡

๐Ÿ” Security

Age Key Management:

  • Private key: ~/Library/Application Support/sops/age/keys.txt (macOS), ~/.config/sops/age/keys.txt (Linux), ~/AppData/Local/sops/age/keys.txt (Windows) (NEVER commit!)
  • Public key: Stored in vault/.sops.yaml (safe to commit)

Backup Your Private Key:

# Display full key file
cat ~/Library/Application\ Support/sops/age/keys.txt

# Save to password manager (1Password, Bitwarden, etc.)

Linux/Windows users: use the OS-specific key path listed in Age Key Management.

โš ๏ธ Critical: Losing your private key = permanent data loss!

Vault Repository Best Practices:

  • โœ… Keep vault repository private (even though files are encrypted)
  • โœ… Enable branch protection and require PR reviews
  • โœ… Use GitHub's secret scanning push protection
  • โœ… Backup private key in password manager

See SECURITY.md for complete security model.

๐ŸŒ Multi-Device Setup

Two repositories you need to know:

  • ๐Ÿ“ฆ EnvSeal tool: chicogong/envseal (this repo - install via PyPI, no need to clone)
  • ๐Ÿ” Your secrets vault: USERNAME/my-secrets-vault (your private repo for encrypted .env files)

On a new machine:

  1. Copy your age key from backup:

    mkdir -p ~/Library/Application\ Support/sops/age/
    nano ~/Library/Application\ Support/sops/age/keys.txt
    # Paste the 3-line key file (created, public key, private key)
    chmod 600 ~/Library/Application\ Support/sops/age/keys.txt
    

    Linux/Windows users: use the OS-specific key path listed in Security.

  2. Clone YOUR secrets vault and install EnvSeal tool:

    # Clone YOUR vault (NOT the envseal tool repo)
    git clone git@github.com:USERNAME/my-secrets-vault.git ~/Github/secrets-vault
    
    # Install EnvSeal tool from PyPI
    pipx install envseal-vault
    envseal init
    
  3. Pull secrets:

    envseal pull my-project --env prod --replace
    

๐Ÿ“ Configuration

Location: ~/.config/envseal/config.yaml

vault_path: /path/to/secrets-vault
repos:
  - name: my-api
    path: /Users/you/projects/my-api
  - name: web-app
    path: /Users/you/projects/web-app
env_mapping:
  ".env": "local"
  ".env.dev": "dev"
  ".env.prod": "prod"
  ".env.staging": "staging"
scan:
  include_patterns:
    - ".env"
    - ".env.*"
  exclude_patterns:
    - ".env.example"
    - ".env.sample"
  ignore_dirs:
    - ".git"
    - "node_modules"
    - "venv"

๐Ÿ› ๏ธ Development

Only for contributing to EnvSeal tool itself:

# Clone the EnvSeal TOOL repository (for development)
git clone https://github.com/chicogong/envseal.git
cd envseal

# Install with dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Lint and format
make lint
make format

# Type check
make type-check

Note: Regular users don't need to clone this repo - just pipx install envseal-vault

๐Ÿ“ Documentation

  • USAGE.en.md - Complete usage guide (English)
  • USAGE.md - ๅฎŒๆ•ดไฝฟ็”จๆŒ‡ๅ—๏ผˆไธญๆ–‡๏ผ‰
  • SECURITY.md - Security model and best practices
  • PUBLISHING.md - Guide for publishing to PyPI

๐Ÿค Contributing

Contributions welcome! Please feel free to submit a Pull Request.

๐Ÿ“„ License

Apache-2.0 License - see LICENSE for details.


Built for developers navigating the AI coding era

PyPI ยท Report Bug ยท Request Feature

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

envseal_vault-0.2.0.tar.gz (91.6 kB view details)

Uploaded Source

Built Distribution

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

envseal_vault-0.2.0-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: envseal_vault-0.2.0.tar.gz
  • Upload date:
  • Size: 91.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.9

File hashes

Hashes for envseal_vault-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d2d23639abac977b16ab24e833082d287085c7dde2e59c6732fb6262663762c2
MD5 d8ea7ab664d6abd15015bf4ad01b6d0c
BLAKE2b-256 ae65f8fd0d29c9fa19b6fcb0c3595a368c307b735ab3ce421b4a959c5ba85b13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for envseal_vault-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a9a12099de927028f7f696a5ee0d5439d9a4c5427bedfcfe96db04f48c71e428
MD5 5c78467c4f8eecfd98c7e3a40e066f74
BLAKE2b-256 2f80fc1ed842e042013f9d3e0864971e9d900fa62717e37f7e530a99ac6f7912

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