Environment variable management with annotation-based wizards
Krakenv is a CLI tool for managing environment variable files (.env) with an annotation-based configuration wizard system. It transforms the tedious process of configuring environment files into a guided, validated experience.
- Interactive Wizard: Guided configuration with type validation and constraints
- Annotation System: Define prompts, types, and validation rules inline in your
.env.dist - Multi-Environment Support: Generate
.env.local,.env.testing,.env.productionfrom a single template - Validation: Type checking (int, string, enum, boolean, object) with constraints (min, max, pattern, etc.)
- Inspection: Compare distributable and environment files, sync discrepancies
- CI/CD Ready: Non-interactive mode with exit codes for pipeline integration
- Google Cloud Secret Manager: Fetch secret values automatically from GCP Secret Manager
- Cross-Platform: Runs on Linux, macOS, and Windows
curl -sSL https://raw.githubusercontent.com/theburrowhub/krakenv/main/install.sh | bashbrew install theburrowhub/tap/krakenvgo install github.com/theburrowhub/krakenv/cmd/krakenv@latestDownload pre-built binaries from the Releases page.
Create a .env.dist file with annotations:
#krakenv:environments=local,testing,production
# Database Configuration
DB_HOST=localhost #prompt:Database host?|string
DB_PORT=5432 #prompt:Database port?|int;min:1;max:65535
DB_NAME= #prompt:Database name?|string;minlen:1
DB_PASSWORD= #prompt:Database password?|string;secret
# Application Settings
APP_ENV=development #prompt:Environment?|enum;options:development,staging,production
DEBUG=true #prompt:Enable debug mode?|boolean;optional
WORKERS=4 #prompt:Number of workers?|int;min:1;max:16krakenv generate .env.localThe wizard will prompt you for each undefined or invalid variable.
krakenv validate .env.localkrakenv inspect .env.localVARIABLE=default #prompt:Question?|type;constraint:value;modifier
| Type | Description | Example |
|---|---|---|
string |
Text value | #prompt:Name?|string;minlen:1;maxlen:100 |
int |
Integer | #prompt:Port?|int;min:1;max:65535 |
numeric |
Float/decimal | #prompt:Rate?|numeric;min:0;max:1 |
boolean |
true/false | #prompt:Enable?|boolean |
enum |
One of options | #prompt:Env?|enum;options:dev,staging,prod |
object |
JSON/YAML | #prompt:Config?|object;format:json |
| Constraint | Applies To | Description |
|---|---|---|
min |
int, numeric | Minimum value |
max |
int, numeric | Maximum value |
minlen |
string | Minimum length |
maxlen |
string | Maximum length |
pattern |
string | Regex pattern |
options |
enum | Allowed values |
format |
object | json or yaml |
gcp-secret |
any | Fetch value from GCP Secret Manager |
| Modifier | Description |
|---|---|
optional |
Variable can be empty |
secret |
Hide input in wizard |
krakenv generate <target> # Generate environment file from distributable
krakenv validate <target> # Validate environment file against annotations
krakenv inspect <target> # Compare distributable and environment files
krakenv add <name> # Add new annotated variable to distributable
krakenv init # Initialize new distributable with wizard
krakenv version # Show version information| Flag | Description |
|---|---|
--dist, -d |
Path to distributable file (default: .env.dist) |
--non-interactive, -n |
Disable TUI; fail on unresolved variables |
--quiet, -q |
Suppress non-error output |
--verbose, -v |
Enable detailed output |
Krakenv can automatically fetch secret values from GCP Secret Manager, eliminating the need to manually enter sensitive values during generation.
The .env.dist is the single source of truth. Each gcp-secret variable
declares its project, name, and version as explicit, named fields β no flags or
environment variables are needed. A single template can pull secrets from
different GCP projects.
| Field | Required | Description |
|---|---|---|
gcp-secret |
yes | Modifier β marks the variable as GCP-sourced |
gcp-secret-project:PROJECT |
yes | GCP project ID |
gcp-secret-name:NAME |
yes | Secret name in Secret Manager |
gcp-secret-version:VERSION |
no | Version number (default: latest) |
Version accepts both numeric (3) and v-prefixed (v3) notation.
#krakenv:environments=local,production
# Secrets from different GCP projects β each annotation is self-contained
API_KEY= #prompt:API Key?|string;secret;gcp-secret;gcp-secret-project:payments-project;gcp-secret-name:stripe-key;gcp-secret-version:v2
DB_PASSWORD= #prompt:DB Password?|string;secret;gcp-secret;gcp-secret-project:infra-project;gcp-secret-name:db-password
JWT_SECRET= #prompt:JWT Secret?|string;secret;gcp-secret;gcp-secret-project:auth-project;gcp-secret-name:jwt-secret;gcp-secret-version:3# No flags needed β all information is in the .env.dist
krakenv generate .env.local
# Works in non-interactive mode (fully automated CI/CD)
krakenv generate .env.production --non-interactive
# Verbose output shows how many secrets were resolved
krakenv generate .env.local --verboseKrakenv uses Application Default Credentials (ADC). Configure one of:
| Method | Command |
|---|---|
| gcloud CLI | gcloud auth application-default login |
| Service account key | export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json |
| GCP-hosted environment | Automatic (GCE, Cloud Run, GKE, etc.) |
# GitHub Actions with Workload Identity Federation
- name: Authenticate to GCP
uses: google-github-actions/auth@v2
with:
workload_identity_provider: 'projects/123/locations/global/workloadIdentityPools/...'
service_account: 'krakenv@my-project.iam.gserviceaccount.com'
- name: Generate environment
run: krakenv generate .env.production --non-interactiveThe authenticated principal needs roles/secretmanager.secretAccessor on each secret.
gcloud secrets add-iam-policy-binding my-api-key \
--project my-project \
--member="serviceAccount:krakenv@my-project.iam.gserviceaccount.com" \
--role="roles/secretmanager.secretAccessor"#!/bin/bash
krakenv validate .env.local --non-interactive || exit 1- name: Validate environment
run: krakenv validate .env.production --non-interactiveenv-setup:
krakenv generate .env.local
env-validate:
krakenv validate .env.local --non-interactive# Clone repository
git clone https://github.com/theburrowhub/krakenv.git
cd krakenv
# Install dependencies
make deps
# Run tests
make test
# Build binary
make build
# Run linter
make lint
# Run all checks
make checkMIT License - see LICENSE for details.
Contributions are welcome! Please read our contributing guidelines before submitting a PR.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Built with π by The Burrow Hub
Crafting effective solutions for developers who deserve better tools
