Env Typegen for Openclaw

Automate the generation of type-safe TypeScript interfaces and Zod validation schemas from your project environment variables.

lxgicstudios
v0.1.0
Feb 2, 2026
0
0
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install env-typegen

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install env-typegen using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Env Typegen?

Env Typegen is a specialized utility designed to bridge the gap between static environment configuration and type-safe development in TypeScript. It intelligently scans your .env files and infers appropriate types for variables, transforming raw strings into numbers, booleans, or specific string formats. By incorporating this into your Openclaw Skills library, you ensure that configuration errors are caught at compile time rather than crashing your application at runtime.

The tool goes beyond simple mapping by providing helper functions that handle the casting of environment variables, which are natively strings in Node.js, into their correct primitive types. This eliminates repetitive boilerplate code and reduces the risk of logic errors when handling configuration data.

Env Typegen Use Cases

  • Eliminating runtime crashes caused by undefined or incorrectly typed environment variables.
  • Synchronizing environment variable changes across a development team with automated type updates.
  • Implementing runtime validation for mission-critical configuration using Zod schemas.
  • Standardizing how environment variables are accessed via a centralized getEnv() helper.
  • Improving IDE IntelliSense for process.env across the entire project.

How Env Typegen Works

  1. The tool identifies and parses the target .env file to extract all key-value pairs.
  2. It applies pattern-matching logic to infer the type of each value (e.g., identifying numeric ports or boolean flags).
  3. It generates a TypeScript interface (defaulting to 'Env') containing all discovered keys and their inferred types.
  4. It extends the NodeJS global namespace to provide better typing for the native process.env object.
  5. It creates a wrapper function that provides safe, typed access to the variables, including default value fallbacks.
  6. If the --zod flag is used, it additionally generates a validation schema to ensure variables meet requirements at runtime.

Env Typegen Setup

To add this capability to your Openclaw Skills workflow, install the package using npm:

npm install -g @lxgicstudios/env-typegen

You can then generate types immediately for any project by running:

npx @lxgicstudios/env-typegen -o src/types/env.d.ts

Env Typegen Data Schema & Taxonomy

The tool organizes environment metadata based on the following inference patterns:

Pattern Detected Inferred TypeScript Type Inference Logic
Numeric values (e.g., 3000) number Interpreted as integer or float
Boolean strings (true, 1, yes) boolean Case-insensitive truthy check
Standard URLs string Regex-based URL identification
Email addresses string Email format verification
Standard text string Default fallback

The output is typically structured into a .d.ts or .ts file containing the interface and a global namespace extension.

Env Typegen Advanced Features

  • Zod integration for creating robust runtime validation schemas alongside static types.
  • Support for custom input files, allowing you to target .env.local, .env.production, or other variants.
  • Configurable output paths to integrate seamlessly with existing project structures.
  • Customizable interface naming to prevent collisions in complex multi-module systems.
  • Automated casting logic within generated helpers to handle Node.js string-only environment limitations.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*