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
Sourceforge-town/skills
Added on
NPX Install
npx skill4agent add forge-town/skills zod-env-integrationTags
Translated version includes tags in frontmatterSKILL.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
- Prepare a .env.example file in the project root directory
- Strictly follow the code structure and patterns in best-practice-examples/
- For single environment: Generate containing schema, getter, and exports
integrations/env/ - For multiple environments: Generate independent directories for each environment
integrations/{env}-env/ - Create Zod schemas according to the code generation guidelines
- Implement getter functions with appropriate error handling
- Create barrel exports for clean imports
- 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 in your project
pnpm install zod - 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