setup-env-validation

Enforce type-safe environment variable access with zod in TypeScript projects.

3|1|Updated Mar 23, 2026
One-click install
npx skills add https://github.com/malinskibeniamin/skills --skill setup-env-validation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setup-env-validation
Source: https://github.com/malinskibeniamin/skills/tree/main/setup-env-validation
Command: npx skills add https://github.com/malinskibeniamin/skills --skill setup-env-validation

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Enforce type-safe environment variable access using t3-env with zod validation. Bans raw process.env.X outside dedicated env files. Use when setting up env validation, t3-env, type-safe environment variables, or banning raw process.env access.

Core Features & Use Cases

  • Centralized type-safe environment management with a single src/env.ts and zod schemas.
  • PostToolUse hook that blocks direct usage of process.env outside env definitions.
  • Clear, repeatable setup steps: install dependencies, create env.ts, wire the hook, and verify.

Quick Start

Install the required packages, create a type-safe env.ts with the provided template, and wire up the hook by placing scripts/env-validation-check.sh and _hook-lib.sh into .claude/hooks and adding the hook to PostToolUse.

Frequently Asked Questions about setup-env-validation

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

FAQPage Schema
How do I enforce type-safe environment variable access in a TypeScript project?

You can enforce type-safe environment variable access by setting up a central env.ts file with zod schemas to validate variables. A PostToolUse hook then blocks any direct usage of raw process.env outside this dedicated environment file.

What is the best way to ban raw process.env usage across my codebase?

The best way to ban raw process.env usage is implementing a PostToolUse hook that blocks direct access outside a central env definitions file. This ensures all environment variables are validated through a zod schema in your TypeScript project.

Does this environment validation approach work with t3-env and zod?

Yes, this environment validation approach works specifically with t3-env and zod. It uses a central env.ts file containing zod schemas to validate environment variables and a verification workflow to ensure type safety.

How do I set up zod schemas for environment validation in TypeScript?

To set up zod schemas for environment validation, install the required packages, create a central env.ts file using the provided template, and wire the PostToolUse hook by placing the validation scripts into your project's hooks directory.

Why should I use a central env.ts file instead of raw process.env?

Using a central env.ts file instead of raw process.env ensures centralized type-safe environment management. It validates all environment variables through zod schemas, preventing runtime errors caused by missing or malformed configuration data.

Can I use this hook to validate environment variables in any TypeScript framework?

Yes, you can use this hook to validate environment variables in any TypeScript project. It applies to TypeScript projects that want to validate all environment variables and block raw process.env usage through a central env.ts file.