env-constants
Generates src/shared/EnvConsts.ts for type-safe environment variable access. Provides TypeScript interface and exports for accessing Vite environment variables throughout the application.
When & Why to Use This Skill
This Claude skill automates the creation of a type-safe environment variable management system for TypeScript and Vite applications. By generating a centralized 'EnvConsts.ts' file, it wraps Vite's native environment handling to provide a robust interface with auto-completion and default values, effectively eliminating runtime errors caused by missing or misspelled configuration keys.
Use Cases
- Scenario 1: Initializing a new Vite-based frontend project and needing to establish a best-practice architecture for environment variable access from day one.
- Scenario 2: Refactoring legacy TypeScript codebases to replace scattered 'import.meta.env' calls with a single, type-safe source of truth to improve maintainability.
- Scenario 3: Ensuring development team consistency by automatically providing fallback default values for local environments, preventing application crashes when .env files are incomplete.
| name | env-constants |
|---|---|
| description | Generates src/shared/EnvConsts.ts for type-safe environment variable access. Provides TypeScript interface and exports for accessing Vite environment variables throughout the application. |
Environment Constants Skill
Purpose
Generate the src/shared/EnvConsts.ts file for accessing environment variables with type safety.
Output
Create the file: src/shared/EnvConsts.ts
Example File
See: examples.md in this directory for complete examples and detailed explanations.
Notes
- Wraps Vite's import.meta.env for type safety
- Provides default values for all environment variables.