env-config
Set up and audit environment variable management — create .env.example, add startup validation, separate secrets from config, and document every variable
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Set up and audit environment variable management — create .env.example, add startup validation, separate secrets from config, and document every variable
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | env-config |
| description | Set up and audit environment variable management — create .env.example, add startup validation, separate secrets from config, and document every variable |
| compatibility | >=0.7.0 |
Skill metadata: version "1.0"; license MIT; tags [env, config, secrets, validation, dotenv]; compatibility ">=0.7.0"; recommended tools [codebase, editFiles, runCommands].
Establish a safe, documented environment variable system. Creates .env.example, adds startup validation, and ensures secrets never leak into version control.
os.getenv() / process.env.X calls without validation.env is committed or at risk of being committed to version controlScan the codebase for all environment variable reads:
# Python
grep -rn "os\.getenv\|os\.environ" . --include="*.py" | grep -v ".git/"
# Node.js / TypeScript
grep -rn "process\.env\." . --include="*.ts" --include="*.js" | grep -v "node_modules/"
# Go
grep -rn "os\.Getenv" . --include="*.go"
# Shell
grep -rn "\$[A-Z_]\{3,\}" . --include="*.sh"
Collect every variable name. De-duplicate.
| Class | Description | Example | Secret? |
|---|---|---|---|
| Secret | Must never be logged or committed | DATABASE_PASSWORD, API_KEY | Yes |
| Config | Environment-specific, not sensitive | DATABASE_HOST, PORT, LOG_LEVEL | No |
| Feature flag | Boolean toggles | FEATURE_NEW_CHECKOUT=true | No |
| Build-time | Set during CI/CD, not runtime | BUILD_VERSION, COMMIT_SHA | No |
.env.exampleDocument every variable. Secrets get placeholder values only:
# .env.example — copy to .env and fill in values
# Required
## Database
DATABASE_URL=postgres://user:password@localhost:5432/mydb
DATABASE_MAX_CONNECTIONS=10
## Auth
JWT_SECRET=<generate with: openssl rand -hex 32>
JWT_EXPIRY_HOURS=24
## External APIs
STRIPE_SECRET_KEY=sk_test_<replace>
STRIPE_WEBHOOK_SECRET=whsec_<replace>
# Optional — defaults shown
LOG_LEVEL=info
PORT=3000
FEATURE_NEW_CHECKOUT=false
Rules:
<replace> or <generate with: ...> as their value — never real values.gitignoreEnsure .env and its variants are excluded:
# Environment files — never commit
.env
.env.local
.env.*.local
.env.development
.env.production
.env.staging
# Allow example file
!.env.example
Fail fast if required variables are missing. Add a validation module:
Python (with pydantic-settings):
# config.py
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
database_url: str
jwt_secret: str
port: int = 3000
log_level: str = "info"
class Config:
env_file = ".env"
settings = Settings() # raises ValidationError on startup if required vars missing
Node.js (with zod):
// config.ts
import { z } from "zod";
const schema = z.object({
DATABASE_URL: z.string().url(),
JWT_SECRET: z.string().min(32),
PORT: z.coerce.number().default(3000),
});
export const config = schema.parse(process.env);
Go:
// config.go
func Load() (*Config, error) {
cfg := &Config{
DatabaseURL: os.Getenv("DATABASE_URL"),
Port: os.Getenv("PORT"),
}
if cfg.DatabaseURL == "" {
return nil, fmt.Errorf("DATABASE_URL is required")
}
return cfg, nil
}
os.getenv / process.env callsReplace scattered reads with centralized config access:
# Before
db_url = os.getenv("DATABASE_URL")
if not db_url:
raise ValueError("DATABASE_URL required")
# After
from config import settings
db_url = settings.database_url
Ensure CI never has .env present. Use platform secrets:
${{ secrets.JWT_SECRET }} → JWT_SECRET env var$JWT_SECRET via CI/CD variables--env-file flag or Compose env_file: key (never bake into image).env.example documents every variable with a comment and safe placeholder.gitignore excludes .env and variants, allows .env.exampleos.getenv()/process.env calls remain in application code (all routed through config module).env.example or any committed filegit log --all -- .env returns no commitsHealth check procedures D1–D14 for the Audit agent — structural validation, attention budget, version checks, workspace integrity, and static audit
Configure and manage Model Context Protocol servers for external tool access
Review a UI for accessibility — WCAG 2.1 AA compliance, semantic HTML, ARIA usage, keyboard navigation, focus management, colour contrast, and screen reader compatibility
Design or review a REST or GraphQL API — resource modeling, versioning strategy, error contract, OpenAPI/schema-first workflow, and security baseline
Generate a CHANGELOG.md entry from staged changes, a commit range, or a PR diff — following Keep a Changelog format with conventional commit classification
Generate or update onboarding documentation — README, CONTRIBUTING guide, dev environment setup script, and new-developer validation checklist