From hopeoverture-worldbuilding-app-skills
Validates .env files across environments, checks variable scoping (public vs. private), detects security issues, and ensures required secrets, database URLs, and API keys are set.
How this skill is triggered — by the user, by Claude, or both
Slash command
/hopeoverture-worldbuilding-app-skills:env-config-validatorThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Validate `.env` files across local, staging, and production environments. Ensure all required secrets, database URLs, API keys, and public variables are properly scoped, set, and secure.
Validate .env files across local, staging, and production environments. Ensure all required secrets, database URLs, API keys, and public variables are properly scoped, set, and secure.
To validate environment configuration:
.env, .env.local, .env.production, etc.scripts/validate_env.py for automated validationEnsure proper scoping of environment variables:
NEXT_PUBLIC_*): Accessible in browserCompare configurations across environments:
Detect security vulnerabilities in environment configuration:
Ensure these categories of variables are present:
Database Connection
DATABASE_URL or equivalentAuthentication
JWT_SECRET or AUTH_SECRETExternal APIs
Application Config
NODE_ENVNEXT_PUBLIC_APP_URL or APP_URLEmail/Notifications (if used)
Follow Next.js environment variable conventions:
Public variables: NEXT_PUBLIC_* prefix
NEXT_PUBLIC_API_URLPrivate variables: No prefix
DATABASE_URL, API_SECRETNaming style: SCREAMING_SNAKE_CASE
DATABASE_URL, JWT_SECRET, STRIPE_API_KEYNever expose secrets in public variables
NEXT_PUBLIC_DATABASE_URLDATABASE_URLDatabase URLs must be private
NEXT_PUBLIC_DB_URLDATABASE_URLAPI keys scoping
NEXT_PUBLIC_* (e.g., Google Maps)No hardcoded secrets in code
.env.local or .env.productionStrong secrets
Use scripts/validate_env.py to automate validation:
# Validate current .env file
python scripts/validate_env.py
# Validate specific file
python scripts/validate_env.py --file .env.production
# Compare multiple environments
python scripts/validate_env.py --compare .env.local .env.production
# Check against required variables template
python scripts/validate_env.py --template .env.example
The script checks:
Detection: Script reports missing required variable
Solution:
# Add to .env.production
DATABASE_URL="postgresql://user:password@host:5432/dbname"
Note: Use different databases for dev/staging/prod
Detection: Script finds NEXT_PUBLIC_ prefix on secret
Problem:
# [ERROR] WRONG - secret exposed to browser
NEXT_PUBLIC_API_SECRET="secret123"
Solution:
# [OK] CORRECT - server-side only
API_SECRET="secret123"
Detection: Script detects short or weak secret
Problem:
# [ERROR] WRONG - too short, predictable
JWT_SECRET="secret"
Solution:
# [OK] CORRECT - strong, random, 32+ characters
JWT_SECRET="a8f3d9c2e1b7f4a6d8c3e9b2f1a7d4c8e3b9f2a1d7c4e8b3f9a2d1c7e4b8f3a9"
Generate with:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
Detection: Script comparison shows name mismatch
Problem:
# .env.local
DATABASE_URL="..."
# .env.production
DB_URL="..." # [ERROR] Different name
Solution: Use consistent names
# Both files
DATABASE_URL="..."
Detection: Client-side code fails to connect to API
Problem: NEXT_PUBLIC_API_URL not set
Solution:
# .env.local
NEXT_PUBLIC_API_URL="http://localhost:3000"
# .env.production
NEXT_PUBLIC_API_URL="https://api.yourapp.com"
Python script to validate environment files, check for security issues, compare across environments, and verify against templates. Provides detailed error messages and suggestions.
Comprehensive guide to environment variable management including:
Template showing all required environment variables for a worldbuilding application. Use as a reference for setting up new environments or auditing existing ones.
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/worldbuilding_dev"
# Authentication
JWT_SECRET="dev-secret-change-in-production"
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="dev-nextauth-secret"
# Public
NEXT_PUBLIC_API_URL="http://localhost:3000"
NEXT_PUBLIC_APP_NAME="Worldbuilding App (Dev)"
# External APIs (test keys)
OPENAI_API_KEY="sk-test-..."
STRIPE_SECRET_KEY="sk_test_..."
# Database
DATABASE_URL="postgresql://user:[email protected]:5432/worldbuilding_staging"
# Authentication
JWT_SECRET="staging-secret-32-chars-minimum"
NEXTAUTH_URL="https://staging.yourapp.com"
NEXTAUTH_SECRET="staging-nextauth-secret"
# Public
NEXT_PUBLIC_API_URL="https://staging.yourapp.com"
NEXT_PUBLIC_APP_NAME="Worldbuilding App (Staging)"
# External APIs (test keys)
OPENAI_API_KEY="sk-test-..."
STRIPE_SECRET_KEY="sk_test_..."
# Database
DATABASE_URL="postgresql://user:[email protected]:5432/worldbuilding_prod"
# Authentication
JWT_SECRET="production-secret-use-crypto-random-32-chars-minimum"
NEXTAUTH_URL="https://yourapp.com"
NEXTAUTH_SECRET="production-nextauth-secret"
# Public
NEXT_PUBLIC_API_URL="https://api.yourapp.com"
NEXT_PUBLIC_APP_NAME="Worldbuilding App"
# External APIs (production keys)
OPENAI_API_KEY="sk-live-..."
STRIPE_SECRET_KEY="sk_live_..."
# Monitoring
SENTRY_DSN="https://..."
Never commit secrets
.env.local, .env.production to .gitignore.env.example as a templateUse strong, random secrets
crypto.randomBytes() or password managerScope variables correctly
NEXT_PUBLIC_*): Only non-sensitive, client-accessible dataConsistent naming
SCREAMING_SNAKE_CASE conventionEnvironment-specific values
Document required variables
.env.example updatedValidate on deployment
Rotate secrets regularly
Use secret management tools
Test environment parity
Common environment variables for worldbuilding applications:
DATABASE_URL="postgresql://..."
DATABASE_POOL_SIZE="10" # Optional
JWT_SECRET="..."
NEXTAUTH_URL="..."
NEXTAUTH_SECRET="..."
# AI services (optional)
OPENAI_API_KEY="..."
# Maps (if using)
NEXT_PUBLIC_GOOGLE_MAPS_API_KEY="..."
# Image hosting (if using)
CLOUDINARY_URL="..."
NODE_ENV="production"
NEXT_PUBLIC_APP_URL="https://..."
NEXT_PUBLIC_APP_NAME="Worldbuilding App"
SMTP_HOST="..."
SMTP_PORT="587"
SMTP_USER="..."
SMTP_PASSWORD="..."
Consult references/env_best_practices.md for detailed guidance and assets/.env.example for a complete template.
Guides completion of development work by verifying tests, detecting environment, and presenting structured options for merge, PR, or cleanup.
Enforces test-driven development: write failing test first, then minimal code to pass. Use when implementing features or bugfixes.
Guides creation and editing of skills using test-driven development with pressure scenarios and subagents to verify agent compliance.
npx claudepluginhub hopeoverture/worldbuilding-app-skills