void-env-validation

Validates environment variables at boot using Zod schemas in a typed env module.

Updated May 29, 2026
One-click install
npx skills add https://github.com/voidcorp-core/void-harness --skill void-env-validation-voidcorp-core
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: void-env-validation
Source: https://github.com/voidcorp-core/void-harness/tree/main/packages/cli/core-assets/packs/pack-server/skills/void-env-validation
Command: npx skills add https://github.com/voidcorp-core/void-harness --skill void-env-validation-voidcorp-core

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires zod.

What problem does it solve? Environment variables are an invisible trust boundary: missing or malformed values like a database URL cause crashes mid-request instead of clear failures at startup. This Skill enforces a pattern where all env vars are parsed and validated once at boot, so configuration errors surface immediately with descriptive messages. ## Core Features & Use Cases - Boot-time validation with Zod: Define Server and Client schemas that parse process.env once and export a typed env object, throwing at module load if anything is missing or invalid. - Server/client separation: Keep server-only secrets out of the browser bundle by parsing the server schema only when window is undefined and restricting client code to NEXT_PUBLIC_* variables. - Per-runtime safety: Guidance for Node, Edge, and browser runtimes, including granular env-client and env-server imports for Edge routes. - Use Case: When adding a new STRIPE_SECRET_KEY to a Next.js app, add it to the Zod schema, update .env.example, and reference it via the typed env import instead of raw process.env. ## Quick Start Ask the agent to add a new environment variable to the project using the validated env schema pattern and update .env.example accordingly.

Frequently Asked Questions about void-env-validation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I validate environment variables with Zod in Next.js?

Define a Zod schema for your variables and call .parse(process.env) once in a dedicated env module, then export the typed result. The app throws at boot with a clear Zod error if any variable is missing or invalid, instead of crashing mid-request.

How to separate server and client environment variables in Next.js?

Create separate Server and Client schemas: parse the server schema only when typeof window === 'undefined', and restrict the client schema to NEXT_PUBLIC_* variables. For Edge routes, split exports into env-client and env-server modules so server-only parsing never runs in the browser or Edge bundle.

Why does my Edge route fail when reading environment variables?

Edge runtimes lack full process.env access, so importing a module that parses server-only variables like DATABASE_URL fails. Import from a granular env-client module in Edge routes and keep server-only schema parsing in env-server.

Should I use NEXT_PUBLIC_ prefix for API keys and secrets?

No. Anything prefixed NEXT_PUBLIC_ is baked into the client bundle at build time and visible to anyone. Use NEXT_PUBLIC_ only for browser-safe values like the app URL, and keep secrets as server-only variables with domain-prefixed names like STRIPE_SECRET_KEY.

Why avoid process.env fallbacks or non-null assertions in TypeScript?

Fallbacks like process.env.KEY ?? 'default' silently hide configuration errors, and non-null assertions bypass the type system, producing undefined errors mid-request. A Zod schema parse at boot throws a descriptive error naming the exact missing field.