← Back to Library|SkillsEnvironment Config
Install this skill: copy and save to ~/.claude/skills/environment-config/SKILL.md

Environment Config

Creates .env.example, validates env vars at startup, separates public/secret vars, and documents each variable.

3 min|Beginner
BuildQuick WinDeveloper
SKILL.md~/.claude/skills/environment-config/
---
name: environment-config
description: |
  Creates proper environment variable configuration and validation.
  IMPORTANT: Activate this skill whenever the user asks about "environment variables",
  "env setup", ".env configuration", or "env validation".
  This skill MUST be used for all environment configuration requests.
---

# Environment Config

Creates a complete environment variable setup: .env.example with documentation, runtime validation that catches missing variables at startup, and clear separation between public and secret values.

**Trigger:**

Say any of these to activate this skill:
- "set up environment variables"
- "create .env.example"
- "validate env vars"
- "Use skill: environment config"

**How It Works:**

1. Search the codebase for all `process.env` or `import.meta.env` references
2. Categorize each variable: public (safe for client) vs secret (server-only)
3. Determine which are required vs optional (check for fallback values)
4. Create .env.example with every variable, a description, and example value
5. Generate a validation module that checks all required vars at startup
6. Use zod or a simple check function (matching the project's style)
7. Ensure .env is in .gitignore (add it if missing)

**Guidelines:**

- Never put real secrets in .env.example (use placeholder values like "sk_test_...")
- Validate at application startup, not at first use (fail fast)
- Separate public vars (NEXT_PUBLIC_*, VITE_*) from server secrets
- Include a comment for each variable explaining what it's for
- If using Next.js, use the `NEXT_PUBLIC_` prefix correctly

**Works With:**

- Best with: Claude Code CLI (can search the full codebase for env references)
- Also works: Cursor, Windsurf
- Expects: Any project that uses environment variables

**Output Format:**

- .env.example with documented variables
- Validation module (env.ts or similar) that runs at startup
- Updated .gitignore if .env was missing

Creates a complete environment variable setup: .env.example with documentation, runtime validation that catches missing variables at startup, and clear separation between public and secret values.

Say any of these to activate this skill: - "set up environment variables" - "create .env.example" - "validate env vars" - "Use skill: environment config"

1. Search the codebase for all process.env or import.meta.env references 2. Categorize each variable: public (safe for client) vs secret (server-only) 3. Determine which are required vs optional (check for fallback values) 4. Create .env.example with every variable, a description, and example value 5. Generate a validation module that checks all required vars at startup 6. Use zod or a simple check function (matching the project's style) 7. Ensure .env is in .gitignore (add it if missing)

  • Never put real secrets in .env.example (use placeholder values like "sk_test_...")
  • Validate at application startup, not at first use (fail fast)
  • Separate public vars (NEXT_PUBLIC_*, VITE_*) from server secrets
  • Include a comment for each variable explaining what it's for
  • If using Next.js, use the NEXT_PUBLIC_ prefix correctly
  • Best with: Claude Code CLI (can search the full codebase for env references)
  • Also works: Cursor, Windsurf
  • Expects: Any project that uses environment variables
  • .env.example with documented variables
  • Validation module (env.ts or similar) that runs at startup
  • Updated .gitignore if .env was missing