Setup env validation

From redpanda-data/ui-harness · View interactive version

Setup env validation is an AI agent skill from the GitHub repository redpanda-data/ui-harness. 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.

How to use this skill

Skill file

Setup Env Validation

t3-env + zod for type-safe env vars. Single src/env.ts source of truth. PostToolUse hook block raw process.env. in TS/TSX/JS/JSX (skip env files + tests).

Steps

1. Install

bun add @t3-oss/env-core zod

2. Create `src/env.ts`

import { createEnv } from "@t3-oss/env-core";
import { z } from "zod";

export const env = createEnv({
  server: {
    DATABASE_URL: z.string().url(),
    API_SECRET: z.string().min(1),
  },
  clientPrefix: "PUBLIC_",
  client: {
    PUBLIC_API_URL: z.string().url(),
  },
  runtimeEnv: process.env,
});

Use import { env } from "@/env" everywhere instead of process.env.

3. Hook

Copy scripts/env-validation-check.sh + scripts/_hook-lib.sh -> .claude/hooks/. chmod +x. Add to PostToolUse (Edit|Write).

4. Verify

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.