universal/infrastructure/env-manager/SKILL.md
Environment variable validation, security scanning, and management for Next.js, Vite, React, and Node.js applications
npx skillsauth add bobmatnyc/claude-mpm-skills env-managerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Comprehensive environment variable validation, security scanning, and management for modern web applications.
The env-manager skill provides systematic environment variable management across local development, CI/CD pipelines, and deployment platforms. It prevents common issues like missing variables, exposed secrets, and framework-specific configuration errors.
Key Features:
Common problems this solves:
No installation needed! env-manager is a bundled skill in Claude MPM.
Requirements:
# 1. Validate your .env file
python3 scripts/validate_env.py .env
# 2. Check for framework-specific issues (Next.js example)
python3 scripts/validate_env.py .env --framework nextjs
# 3. Compare with .env.example to find missing vars
python3 scripts/validate_env.py .env --compare-with .env.example
# 4. Generate .env.example for documentation
python3 scripts/validate_env.py .env --generate-example .env.example
# 5. Get JSON output for CI/CD integration
python3 scripts/validate_env.py .env --json
That's it! Environment variables are now validated professionally.
Validate a .env file for structural issues:
python3 scripts/validate_env.py .env
What it checks:
Example output:
✅ Validation successful!
- 15 variables validated
- 0 errors
- 0 warnings
Validate Next.js environment variables:
python3 scripts/validate_env.py .env.local --framework nextjs
Next.js-specific checks:
Example:
# .env.local
NEXT_PUBLIC_API_URL=https://api.example.com
NEXT_PUBLIC_API_KEY=secret123 # ⚠️ WARNING: Secret in client-exposed variable!
DATABASE_URL=postgresql://... # ✅ Server-side only
python3 scripts/validate_env.py .env --framework vite
Vite-specific checks:
python3 scripts/validate_env.py .env --framework react
React-specific checks:
python3 scripts/validate_env.py .env --framework nodejs
Node.js-specific checks:
python3 scripts/validate_env.py .env --framework flask
Flask-specific checks:
Ensure your .env has all required variables:
python3 scripts/validate_env.py .env --compare-with .env.example
What it checks:
Example output:
❌ Missing variables:
- DATABASE_URL (required in .env.example)
- STRIPE_SECRET_KEY (required in .env.example)
⚠️ Extra variables not in .env.example:
- DEBUG_MODE (consider adding to .env.example)
Perfect for:
Create documentation for your environment variables:
python3 scripts/validate_env.py .env --generate-example .env.example
What it does:
Example:
# Input: .env
DATABASE_URL=postgresql://user:pass@localhost/db # pragma: allowlist secret
STRIPE_SECRET_KEY=sk_live_abc123xyz
NEXT_PUBLIC_API_URL=https://api.example.com
# Output: .env.example
DATABASE_URL=postgresql://user:password@localhost/dbname # pragma: allowlist secret
STRIPE_SECRET_KEY=your_stripe_secret_key_here
NEXT_PUBLIC_API_URL=https://api.example.com
Security note: env-manager detects common secret patterns and replaces them with safe placeholders.
Get machine-readable JSON output for automated workflows:
python3 scripts/validate_env.py .env.example --strict --json
JSON output format:
{
"valid": true,
"errors": [],
"warnings": [],
"stats": {
"total_vars": 15,
"errors": 0,
"warnings": 0
}
}
Exit codes:
0: Validation passed1: Validation errors found2: Missing required file3: Warnings found (only in --strict mode)GitHub Actions example:
name: Validate Environment Variables
on: [push, pull_request]
jobs:
validate-env:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Validate .env.example
run: |
python3 scripts/validate_env.py .env.example --strict --json
working-directory: ./path/to/skill
- name: Check for framework-specific issues
run: |
python3 scripts/validate_env.py .env.example --framework nextjs --json
working-directory: ./path/to/skill
Treat warnings as errors (useful for CI/CD):
python3 scripts/validate_env.py .env --strict
When to use:
Show only errors, suppress warnings:
python3 scripts/validate_env.py .env --quiet
When to use:
| Framework | Prefix | Client-Exposed | Notes |
|-----------|--------|----------------|-------|
| Next.js | NEXT_PUBLIC_* | Yes | Auto-exposed in browser |
| Vite | VITE_* | Yes | Bundled into client code |
| React (CRA) | REACT_APP_* | Yes | Embedded in production build |
| Node.js | N/A | No | Server-side only |
| Flask | N/A | No | Server-side only |
Security warning: Never put secrets in client-exposed variables (NEXT_PUBLIC_, VITE_, REACT_APP_). env-manager will warn you if it detects common secret patterns.
python3 scripts/validate_env.py <file> [options]
| Option | Description | Example |
|--------|-------------|---------|
| --compare-with FILE | Compare with .env.example | --compare-with .env.example |
| --framework {nextjs\|vite\|react\|nodejs\|flask\|generic} | Framework-specific validation | --framework nextjs |
| --strict | Treat warnings as errors | --strict |
| --json | JSON output for automation | --json |
| --quiet | Only show errors | --quiet |
| --generate-example OUTPUT | Generate .env.example | --generate-example .env.example |
| Code | Meaning | When |
|------|---------|------|
| 0 | Success | No errors (warnings OK unless --strict) |
| 1 | Validation errors | Structural issues, duplicates, etc. |
| 2 | File not found | Specified .env file doesn't exist |
| 3 | Warnings in strict mode | Warnings exist and --strict enabled |
# New developer clones repo
git clone <repo>
cd <project>
# Copy example and fill in values
cp .env.example .env
# Edit .env with actual values...
# Validate setup
python3 scripts/validate_env.py .env --compare-with .env.example
# If missing variables, fix them
# Validation passes ✅
# Before deploying to Vercel/Railway/Heroku
python3 scripts/validate_env.py .env.production --framework nextjs --strict
# Fix any errors
# Deploy with confidence ✅
# Check for accidentally exposed secrets
python3 scripts/validate_env.py .env.local --framework nextjs
# Look for warnings like:
# ⚠️ NEXT_PUBLIC_STRIPE_SECRET: Contains potential secret in client-exposed variable
# After adding new environment variable
echo "NEW_API_KEY=abc123" >> .env
# Regenerate .env.example
python3 scripts/validate_env.py .env --generate-example .env.example
# Commit updated .env.example
git add .env.example
git commit -m "docs: add NEW_API_KEY to environment variables"
# In your CI pipeline
- name: Validate environment configuration
run: |
python3 scripts/validate_env.py .env.example --strict --json > validation.json
# Fail pipeline if validation fails
if [ $? -ne 0 ]; then
cat validation.json
exit 1
fi
env-manager is designed for speed:
Benchmarks:
Why it matters:
Critical security features:
Security-audited: This skill has undergone security review. See references/security.md for details.
Best practices:
Cause: Line in .env doesn't have = separator
Fix:
# ❌ Bad
API_KEY
# ✅ Good
API_KEY=your_key_here
Cause: Same variable defined multiple times
Fix:
# ❌ Bad
API_KEY=value1
API_KEY=value2
# ✅ Good
API_KEY=value2
Cause: Variable name doesn't follow UPPERCASE_WITH_UNDERSCORES convention
Fix:
# ❌ Bad
apiKey=value
api-key=value
# ✅ Good
API_KEY=value
Cause: NEXT_PUBLIC_, VITE_, or REACT_APP_ variable contains secret-like value
Fix:
# ❌ Bad (secret exposed to client!)
NEXT_PUBLIC_STRIPE_SECRET=sk_live_abc123
# ✅ Good (server-side only)
STRIPE_SECRET_KEY=sk_live_abc123
NEXT_PUBLIC_STRIPE_PUBLISHABLE=pk_live_xyz789
Cause: Variable has no value
Fix:
# ❌ Bad
DATABASE_URL=
# ✅ Good (if optional, document it)
DATABASE_URL= # Optional, uses SQLite if not set
# ✅ Better
DATABASE_URL=postgresql://localhost/mydb
Cause: Specified .env file doesn't exist
Fix:
# Check file exists
ls -la .env
# Or create it
touch .env
Check:
This is intentional! env-manager is warning you that variables like NEXT_PUBLIC_API_KEY will be visible in the browser.
Options:
env-manager is conservative about secrets. If it over-sanitizes:
See references/validation.md for advanced validation patterns.
See references/synchronization.md for Vercel, Railway, Heroku integration patterns.
See references/frameworks.md for comprehensive framework guides.
env-manager is a bundled skill in Claude MPM. Agents can use it for:
See INTEGRATION.md for agent integration patterns.
env-manager follows Claude MPM contribution guidelines:
make lint-fix during developmentmake quality before commitsSee CONTRIBUTING.md for details.
MIT License - Part of Claude MPM project
Version: 1.0.0 Status: Stable, Security-Audited Test Coverage: 85%+ Performance: 80x faster than target
development
Optimize web performance using Core Web Vitals, modern patterns (View Transitions, Speculation Rules), and framework-specific techniques
development
Best practices for documenting APIs and code interfaces, eliminating redundant documentation guidance per agent.
development
Comprehensive API design patterns covering REST, GraphQL, gRPC, versioning, authentication, and modern API best practices
development
Visual verification workflow for UI changes to accelerate code review and catch ...