zod-env-integration

Original🇨🇳 Chinese
Translated
9 scriptsChecked / no sensitive code detected

Generate Zod-based environment variable management code from .env.example files. Use when you need to create type-safe env management, standardize env handling, or generate env schemas.

9installs
Added on

NPX Install

npx skill4agent add forge-town/skills zod-env-integration

SKILL.md Content (Chinese)

View Translation Comparison →

Zod Environment Variable Integration

Provides guidance and templates for generating type-safe environment variable management code based on Zod validation. Includes examples and best practices for creating schemas, getter functions, and barrel exports.

How It Works

  1. Prepare a .env.example file in the project root directory
  2. Strictly follow the code structure and patterns in best-practice-examples/
  3. For single environment: Generate
    integrations/env/
    containing schema, getter, and exports
  4. For multiple environments: Generate independent
    integrations/{env}-env/
    directories for each environment
  5. Create Zod schemas according to the code generation guidelines
  6. Implement getter functions with appropriate error handling
  7. Create barrel exports for clean imports
  8. Use the generated code in your application

Usage

This skill provides documentation and examples. Follow the steps in the reference guides:
  • Single Environment Code Generation Guide - Detailed rules for single environment code generation
  • Multiple Environments Code Generation Guide - Detailed rules for multiple environments code generation
  • .env.example Template - Template for .env files
  • Best Practice Examples - Must strictly follow single and multiple environment code examples
Important: When implementing, you must strictly follow the code structure, naming conventions, and error handling patterns in best-practice-examples. Any modifications may break the type safety guarantees.

Troubleshooting

  • Missing .env.example: Copy the template from references/.env.example.template
  • Zod Not Installed: Run
    pnpm install zod
    in your project
  • Type Errors: Check the correct schema syntax in the code generation guides
  • Import Errors: Ensure the barrel exports in index.ts are correct
  • Deviation from Best Practices: If you encounter issues, first confirm whether the code structure strictly follows the patterns in best-practice-examples