diff --git a/commands/env.md b/commands/env.md index 0aa565f7..94d42a46 100644 --- a/commands/env.md +++ b/commands/env.md @@ -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.** @@ -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**. @@ -130,7 +131,7 @@ The CLI will prompt for the value interactively — **do not pass the value as a ```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 @@ -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 diff --git a/skills/env-vars/SKILL.md b/skills/env-vars/SKILL.md index 2618c9e5..0c453866 100644 --- a/skills/env-vars/SKILL.md +++ b/skills/env-vars/SKILL.md @@ -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 @@ -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 @@ -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 diff --git a/tests/auth-skill.test.ts b/tests/auth-skill.test.ts index 857e2c9c..d04af250 100644 --- a/tests/auth-skill.test.ts +++ b/tests/auth-skill.test.ts @@ -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", () => { @@ -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"); }); });