env-vars

Manages Vercel environment variables, .env file conventions, and OIDC token lifecycle.

Updated Aug 21, 2025
One-click install
npx skills add https://github.com/Adithiya-S/AI-Study-Companion --skill env-vars-adithiya-s
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: env-vars
Source: https://github.com/Adithiya-S/AI-Study-Companion/tree/main/.agents/skills/env-vars
Command: npx skills add https://github.com/Adithiya-S/AI-Study-Companion --skill env-vars-adithiya-s

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Managing environment variables across local development, preview, and production environments is error-prone: secrets get committed to git, vercel env pull silently overwrites custom variables, and local OIDC tokens expire mid-session causing confusing auth failures. This Skill provides expert guidance on the full Vercel environment variable workflow. ## Core Features & Use Cases - .env File Hierarchy: Explains the Next.js load order across .env, .env.local, and environment-specific variants, including which files are git-tracked and which hold secrets. - vercel env CLI Operations: Covers pulling, adding, listing, and removing variables with environment scoping, sensitive flags, and Git branch overrides. - OIDC Token Lifecycle: Documents how VERCEL_OIDC_TOKEN works on Vercel versus locally, and how to troubleshoot expiry and AI Gateway authentication. - Use Case: After cloning a project on a new machine, run the bootstrap sequence to link the Vercel project, pull secrets into .env.local, and verify all keys from .env.example exist. ## Quick Start Pull the Vercel environment variables for this project into .env.local and verify that every key listed in .env.example is present.

Frequently Asked Questions about env-vars

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I pull Vercel environment variables to local development?

Run vercel env pull .env.local after linking your project with vercel link. This writes all environment variables for the development environment into .env.local, including a VERCEL_OIDC_TOKEN valid for about 12 hours.

What is the Next.js .env file load order?

Next.js loads .env first, then .env.[environment], then .env.local, and finally .env.[environment].local with the highest priority. The .env.local file is skipped in the test environment and is always gitignored.

Why does vercel env pull delete my custom variables?

vercel env pull replaces the entire target file, discarding any manually added variables. Keep custom variables in .env.development.local instead, which Next.js loads after .env.local, or back them up before pulling.

Why do I get OIDC authentication errors in local development?

Locally pulled VERCEL_OIDC_TOKEN values expire after roughly 12 hours, causing auth failures with AI Gateway or other Vercel services. Re-run vercel env pull .env.local --yes to provision a fresh token.

Can I scope Vercel environment variables to a specific Git branch?

Yes, preview environment variables can be scoped to specific branches using the --git-branch flag, for example vercel env add DATABASE_URL preview --git-branch=staging. Variables can also be scoped to production, preview, or development environments.

Why don't standalone scripts load variables from .env.local?

Only Next.js auto-loads .env.local; tools like drizzle-kit or tsx scripts do not. Use dotenv-cli, for example npx dotenv -e .env.local -- npx drizzle-kit push, or export the variables manually before running the script.