env-management

Manage environment variables with split .env.client and .env.api structure. Use when adding new env vars, debugging config issues, or setting up environments.

⭐5stars🔀1forks📁View on GitHub🕐Updated Jan 11, 2026⬇️1downloads

When & Why to Use This Skill

This Claude skill streamlines environment variable management by implementing a secure, split-file structure (.env.client and .env.api). It ensures a clear separation between public browser-side variables and sensitive server-side secrets, enhancing both security and developer workflow efficiency in modern web applications like Next.js.

Use Cases

  • Secure Configuration Setup: Automatically organize environment variables into client-side and server-side files to prevent accidental exposure of sensitive API keys.
  • New Feature Integration: Quickly add and document new environment variables with the correct prefixes (e.g., NEXT_PUBLIC_) for seamless frontend and backend integration.
  • Security Auditing: Review existing environment configurations to ensure secrets like Stripe keys or database credentials are not accessible via the browser.
  • Environment Troubleshooting: Debug configuration issues by verifying local .env files against deployment requirements for platforms like Cloudflare Pages or Vercel.
nameenv-management
descriptionManage environment variables with split .env.client and .env.api structure. Use when adding new env vars, debugging config issues, or setting up environments.

Environment Variables

Split Structure

This project uses split env files (see docs/PRDs/env-system-refactor.md):

File Purpose Prefix
.env.client Public browser vars NEXT_PUBLIC_*
.env.api Server secrets No prefix

Adding New Variables

Client-side (Public)

  1. Add to .env.client:
    NEXT_PUBLIC_API_URL=https://api.example.com
    
  2. Access in code:
    const url = process.env.NEXT_PUBLIC_API_URL;
    

Server-side (Secret)

  1. Add to .env.api:
    STRIPE_SECRET_KEY=sk_live_xxx
    
  2. Access only in server code:
    // Only in app/api/*, server/*, or Server Components
    const key = process.env.STRIPE_SECRET_KEY;
    

Security Rules

  • Never put secrets in .env.client
  • Never prefix secrets with NEXT_PUBLIC_
  • Supabase anon key is public (safe for client)
  • Supabase service role key is secret (API only)

Local Development

Copy example files:

cp .env.client.example .env.client
cp .env.api.example .env.api

Cloudflare Deployment

Set vars in Cloudflare Pages dashboard under Settings > Environment Variables.