Agent skill
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.
Install this agent skill to your Project
npx add-skill https://github.com/andrelandgraf/fullstackrecipes/tree/main/templates/ai-workflow/.agents/skills/better-env
SKILL.md
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.mdreferences/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.
Choose the command runner to match the repo:
- Use
npxin npm/pnpm-based repos (for example lockfiles likepackage-lock.jsonorpnpm-lock.yamland scripts run vianpm/pnpm). - Use
bunxin Bun-based repos (for examplebun.lockand scripts run viabun). - Keep commands aligned with the project's existing package manager/runtime conventions; do not mix runners unless the repo already does.
Recommended flow in a repo:
- Run
better-env initonce to verify adapter prerequisites. - Run
better-env pull --environment <name>to sync local env files. - Run
better-env validate --environment <name>before app startup/build. - Use
add,upsert,update,delete, andloadfor remote env changes.
Choose command behavior intentionally:
upsertfor idempotent automation and scriptsaddwhen duplicate keys should failupdatewhen missing keys should faildeleteto remove remote keysloadfor batch updates from dotenv files
Learn more:
references/cli.mdreferences/vercel-adapter.md
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
shiki-code-blocks
Syntax highlight code blocks with Shiki. Supports server-side rendering in RSC and automatic light/dark theme switching.
better-auth-emails
Add email verification, password reset, and account management emails to Better Auth using Resend.
ai-sdk-setup
Install the Vercel AI SDK with AI Elements components. Build a streaming chat interface with the useChat hook.
code-style-setup
Configure Prettier for code formatting and TypeScript for typechecking. Includes VSCode settings and EditorConfig for consistent code style. Skips ESLint/Biome to avoid config complexity.
using-nuqs
Manage React state in URL query parameters with nuqs. Covers Suspense boundaries, parsers, clearing state, and deep-linkable dialogs.
chat-naming
Generate descriptive chat titles from the first message using a fast LLM. Runs as a background workflow step after the main response to avoid delaying the experience.
Didn't find tool you were looking for?