ClawKit Logo
ClawKitReliability Toolkit
Back to Registry
Official Verified

Env Typegen - TypeScript Types from .env

Generate TypeScript types from .env files with smart inference. Type-safe environment variables. Optional Zod schema. Free CLI tool.

skill-install โ€” Terminal

Install via CLI (Recommended)

clawhub install openclaw/skills/skills/lxgicstudios/env-typegen
Or

Env Typegen

Generate TypeScript types from your .env file. Smart type inference for numbers, booleans, URLs.

Installation

npm install -g @lxgicstudios/env-typegen

Commands

Generate Types

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

With Zod Schema

npx @lxgicstudios/env-typegen --zod

Example

Input .env:

# Database
DATABASE_URL=postgresql://localhost:5432/db
DB_POOL_SIZE=10

# Server
PORT=3000
DEBUG=true

# API
API_KEY=sk_live_abc123

Output:

export interface Env {
  /** Database */
  DATABASE_URL: string;
  DB_POOL_SIZE: number;
  /** Server */
  PORT: number;
  DEBUG: boolean;
  /** API */
  API_KEY: string;
}

export function getEnv(): Env {
  return {
    DATABASE_URL: process.env.DATABASE_URL || '',
    DB_POOL_SIZE: Number(process.env.DB_POOL_SIZE),
    PORT: Number(process.env.PORT),
    DEBUG: ['true', '1', 'yes'].includes(process.env.DEBUG?.toLowerCase() || ''),
    API_KEY: process.env.API_KEY || '',
  };
}

declare global {
  namespace NodeJS {
    interface ProcessEnv {
      DATABASE_URL: string;
      DB_POOL_SIZE: string;
      PORT: string;
      DEBUG: string;
      API_KEY: string;
    }
  }
}

Type Inference

PatternType
PORT=3000number
DEBUG=trueboolean
API_URL=https://...string (URL)
[email protected]string (email)
Everything elsestring

Options

OptionDescription
-i, --inputInput file (default: .env)
-o, --outputOutput file (default: env.d.ts)
--zodGenerate Zod schema too
--nameInterface name (default: Env)

Common Use Cases

Generate for project:

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

With runtime validation:

npx @lxgicstudios/env-typegen --zod -o src/env.ts

Built by LXGIC Studios

๐Ÿ”— GitHub ยท Twitter

Metadata

Stars1601
Views0
Updated2026-02-27
View Author Profile
AI Skill Finder

Not sure this is the right skill?

Describe what you want to build โ€” we'll match you to the best skill from 16,000+ options.

Find the right skill
Add to Configuration

Paste this into your clawhub.json to enable this plugin.

{
  "plugins": {
    "official-lxgicstudios-env-typegen": {
      "enabled": true,
      "auto_update": true
    }
  }
}
Safety NoteClawKit audits metadata but not runtime behavior. Use with caution.