better-env

Quản lý biến môi trường tốt hơn cho agent và con người với an toàn kiểu đầy đủ, đồng bộ hóa môi trường từ xa dựa trên CLI, và xác thực môi trường.

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

Thêm skills từ neondatabase

claimable-postgres
neondatabase
Cơ sở dữ liệu Postgres tức thì cho phát triển cục bộ, demo, tạo mẫu và môi trường thử nghiệm. Không yêu cầu tài khoản. Cơ sở dữ liệu hết hạn sau 72 giờ trừ khi được claim vào tài khoản Neon.
neon
neondatabase
Tổng quan về nền tảng Neon dành cho ứng dụng và tác nhân, bao gồm Postgres, Auth, Data API, và các dịch vụ mới: Object Storage, Compute Functions, và AI Gateway. Sử dụng bất cứ khi nào "Neon" được đề cập để có cái nhìn tổng quan về cách làm việc với Neon và cách bắt đầu. Nếu không, các khả năng riêng lẻ là các kích hoạt: "object storage" hoặc "S3-compatible storage", "serverless functions", "background jobs", hoặc "run code near my database", "AI gateway", "LLM proxy", "model routing", hoặc "call an LLM" →...
apidatabasedevelopment
plugin-manager
neondatabase
Quản lý cấu trúc và cấu hình plugin cho kho lưu trữ này trên cả Cursor và Claude Code. Sử dụng khi tạo, cập nhật hoặc xem xét các thư mục plugin…
skill-creator
neondatabase
Hướng dẫn tạo kỹ năng hiệu quả. Kỹ năng này nên được sử dụng khi người dùng muốn tạo một kỹ năng mới (hoặc cập nhật kỹ năng hiện có) để mở rộng khả năng của Claude…
using-neon
neondatabase
Hướng dẫn và các phương pháp tốt nhất khi làm việc với Neon Serverless Postgres. Bao gồm bắt đầu, phát triển cục bộ với Neon, chọn phương thức kết nối, Neon…
neon-js-react
neondatabase
Thiết lập đầy đủ Neon SDK với xác thực VÀ truy vấn cơ sở dữ liệu trong các ứng dụng React (Vite, CRA). Tạo client có kiểu, sinh kiểu cơ sở dữ liệu, và cấu hình…
postgres-best-practices
neondatabase
Các phương pháp và hướng dẫn tốt nhất khi làm việc với Postgres. Bao gồm thiết kế lược đồ, chiến lược lập chỉ mục, tối ưu hóa truy vấn, di chuyển dữ liệu và các lỗi thường gặp. Sử dụng…
neon-postgres-egress-optimizer
neondatabase
Hướng dẫn người dùng chẩn đoán và khắc phục các mẫu truy vấn phía ứng dụng gây ra việc truyền dữ liệu quá mức (egress) từ cơ sở dữ liệu Postgres của họ. Hầu hết các hóa đơn egress cao đến từ việc ứng dụng lấy nhiều dữ liệu hơn mức nó sử dụng.