---
name: sync-vercel-env
description: Sync local .env.local variables to the Vercel project so that serverless functions (api/) can read them in development. Use when api/ functions return 500 errors due to missing environment variables, after running setup-supabase or add-login, or when the user says "las funciones no leen las env vars", "error 500 en las apis", "vercel no lee el .env". VITE_* variables are skipped (they are public and don't need to be in Vercel).
metadata:
  category: Setup & Environment
---

# Skill: Sync Vercel Env

Reads `.env.local` and pushes every non-`VITE_` variable to the Vercel project for the `development` environment. `vercel dev` reads serverless function env vars from the Vercel project, not from `.env.local`, so functions in `api/` won't see secrets until they are uploaded.

## When to run

- After `/setup-supabase` or `/add-login` writes secrets to `.env.local`
- Any time `api/` functions return 500 errors that look like "X is required" or "missing env var"

## Prerequisites

- `.env.local` exists at the project root. If not, stop:
  > No encontré `.env.local`. Asegurate de haber corrido `/setup-supabase` o `/add-login` primero.
- `.vercel/project.json` exists (project is linked). If not, stop:
  > El proyecto no está linkeado a Vercel. Corré `npx vercel link` primero.

## Steps

### 1. Run the script

```bash
bun <plugin-dir>/skills/sync-vercel-env/scripts/sync-vercel-env.ts
```

The script:
- Reads every `KEY=VALUE` line from `.env.local`.
- Skips any variable starting with `VITE_` (public, already in the bundle).
- For each remaining variable, removes the existing value in the Vercel project and re-adds it for `development` (idempotent).
- Prints the list of synced keys (never the values).

### 2. Report

> ✅ Sync listo. N variables pusheadas a Vercel (entorno `development`).
>
> Reiniciá `bun run dev` si estaba corriendo.
