Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions commands/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ For any operation that mutates **production** environment variables (`add` or `r
vercel env ls

# Filter by environment
vercel env ls production
vercel env ls --environment production
```

Present results as a table of variable **names only** grouped by environment. **Never print values.**
Expand Down Expand Up @@ -99,25 +99,26 @@ vercel env add MY_SECRET

# Non-interactive: read the value from a file so it never lands in shell
# history or process arguments (echo "value" | ... and --value do both)
vercel env add MY_SECRET production < ./secret.txt
vercel env add MY_SECRET --environment production < ./secret.txt

# Add to production and preview in one command
vercel env add MY_SECRET production,preview < ./secret.txt
vercel env add MY_SECRET --environment production,preview < ./secret.txt

# Set the type explicitly
vercel env add MY_SECRET production --type secret < ./secret.txt
vercel env add SITE_REGION production --type config < ./region.txt
vercel env add MY_SECRET --environment production --type secret < ./secret.txt
vercel env add SITE_REGION --environment production --type config < ./region.txt

# Add development in its own command; development-only adds default to Config
vercel env add MY_SECRET development < ./dev-secret.txt
vercel env add MY_SECRET --environment development < ./dev-secret.txt

# Update an existing value
vercel env update MY_SECRET production < ./secret.txt
# Update an existing value (--yes: piped input can't answer the confirmation)
vercel env update MY_SECRET --environment production --yes < ./secret.txt
```

- **Defaults**: a non-interactive add to production, preview, or a custom environment is stored as Secret.
- **Public prefixes are always Config**: variables such as `NEXT_PUBLIC_*` or `VITE_*` are exposed to browsers, so the CLI refuses `--type secret` for them. Keep a private value under a name without the prefix.
- **Flags**: `--type config|secret` needs Vercel CLI 59.6 or later. Older CLIs use `--visibility`, now a deprecated alias of `--type`. `--sensitive` (Secret) and `--no-sensitive` (Config) still work in every version.
- **Environment flag**: `--environment` and `--git-branch` on `env add`, `ls`, `rm`, and `update` need Vercel CLI 64.6.0 or later. Older CLIs take the environment and branch as bare arguments (`vercel env add NAME production`); current CLIs still accept them with a deprecation warning.
- **Team policy**: **Separate Production Secret Values** requires a Production Secret to differ from the Preview, Development, and custom environment values of the same key. Under it, create separate Production and non-Production values instead of adding one value to all targets. It replaces the deprecated **Enforce Sensitive Environment Variables** policy.

The CLI will prompt for the value interactively — **do not pass the value as a CLI argument or echo it**.
Expand All @@ -130,7 +131,7 @@ The CLI will prompt for the value interactively — **do not pass the value as a
<!-- Sourced from env-vars skill: vercel env CLI > Remove Environment Variables -->
```bash
# Remove from specific environment
vercel env rm MY_SECRET production
vercel env rm MY_SECRET --environment production

# Remove from all environments
vercel env rm MY_SECRET
Expand Down Expand Up @@ -205,7 +206,7 @@ Preview environment variables can be scoped to specific Git branches:

```bash
# Add a variable only for the "staging" branch
vercel env add DATABASE_URL preview --git-branch=staging < ./staging-database-url.txt
vercel env add DATABASE_URL --environment preview --git-branch=staging < ./staging-database-url.txt
```

## Common Gotchas
Expand Down
21 changes: 11 additions & 10 deletions skills/env-vars/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,25 +121,26 @@ vercel env add MY_SECRET

# Non-interactive: read the value from a file so it never lands in shell
# history or process arguments (echo "value" | ... and --value do both)
vercel env add MY_SECRET production < ./secret.txt
vercel env add MY_SECRET --environment production < ./secret.txt

# Add to production and preview in one command
vercel env add MY_SECRET production,preview < ./secret.txt
vercel env add MY_SECRET --environment production,preview < ./secret.txt

# Set the type explicitly
vercel env add MY_SECRET production --type secret < ./secret.txt
vercel env add SITE_REGION production --type config < ./region.txt
vercel env add MY_SECRET --environment production --type secret < ./secret.txt
vercel env add SITE_REGION --environment production --type config < ./region.txt

# Add development in its own command; development-only adds default to Config
vercel env add MY_SECRET development < ./dev-secret.txt
vercel env add MY_SECRET --environment development < ./dev-secret.txt

# Update an existing value
vercel env update MY_SECRET production < ./secret.txt
# Update an existing value (--yes: piped input can't answer the confirmation)
vercel env update MY_SECRET --environment production --yes < ./secret.txt
```

- **Defaults**: a non-interactive add to production, preview, or a custom environment is stored as Secret.
- **Public prefixes are always Config**: variables such as `NEXT_PUBLIC_*` or `VITE_*` are exposed to browsers, so the CLI refuses `--type secret` for them. Keep a private value under a name without the prefix.
- **Flags**: `--type config|secret` needs Vercel CLI 59.6 or later. Older CLIs use `--visibility`, now a deprecated alias of `--type`. `--sensitive` (Secret) and `--no-sensitive` (Config) still work in every version.
- **Environment flag**: `--environment` and `--git-branch` on `env add`, `ls`, `rm`, and `update` need Vercel CLI 64.6.0 or later. Older CLIs take the environment and branch as bare arguments (`vercel env add NAME production`); current CLIs still accept them with a deprecation warning.
- **Team policy**: **Separate Production Secret Values** requires a Production Secret to differ from the Preview, Development, and custom environment values of the same key. Under it, create separate Production and non-Production values instead of adding one value to all targets. It replaces the deprecated **Enforce Sensitive Environment Variables** policy.

### List Environment Variables
Expand All @@ -149,14 +150,14 @@ vercel env update MY_SECRET production < ./secret.txt
vercel env ls

# Filter by environment
vercel env ls production
vercel env ls --environment production
```

### Remove Environment Variables

```bash
# Remove from specific environment
vercel env rm MY_SECRET production
vercel env rm MY_SECRET --environment production

# Remove from all environments
vercel env rm MY_SECRET
Expand Down Expand Up @@ -258,7 +259,7 @@ Preview environment variables can be scoped to specific Git branches:

```bash
# Add a variable only for the "staging" branch
vercel env add DATABASE_URL preview --git-branch=staging < ./staging-database-url.txt
vercel env add DATABASE_URL --environment preview --git-branch=staging < ./staging-database-url.txt
```

## Gotchas
Expand Down
4 changes: 2 additions & 2 deletions tests/auth-skill.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe("env-vars skill guidance", () => {
// echo puts the value in shell history and process arguments; the skill
// must read secrets from a file (or a variable via printf) instead.
expect(envVars).not.toMatch(/echo "[^"]*secret[^"]*" \| vercel env (add|update)/i);
expect(envVars).toContain("vercel env add MY_SECRET production < ./secret.txt");
expect(envVars).toContain("vercel env add MY_SECRET --environment production < ./secret.txt");
});

test("documents Secret and Config types, their flags, and the update command", () => {
Expand All @@ -93,6 +93,6 @@ describe("env-vars skill guidance", () => {
expect(envVars).toContain("--no-sensitive");
expect(envVars).toContain("Separate Production Secret Values");
expect(envVars).toMatch(/stored as Secret/);
expect(envVars).toContain("vercel env update MY_SECRET production");
expect(envVars).toContain("vercel env update MY_SECRET --environment production");
});
});
Loading