env-manager by bobmatnyc/claude-mpm-skills
npx skills add https://github.com/bobmatnyc/claude-mpm-skills --skill env-manager为现代 Web 应用程序提供全面的环境变量验证、安全扫描和管理。
env-manager 技能提供跨本地开发、CI/CD 流水线和部署平台的系统化环境变量管理。它能防止常见问题,如变量缺失、密钥泄露和特定框架的配置错误。
主要特性:
它解决的常见问题:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
无需安装!env-manager 是 Claude MPM 中的捆绑技能。
要求:
# 1. 验证你的 .env 文件
python3 scripts/validate_env.py .env
# 2. 检查框架特定问题(Next.js 示例)
python3 scripts/validate_env.py .env --framework nextjs
# 3. 与 .env.example 比较以查找缺失的变量
python3 scripts/validate_env.py .env --compare-with .env.example
# 4. 生成 .env.example 用于文档
python3 scripts/validate_env.py .env --generate-example .env.example
# 5. 获取 JSON 输出用于 CI/CD 集成
python3 scripts/validate_env.py .env --json
就这样!环境变量现已得到专业验证。
验证 .env 文件的结构问题:
python3 scripts/validate_env.py .env
它检查的内容:
示例输出:
✅ 验证成功!
- 已验证 15 个变量
- 0 个错误
- 0 个警告
验证 Next.js 环境变量:
python3 scripts/validate_env.py .env.local --framework nextjs
Next.js 特定检查:
示例:
# .env.local
NEXT_PUBLIC_API_URL=https://api.example.com
NEXT_PUBLIC_API_KEY=secret123 # ⚠️ 警告:客户端暴露变量中包含密钥!
DATABASE_URL=postgresql://... # ✅ 仅限服务器端
python3 scripts/validate_env.py .env --framework vite
Vite 特定检查:
python3 scripts/validate_env.py .env --framework react
React 特定检查:
python3 scripts/validate_env.py .env --framework nodejs
Node.js 特定检查:
python3 scripts/validate_env.py .env --framework flask
Flask 特定检查:
确保你的 .env 包含所有必需的变量:
python3 scripts/validate_env.py .env --compare-with .env.example
它检查的内容:
示例输出:
❌ 缺失的变量:
- DATABASE_URL (.env.example 中必需)
- STRIPE_SECRET_KEY (.env.example 中必需)
⚠️ .env.example 中不存在的额外变量:
- DEBUG_MODE (考虑添加到 .env.example)
非常适合:
为你的环境变量创建文档:
python3 scripts/validate_env.py .env --generate-example .env.example
它的功能:
示例:
# 输入: .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
# 输出: .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
安全说明: env-manager 检测常见的密钥模式并将其替换为安全的占位符。
获取机器可读的 JSON 输出以用于自动化工作流:
python3 scripts/validate_env.py .env.example --strict --json
JSON 输出格式:
{
"valid": true,
"errors": [],
"warnings": [],
"stats": {
"total_vars": 15,
"errors": 0,
"warnings": 0
}
}
退出码:
0: 验证通过1: 发现验证错误2: 缺少必需文件3: 发现警告(仅在 --strict 模式下)GitHub Actions 示例:
name: 验证环境变量
on: [push, pull_request]
jobs:
validate-env:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 验证 .env.example
run: |
python3 scripts/validate_env.py .env.example --strict --json
working-directory: ./path/to/skill
- name: 检查框架特定问题
run: |
python3 scripts/validate_env.py .env.example --framework nextjs --json
working-directory: ./path/to/skill
将警告视为错误(对 CI/CD 有用):
python3 scripts/validate_env.py .env --strict
何时使用:
仅显示错误,抑制警告:
python3 scripts/validate_env.py .env --quiet
何时使用:
| 框架 | 前缀 | 客户端暴露 | 备注 |
|---|---|---|---|
| Next.js | NEXT_PUBLIC_* | 是 | 在浏览器中自动暴露 |
| Vite | VITE_* | 是 | 打包到客户端代码中 |
| React (CRA) | REACT_APP_* | 是 | 嵌入到生产构建中 |
| Node.js | N/A | 否 | 仅限服务器端 |
| Flask | N/A | 否 | 仅限服务器端 |
安全警告: 切勿将密钥放入客户端暴露的变量(NEXT_PUBLIC_、VITE_、REACT_APP_)中。如果 env-manager 检测到常见的密钥模式,它会向你发出警告。
python3 scripts/validate_env.py <file> [options]
| 选项 | 描述 | 示例 |
|---|---|---|
--compare-with FILE | 与 .env.example 比较 | --compare-with .env.example |
| `--framework {nextjs | vite | react |
--strict | 将警告视为错误 | --strict |
--json | JSON 输出用于自动化 | --json |
--quiet | 仅显示错误 | --quiet |
--generate-example OUTPUT | 生成 .env.example | --generate-example .env.example |
| 代码 | 含义 | 何时 |
|---|---|---|
0 | 成功 | 无错误(警告允许,除非使用 --strict) |
1 | 验证错误 | 结构问题、重复等 |
2 | 文件未找到 | 指定的 .env 文件不存在 |
3 | 严格模式下的警告 | 存在警告且启用了 --strict |
# 新开发者克隆仓库
git clone <repo>
cd <project>
# 复制示例并填写值
cp .env.example .env
# 使用实际值编辑 .env...
# 验证设置
python3 scripts/validate_env.py .env --compare-with .env.example
# 如果缺少变量,修复它们
# 验证通过 ✅
# 在部署到 Vercel/Railway/Heroku 之前
python3 scripts/validate_env.py .env.production --framework nextjs --strict
# 修复任何错误
# 自信地部署 ✅
# 检查意外暴露的密钥
python3 scripts/validate_env.py .env.local --framework nextjs
# 查找类似警告:
# ⚠️ NEXT_PUBLIC_STRIPE_SECRET: 客户端暴露变量中包含潜在密钥
# 添加新环境变量后
echo "NEW_API_KEY=abc123" >> .env
# 重新生成 .env.example
python3 scripts/validate_env.py .env --generate-example .env.example
# 提交更新后的 .env.example
git add .env.example
git commit -m "docs: 将 NEW_API_KEY 添加到环境变量"
# 在你的 CI 流水线中
- name: 验证环境配置
run: |
python3 scripts/validate_env.py .env.example --strict --json > validation.json
# 如果验证失败,则使流水线失败
if [ $? -ne 0 ]; then
cat validation.json
exit 1
fi
env-manager 为速度而设计:
基准测试:
为何重要:
关键安全特性:
安全审计: 此技能已通过安全审查。详情请参阅 references/security.md。
最佳实践:
原因: .env 中的行没有 = 分隔符
修复:
# ❌ 错误
API_KEY
# ✅ 正确
API_KEY=your_key_here
原因: 同一变量被多次定义
修复:
# ❌ 错误
API_KEY=value1
API_KEY=value2
# ✅ 正确
API_KEY=value2
原因: 变量名不遵循 UPPERCASE_WITH_UNDERSCORES 约定
修复:
# ❌ 错误
apiKey=value
api-key=value
# ✅ 正确
API_KEY=value
原因: NEXT_PUBLIC_、VITE_ 或 REACT_APP_ 变量包含类似密钥的值
修复:
# ❌ 错误(密钥暴露给客户端!)
NEXT_PUBLIC_STRIPE_SECRET=sk_live_abc123
# ✅ 正确(仅限服务器端)
STRIPE_SECRET_KEY=sk_live_abc123
NEXT_PUBLIC_STRIPE_PUBLISHABLE=pk_live_xyz789
原因: 变量没有值
修复:
# ❌ 错误
DATABASE_URL=
# ✅ 正确(如果是可选的,请记录它)
DATABASE_URL= # 可选,如果未设置则使用 SQLite
# ✅ 更好
DATABASE_URL=postgresql://localhost/mydb
原因: 指定的 .env 文件不存在
修复:
# 检查文件是否存在
ls -la .env
# 或创建它
touch .env
检查:
这是故意的! env-manager 警告你像 NEXT_PUBLIC_API_KEY 这样的变量将在浏览器中可见。
选项:
env-manager 对密钥的处理很保守。如果它过度清理:
有关高级验证模式,请参阅 references/validation.md。
有关 Vercel、Railway、Heroku 集成模式,请参阅 references/synchronization.md。
有关全面的框架指南,请参阅 references/frameworks.md。
env-manager 是 Claude MPM 中的捆绑技能。智能体可以将其用于:
有关智能体集成模式,请参阅 INTEGRATION.md。
env-manager 遵循 Claude MPM 贡献指南:
make lint-fixmake quality详情请参阅 CONTRIBUTING.md。
MIT 许可证 - Claude MPM 项目的一部分
版本 : 1.0.0 状态 : 稳定,已通过安全审计 测试覆盖率 : 85%+ 性能 : 比目标快 80 倍
每周安装次数
63
仓库
GitHub 星标数
18
首次出现
Jan 23, 2026
安全审计
安装于
claude-code47
codex47
gemini-cli46
opencode45
cursor43
github-copilot43
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 |
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 |
--strict | Treat warnings as errors | --strict |
--json | JSON output for automation | --json |
| 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
Weekly Installs
63
Repository
GitHub Stars
18
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
claude-code47
codex47
gemini-cli46
opencode45
cursor43
github-copilot43
Azure RBAC 权限管理工具:查找最小角色、创建自定义角色与自动化分配
142,000 周安装
CLIP模型:OpenAI图像文本对比预训练,零样本分类与跨模态检索指南
215 周安装
Angular SignalStore 最佳实践 - NgRx 信号状态管理规则与技巧
222 周安装
lp-agent:自动化流动性提供策略工具 | Hummingbot API 与 Solana DEX 集成
217 周安装
SkyPilot 多云编排指南:跨 AWS/GCP/Azure 自动优化机器学习成本与分布式训练
215 周安装
邮件序列设计指南:自动化营销策略、模板与最佳实践 | 提升转化率
218 周安装
开发者成长分析工具 - 基于Claude Code聊天历史识别编码模式和改进领域
218 周安装
| N/A |
| No |
| Server-side only |
--quiet | Only show errors | --quiet |
--generate-example OUTPUT | Generate .env.example | --generate-example .env.example |