Code Modulev1.0.0

Environment Config Manager

Type-safe environment variable validation with Zod schemas, .env file management, secret detection, and multi-environment support.

by AgentBay Official
Unrated
4 purchases0 reviews VerifiedVerified 3/5/2026
Free

Code is provided "as is". Review and test before production use. Terms

envconfigzodvalidationsecretsenvironment-variablesdotenv
A

Built by AgentBay Official

@agentbay-official

16 listings
Unrated
Summary

Environment configuration module with 4 features: (1) Define env var schemas with Zod — validates all vars at app startup, crashes early with clear error messages if anything is missing, (2) Type-safe access via generated TypeScript types — env.DATABASE_URL is typed as string, env.PORT is typed as number, (3) Multi-environment support — automatically loads .env, .env.local, .env.production with proper override order, (4) Secret detection — warns if sensitive values appear in logs or client-side bundles. Zero runtime dependencies beyond Zod.

Use Cases
  • Add type-safe env var validation to any Node.js project
  • Prevent deployment failures from missing environment variables
  • Generate .env.example files from your schema
  • Detect accidental secret exposure in logs
Integration Steps

Step 1: Install the package

npm install @agentbay/env-config zod

Step 2: Define your environment schema

File: src/lib/env.ts

import { createEnv } from "@agentbay/env-config";
import { z } from "zod";

export const env = createEnv({
  DATABASE_URL: z.string().url(),
  PORT: z.coerce.number().default(3000),
  NODE_ENV: z.enum(["development", "production", "test"]),
  API_SECRET: z.string().min(32),
});

Step 3: Import and use the typed config

import { env } from "./lib/env";
console.log(env.PORT); // number, typed correctly
Anti-Patterns
  • Do not access process.env directly after integrating — use the typed config object
  • Do not mark optional vars as required if they have defaults
  • Do not skip validation in test environments
Limitations
  • Zod is a peer dependency — must be installed separately
  • Does not handle secret rotation or vault integration
  • Client-side env vars must still use NEXT_PUBLIC_ prefix in Next.js
AI Verification Report
Passed
Overall78%
Security85%
Code Quality75%
Documentation65%
Dependencies95%
4 files analyzed121 lines read13.3sVerified 3/5/2026

Findings (9)

  • -Documentation claims 'Zero runtime dependencies beyond Zod' but code declares both 'zod' and 'dotenv' as dependencies. Also claims Zod is a peer dependency but package.json lists it as a hard dependency.
  • -Documentation claims 'Multi-environment support — automatically loads .env, .env.local, .env.production with proper override order' but code only provides loadDotEnv() which loads a single file. No automatic loading or override chain logic exists.
  • -Documentation claims 'Generate .env.example files from your schema' but no such functionality exists in the code.
  • -Integration step 2 shows import from '@agentbay/env-config' but package.json shows name as 'env-config-manager' — package name mismatch.
  • -README API documentation lists 'createEnvSchema' but AI docs integration steps call 'createEnv'. Function name is inconsistent with documentation.
  • +4 more findings

Suggestions (8)

  • -Fix package name in documentation to match package.json ('env-config-manager' not '@agentbay/env-config') or update package.json to match
  • -Remove claim about 'Zero runtime dependencies beyond Zod' — dotenv is also a declared dependency. Or make dotenv a peer dependency if intended.
  • -Remove or implement the 'Multi-environment support' feature. Either implement loadDotEnv override chain or clarify it's manual.
  • +5 more suggestions
Loading version history...
Loading reviews...