better-env

Better environment variable management for agents and humans with full type safety, CLI-based remote environment synchronization, and environment validation. Use when setting up typed config schemas, validating env variables, or managing remote env vars across Vercel, Netlify, Railway, Cloudflare, and Fly.io with better-env.

9 stars

Best use case

better-env is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Better environment variable management for agents and humans with full type safety, CLI-based remote environment synchronization, and environment validation. Use when setting up typed config schemas, validating env variables, or managing remote env vars across Vercel, Netlify, Railway, Cloudflare, and Fly.io with better-env.

Teams using better-env should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/better-env/SKILL.md --create-dirs "https://raw.githubusercontent.com/andrelandgraf/fullstackrecipes/main/.agents/skills/better-env/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/better-env/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How better-env Compares

Feature / Agentbetter-envStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Better environment variable management for agents and humans with full type safety, CLI-based remote environment synchronization, and environment validation. Use when setting up typed config schemas, validating env variables, or managing remote env vars across Vercel, Netlify, Railway, Cloudflare, and Fly.io with better-env.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

## Work With better-env In A Repo

## Type-safe environment config modules

Follow this best practice to manage environment variables in TypeScript applications with full type safety and clear server/public boundaries.

`better-env` exports `configSchema` to define typed env modules and recommends placing them in feature-level `config.ts` files (for example `src/lib/auth/config.ts` and `src/lib/database/config.ts`).

Learn more:

- `references/config-schema.md`

## Validate existence of all env variables in the current environment

Run env validation early so missing or invalid values fail fast before `dev`, `build`, or deploy steps.

`better-env validate --environment <name>` loads `.env*` files with Next.js semantics, discovers `src/lib/*/config.ts` modules, and checks every declared variable from your `configSchema` modules.

If your dotenv files intentionally include keys that are not referenced by config modules, add per-env suppressions in `better-env.ts`:

`environments.<env>.ignoreUnused: string[]`

These suppress only the selected local environment during `validate`.
Adapter defaults are merged in automatically; for Vercel,
`VERCEL_OIDC_TOKEN` is ignored by default in `development`, `preview`, and `production`.

Learn more:

- `references/env-validation.md`

## Configure runtime syncing between local files and hosted providers

Use runtime configuration to keep local dotenv targets aligned with provider environments while preserving safe defaults.

Create `better-env.ts` with `defineBetterEnv(...)` and an adapter (`vercelAdapter`, `netlifyAdapter`, `railwayAdapter`, or `cloudflareAdapter`), then define environment mappings, env-file targets, and gitignore behavior.

Learn more:

- `references/config.md`
- `references/runtime.md`

## Use the CLI for day-to-day environment operations

The CLI gives a consistent workflow for initialization, sync, validation, and remote variable management, which is great for local development and CI automation.

Recommended flow in a repo:

1. Run `better-env init` once to verify adapter prerequisites.
2. Run `better-env pull --environment <name>` to sync local env files.
3. Run `better-env validate --environment <name>` before app startup/build.
4. Use `add`, `upsert`, `update`, `delete`, and `load` for remote env changes.

Choose command behavior intentionally:

- `upsert` for idempotent automation and scripts
- `add` when duplicate keys should fail
- `update` when missing keys should fail
- `delete` to remove remote keys
- `load` for batch updates from dotenv files

Learn more:

- `references/cli.md`
- `references/vercel-adapter.md`

Related Skills

better-auth-setup

9
from andrelandgraf/fullstackrecipes

Add user authentication using Better Auth with Drizzle ORM and Neon Postgres. Base setup with email/password authentication.

better-auth-protected-routes

9
from andrelandgraf/fullstackrecipes

Add server-side route protection to enforce authentication on specific pages while keeping others public.

better-auth-profile

9
from andrelandgraf/fullstackrecipes

Add a complete account settings page with profile editing, password changes, email updates, session management, and account deletion.

better-auth-emails

9
from andrelandgraf/fullstackrecipes

Add email verification, password reset, and account management emails to Better Auth using Resend.

better-auth-components

9
from andrelandgraf/fullstackrecipes

Add UI components and pages for authentication flows including sign in, sign up, forgot password, reset password, and email verification.

better-auth-best-practices

9
from andrelandgraf/fullstackrecipes

Skill for integrating Better Auth - the comprehensive TypeScript authentication framework.

url-state-management

9
from andrelandgraf/fullstackrecipes

Sync React state to URL query parameters for shareable filters, search, and deep-linkable dialogs with nuqs.

testing

9
from andrelandgraf/fullstackrecipes

Complete testing setup with Neon database branching, Playwright browser tests, integration tests, and unit tests. Isolated branches with automatic TTL cleanup.

stripe-subscriptions

9
from andrelandgraf/fullstackrecipes

Complete subscription billing system with Stripe integration, feature flags for plan gating, webhook handling, and billing portal.

ralph-loop

9
from andrelandgraf/fullstackrecipes

Complete setup for automated agent-driven development. Define features as user stories with testable acceptance criteria, then run AI agents in a loop until all stories pass.

observability-monitoring

9
from andrelandgraf/fullstackrecipes

Complete observability stack with structured logging, error tracking, and web analytics.

env-management

9
from andrelandgraf/fullstackrecipes

Complete better-env workflow: typed config schema, Vercel sync, and prebuild validation.