add-env-variable

Automates adding and validating environment variables across a TypeScript project's schema, mapping, documentation, and tests.

1|Updated May 21, 2025
One-click install
npx skills add https://github.com/madooei/backend-template --skill add-env-variable
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-env-variable
Source: https://github.com/madooei/backend-template/tree/main/.claude/skills/add-env-variable
Command: npx skills add https://github.com/madooei/backend-template --skill add-env-variable

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Adds a structured, safe approach to introducing new environment variables, ensuring they are validated, documented, and wired into the application to prevent runtime errors.

Core Features & Use Cases

  • Schema-driven validation: updates the env schema (e.g., using zod) to validate the new variable.
  • End-to-end integration: updates src/env.ts, the dotenv mapping, .env.example, and unit tests to keep configuration consistent.
  • Documentation and testing: documents the variable in .env.example and adds tests to verify validation and defaults.

Quick Start

Add a new environment variable by updating the env schema, mapping, documentation, and tests.

Frequently Asked Questions about add-env-variable

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely add environment variables to a TypeScript project?

To safely add environment variables in TypeScript, use a schema-driven approach that updates the env mapping, documents the variable in .env.example, and adds unit tests to verify validation and defaults. This ensures configuration consistency and prevents runtime errors from misconfigurations.

Why validate environment variables with zod in TypeScript?

Validating environment variables with zod enforces explicit validation rules at the application boundary, ensuring invalid or missing configuration fails fast during startup rather than causing unpredictable runtime errors in production.

What is the best way to keep .env.example and env tests in sync?

The best way to keep .env.example and tests in sync is an end-to-end integration process that updates the schema, dotenv mapping, documentation, and unit tests simultaneously whenever a new environment variable is introduced to the codebase.

How do I update env schema and tests when introducing a new environment variable?

Updating env schema and tests involves modifying the zod schema in src/env.ts, updating the dotenv mapping, adding documentation to .env.example, and writing unit tests to verify that the validation rules and default values behave correctly.

Does adding environment variables require manual updates across multiple files?

Adding environment variables typically requires manual updates across src/env.ts, .env.example, and test files. Automating this process ensures schema validation, dotenv mapping, documentation, and test coverage are applied consistently without missing any required file modifications.

What happens if I add an environment variable without updating validation tests?

Adding an environment variable without updating validation tests risks undetected misconfigurations, where missing or invalid values bypass schema rules and cause runtime errors. Enforcing test coverage verifies defaults and validation logic to prevent these failures.