{"data":{"slug":"github-vercel-labs-agent-skills-skills-vercel-cli-with-tokens-f8f156e5dfaa","title":"Vercel CLI with Tokens","summary":"Deploy and manage Vercel projects using CLI with token-based authentication for secure and automated workflows.","url":"https:\/\/skillshunter.net\/skills\/github-vercel-labs-agent-skills-skills-vercel-cli-with-tokens-f8f156e5dfaa","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-vercel-labs-agent-skills-skills-vercel-cli-with-tokens-f8f156e5dfaa","markdown_url":"https:\/\/skillshunter.net\/skills\/github-vercel-labs-agent-skills-skills-vercel-cli-with-tokens-f8f156e5dfaa.md","download_url":"https:\/\/skillshunter.net\/skills\/github-vercel-labs-agent-skills-skills-vercel-cli-with-tokens-f8f156e5dfaa\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before deploying, ensure the Vercel CLI is installed and up to date. The token must be exported as an environment variable (e.g., `VERCEL_TOKEN`), not passed as a command-line argument.","instructions":"---\nname: vercel-cli-with-tokens\ndescription: Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login \u2014 e.g. \"deploy to vercel\", \"set up vercel\", \"add environment variables to vercel\".\nmetadata:\n  author: vercel\n  version: \"1.0.0\"\n---\n\n# Vercel CLI with Tokens\n\nDeploy and manage projects on Vercel using the CLI with token-based authentication, without relying on `vercel login`.\n\n## Step 1: Locate the Vercel Token\n\nBefore running any Vercel CLI commands, identify where the token is coming from. Work through these scenarios in order:\n\n### A) `VERCEL_TOKEN` is already set in the environment\n\n```bash\nprintenv VERCEL_TOKEN\n```\n\nIf this returns a value, you're ready. Skip to Step 2.\n\n### B) Token is in a `.env` file under `VERCEL_TOKEN`\n\n```bash\ngrep '^VERCEL_TOKEN=' .env 2>\/dev\/null\n```\n\nIf found, export it:\n\n```bash\nexport VERCEL_TOKEN=$(grep '^VERCEL_TOKEN=' .env | cut -d= -f2-)\n```\n\n### C) Token is in a `.env` file under a different name\n\nLook for any variable that looks like a Vercel token (Vercel tokens typically start with `vca_`):\n\n```bash\ngrep -i 'vercel' .env 2>\/dev\/null\n```\n\nInspect the output to identify which variable holds the token, then export it as `VERCEL_TOKEN`:\n\n```bash\nexport VERCEL_TOKEN=$(grep '^<VARIABLE_NAME>=' .env | cut -d= -f2-)\n```\n\n### D) No token found \u2014 ask the user\n\nIf none of the above yield a token, ask the user to provide one. They can create a Vercel access token at vercel.com\/account\/tokens.\n\n---\n\n**Important:** Once `VERCEL_TOKEN` is exported as an environment variable, the Vercel CLI reads it natively \u2014 **do not pass it as a `--token` flag**. Putting secrets in command-line arguments exposes them in shell history and process listings.\n\n```bash\n# Bad \u2014 token visible in shell history and process listings\nvercel deploy --token \"vca_abc123\"\n\n# Good \u2014 CLI reads VERCEL_TOKEN from the environment\nexport VERCEL_TOKEN=\"vca_abc123\"\nvercel deploy\n```\n\n## Step 2: Locate the Project and Team\n\nSimilarly, check for the project ID and team scope. These let the CLI target the right project without needing `vercel link`.\n\n```bash\n# Check environment\nprintenv VERCEL_PROJECT_ID\nprintenv VERCEL_ORG_ID\n\n# Or check .env\ngrep -i 'vercel' .env 2>\/dev\/null\n```\n\n**If you have a project URL** (e.g. `https:\/\/vercel.com\/my-team\/my-project`), extract the team slug:\n\n```bash\n# e.g. \"my-team\" from \"https:\/\/vercel.com\/my-team\/my-project\"\necho \"$PROJECT_URL\" | sed 's|https:\/\/vercel.com\/||' | cut -d\/ -f1\n```\n\n**If you have both `VERCEL_ORG_ID` and `VERCEL_PROJECT_ID` in your environment**, export them \u2014 the CLI will use these automatically and skip any `.vercel\/` directory:\n\n```bash\nexport VERCEL_ORG_ID=\"<org-id>\"\nexport VERCEL_PROJECT_ID=\"<project-id>\"\n```\n\nNote: `VERCEL_ORG_ID` and `VERCEL_PROJECT_ID` must be set together \u2014 setting only one causes an error.\n\n## CLI Setup\n\nEnsure the Vercel CLI is installed and up to date:\n\n```bash\nnpm install -g vercel\nvercel --version\n```\n\n## Deploying a Project\n\nAlways deploy as **preview** unless the user explicitly requests production. Choose a method based on what you have available.\n\n### Quick Deploy (have project ID \u2014 no linking needed)\n\nWhen `VERCEL_TOKEN` and `VERCEL_PROJECT_ID` are set in the environment, deploy directly:\n\n```bash\nvercel deploy -y --no-wait\n```\n\nWith a team scope (either via `VERCEL_ORG_ID` or `--scope`):\n\n```bash\nvercel deploy --scope <team-slug> -y --no-wait\n```\n\nProduction (only when explicitly requested):\n\n```bash\nvercel deploy --prod --scope <team-slug> -y --no-wait\n```\n\nCheck status:\n\n```bash\nvercel inspect <deployment-url>\n```\n\n### Full Deploy Flow (no project ID \u2014 need to link)\n\nUse this when you have a token and team but no pre-existing project ID.\n\n#### Check project state first\n\n```bash\n# Does the project have a git remote?\ngit remote get-url origin 2>\/dev\/null\n\n# Is it already linked to a Vercel project?\ncat .vercel\/project.json 2>\/dev\/null || cat .vercel\/repo.json 2>\/dev\/null\n```\n\n#### Link the project\n\n**With git remote (preferred):**\n\n```bash\nvercel link --repo --scope <team-slug> -y\n```\n\nReads the git remote and connects to the matching Vercel project. Creates `.vercel\/repo.json`. More reliable than plain `vercel link`, which matches by directory name.\n\n**Without git remote:**\n\n```bash\nvercel link --scope <team-slug> -y\n```\n\nCreates `.vercel\/project.json`.\n\n**Link to a specific project by name:**\n\n```bash\nvercel link --project <project-name> --scope <team-slug> -y\n```\n\nIf the project is already linked, check `orgId` in `.vercel\/project.json` or `.vercel\/repo.json` to verify it matches the intended team.\n\n#### Deploy after linking\n\n**A) Git Push Deploy \u2014 has git remote (preferred)**\n\nGit pushes trigger automatic Vercel deployments.\n\n1. **Ask the user before pushing.** Never push without explicit approval.\n2. Commit and push:\n   ```bash\n   git add .\n   git commit -m \"deploy: <description of changes>\"\n   git push\n   ```\n3. Vercel builds automatically. Non-production branches get preview deployments.\n4. Retrieve the deployment URL:\n   ```bash\n   sleep 5\n   vercel ls --format json --scope <team-slug>\n   ```\n   Find the latest entry in the `deployments` array.\n\n**B) CLI Deploy \u2014 no git remote**\n\n```bash\nvercel deploy --scope <team-slug> -y --no-wait\n```\n\nCheck status:\n\n```bash\nvercel inspect <deployment-url>\n```\n\n### Deploying from a Remote Repository (code not cloned locally)\n\n1. Clone the repository:\n   ```bash\n   git clone <repo-url>\n   cd <repo-name>\n   ```\n2. Link to Vercel:\n   ```bash\n   vercel link --repo --scope <team-slug> -y\n   ```\n3. Deploy via git push (if you have push access) or CLI deploy.\n\n### About `.vercel\/` Directory\n\nA linked project has either:\n- `.vercel\/project.json` \u2014 from `vercel link`. Contains `projectId` and `orgId`.\n- `.vercel\/repo.json` \u2014 from `vercel link --repo`. Contains `orgId`, `remoteName`, and a `projects` map.\n\nNot needed when `VERCEL_ORG_ID` + `VERCEL_PROJECT_ID` are both set in the environment.\n\n**Do NOT** run `vercel project inspect` or `vercel link` in an unlinked directory to detect state \u2014 they will interactively prompt or silently link as a side-effect. `vercel ls` is safe (in an unlinked directory it defaults to showing all deployments for the scope). `vercel whoami` is safe anywhere.\n\n## Managing Environment Variables\n\n```bash\n# Set for all environments\necho \"value\" | vercel env add VAR_NAME --scope <team-slug>\n\n# Set for a specific environment (production, preview, development)\necho \"value\" | vercel env add VAR_NAME production --scope <team-slug>\n\n# List environment variables\nvercel env ls --scope <team-slug>\n\n# Pull env vars to local .env.local file\nvercel env pull --scope <team-slug>\n\n# Remove a variable\nvercel env rm VAR_NAME --scope <team-slug> -y\n```\n\n## Inspecting Deployments\n\n```bash\n# List recent deployments\nvercel ls --format json --scope <team-slug>\n\n# Inspect a specific deployment\nvercel inspect <deployment-url>\n\n# View build logs (requires Vercel CLI v35+)\nvercel inspect <deployment-url> --logs\n\n# View runtime request logs (follows live by default; add --no-follow for a one-shot snapshot)\nvercel logs <deployment-url>\n```\n\n## Managing Domains\n\n```bash\n# List domains\nvercel domains ls --scope <team-slug>\n\n# Add a domain to the project \u2014 linked or env-linked directory (1 arg)\nvercel domains add <domain> --scope <team-slug>\n\n# Add a domain \u2014 unlinked directory (requires <project> positional)\nvercel domains add <domain> <project> --scope <team-slug>\n```\n\n## Stripe Projects Plan Changes\n\nIf this project is managed by Stripe Projects. **Ask the user before running any paid or destructive plan change** \u2014 upgrades bill a real card, downgrades remove seats.\n\nFirst run `stripe projects status --json` to confirm the Vercel resource's local name. The examples below assume the default (`vercel-plan`); substitute the actual name if it was renamed at `stripe projects add` time.\n\n- **Upgrade to Pro:** `stripe projects add vercel\/pro` (or `stripe projects upgrade vercel-plan pro`)\n- **Downgrade to Hobby:** `stripe projects downgrade vercel-plan hobby`\n\n### What Pro gives you\n\n- $20\/month platform fee, includes $20\/month of usage credit.\n- Turbo build machines (30 vCPUs, 60 GB memory) by default for new projects \u2014 significantly faster builds than Hobby.\n- 1 deploying seat + unlimited free Viewer seats (read-only collaborators, preview comments).\n- Higher included allocations (1 TB Fast Data Transfer, 10M Edge Requests per month).\n- Paid add-ons available: SAML SSO, HIPAA BAA, Flags Explorer, Observability Plus, Speed Insights, Web Analytics Plus.\n\nFull details: https:\/\/vercel.com\/docs\/plans\/pro-plan\n\n## Working Agreement\n\n- **Never pass `VERCEL_TOKEN` as a `--token` flag.** Export it as an environment variable and let the CLI read it natively.\n- **Check the environment for tokens before asking the user.** Look in the current env and `.env` files first.\n- **Default to preview deployments.** Only deploy to production when explicitly asked.\n- **Ask before pushing to git.** Never push commits without the user's approval.\n- **Do not modify `.vercel\/` files directly.** The CLI manages this directory. Reading them (e.g. to verify `orgId`) is fine.\n- **Do not curl\/fetch deployed URLs to verify.** Just return the link to the user.\n- **Use `--format json`** when structured output will help with follow-up steps.\n- **Use `-y`** on commands that prompt for confirmation to avoid interactive blocking.\n\n## Troubleshooting\n\n### Token not found\n\nCheck the environment and any `.env` files present:\n\n```bash\nprintenv | grep -i vercel\ngrep -i vercel .env 2>\/dev\/null\n```\n\n### Authentication error\n\nIf the CLI fails with `Authentication required`:\n- The token may be expired or invalid.\n- Verify: `vercel whoami` (uses `VERCEL_TOKEN` from environment).\n- Ask the user for a fresh token.\n\n### Wrong team\n\nVerify the scope is correct:\n\n```bash\nvercel whoami --scope <team-slug>\n```\n\n### Build failure\n\nCheck the build logs:\n\n```bash\nvercel inspect <deployment-url> --logs\n```\n\nCommon causes:\n- Missing dependencies \u2014 ensure `package.json` is complete and committed.\n- Missing environment variables \u2014 add with `vercel env add`.\n- Framework misconfiguration \u2014 check `vercel.json`. Vercel auto-detects frameworks (Next.js, Remix, Vite, etc.) from `package.json`; override with `vercel.json` if detection is wrong.\n\n### CLI not installed\n\n```bash\nnpm install -g vercel\n```\n","use_cases":["Deploying to Vercel using access tokens instead of interactive login","Setting up Vercel projects with environment variables","Adding environment variables to Vercel projects"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/vercel-labs\/agent-skills\/blob\/1a2c79d4e6c4a2283dc2c614b6538cbe1ed5ca62\/skills\/vercel-cli-with-tokens\/SKILL.md","source_commit":"1a2c79d4e6c4a2283dc2c614b6538cbe1ed5ca62","license":null,"version":null,"listing_approved_at":"2026-11-15","created_at":"2026-11-15T05:09:04.000000Z","updated_at":"2026-11-15T18:51:31.000000Z","seo_title":"Vercel CLI with Tokens for Deployment","seo_description":"Securely deploy and manage Vercel projects using CLI with token-based authentication. Automate deployments without interactive login.","seo_keywords":["Vercel CLI deployment","Token-based Vercel authentication","Automate Vercel deployments","Vercel CLI setup","Secure Vercel project management"]}}