better-env

Gestion améliorée des variables d'environnement pour agents et humains avec sécurité de type complète, synchronisation d'environnement distant basée sur CLI et validation d'environnement.…

npx skills add https://github.com/neondatabase/better-env --skill better-env

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, cloudflareAdapter, flyAdapter, or convexAdapter).

For a standard Vercel setup, prefer the minimal config:

export default defineBetterEnv({ adapter: vercelAdapter() });

Do not add an environments block when it only duplicates adapter defaults. Add environments only when you intentionally need custom mappings, custom env files, or per-environment ignoreUnused 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.

Choose the command runner to match the repo:

  • Use npx in npm/pnpm-based repos (for example lockfiles like package-lock.json or pnpm-lock.yaml and scripts run via npm/pnpm).
  • Use bunx in Bun-based repos (for example bun.lock and scripts run via bun).
  • 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:

  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

Plus de skills de neondatabase

add-neon-docs
neondatabase
Utilisez cette compétence lorsque l'utilisateur demande d'ajouter de la documentation, d'ajouter des docs, d'ajouter des références ou d'installer de la documentation sur Neon. Ajoute des liens de référence vers les bonnes pratiques Neon…
claimable-postgres
neondatabase
Des bases de données Postgres instantanées pour le développement local, les démos, le prototypage et les environnements de test. Aucun compte requis. Les bases de données expirent après 72 heures, sauf si elles sont réclamées sur un compte Neon.
claimable-postgres
neondatabase
Créez une base de données Postgres instantanée avec Claimable Postgres by Neon (pg.new) pour le développement local rapide, les démos, le prototypage et les environnements de test.
logging-best-practices
neondatabase
Bonnes pratiques de journalisation axées sur les événements larges (lignes de journal canoniques) pour un débogage et une analyse puissants
neon
neondatabase
Aperçu de la plateforme Neon pour les applications et agents, couvrant Postgres, Auth, Data API, et les nouveaux services : Object Storage, Compute Functions, et AI Gateway. À utiliser chaque fois que "Neon" est mentionné pour un aperçu de comment travailler avec Neon et comment démarrer. Sinon, les capacités individuelles sont les déclencheurs : "object storage" ou "stockage compatible S3", "serverless functions", "background jobs", ou "exécuter du code près de ma base de données", "AI gateway", "LLM proxy", "model routing", ou "appeler un LLM" →...
apidevelopmentdatabase
neon-ai-gateway
neondatabase
Une API et un identifiant uniques pour les LLMs de pointe et open source, intégrés dans votre branche Neon et propulsés par Databricks. À utiliser lorsqu’un utilisateur souhaite appeler un LLM, ajouter…
neon-auth
neondatabase
Configure l'authentification Neon pour votre application. Met en place l'authentification, crée des routes d'authentification et génère des composants d'interface utilisateur. À utiliser lors de l'ajout de l'authentification à Next.js,…
neon-auth
neondatabase
Add authentication to a new app. Use for "add auth", "add login", Neon Auth (Managed Better Auth), identity routing, sign-up, sign-in, password reset, email OTP, magic links, organizations, phone OTP, OAuth, OAuth server for MCP or third-party OAuth clients, passkeys, MFA, trusted domains, invalid domain, and @neon/auth. No existing identity: default to Managed Better Auth. Keep working Better Auth, Clerk, Supabase Auth, or another IdP. User asked to migrate from Supabase Auth: Managed...
apidevelopmentsecurity