jpskill.com
🛠️ 開発・MCP コミュニティ

vercel-cli-with-tokens

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o vercel-cli-with-tokens.zip https://jpskill.com/download/21000.zip && unzip -o vercel-cli-with-tokens.zip && rm vercel-cli-with-tokens.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/21000.zip -OutFile "$d\vercel-cli-with-tokens.zip"; Expand-Archive "$d\vercel-cli-with-tokens.zip" -DestinationPath $d -Force; ri "$d\vercel-cli-with-tokens.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して vercel-cli-with-tokens.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → vercel-cli-with-tokens フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

[Skill 名] vercel-cli-with-tokens

トークンを使用した Vercel CLI

vercel loginに頼らず、トークンベースの認証を使用してVercelでプロジェクトをデプロイおよび管理します。

ステップ1: Vercelトークンの特定

Vercel CLIコマンドを実行する前に、トークンがどこから来ているかを特定します。以下のシナリオを順番に確認してください。

A) VERCEL_TOKENがすでに環境に設定されている場合

printenv VERCEL_TOKEN

これが値を返す場合、準備は完了です。ステップ2に進んでください。

B) トークンが.envファイルにVERCEL_TOKENとして存在する場合

grep '^VERCEL_TOKEN=' .env 2>/dev/null

見つかった場合は、エクスポートします。

export VERCEL_TOKEN=$(grep '^VERCEL_TOKEN=' .env | cut -d= -f2-)

C) トークンが.envファイルに別の名前で存在する場合

Vercelトークンと思われる変数(Vercelトークンは通常vca_で始まります)を探します。

grep -i 'vercel' .env 2>/dev/null

出力を調べて、どの変数がトークンを保持しているかを特定し、VERCEL_TOKENとしてエクスポートします。

export VERCEL_TOKEN=$(grep '^<VARIABLE_NAME>=' .env | cut -d= -f2-)

D) トークンが見つからない場合 — ユーザーに尋ねる

上記のいずれでもトークンが得られない場合は、ユーザーに提供を依頼します。ユーザーはvercel.com/account/tokensでVercelアクセストークンを作成できます。


重要: VERCEL_TOKENが環境変数としてエクスポートされると、Vercel CLIはそれをネイティブに読み取ります。--tokenフラグとして渡さないでください。コマンドライン引数にシークレットを配置すると、シェル履歴やプロセスリストに公開されてしまいます。

# 不適切 — トークンがシェル履歴とプロセスリストに表示される
vercel deploy --token "vca_abc123"

# 適切 — CLIが環境からVERCEL_TOKENを読み取る
export VERCEL_TOKEN="vca_abc123"
vercel deploy

ステップ2: プロジェクトとチームの特定

同様に、プロジェクトIDとチームスコープを確認します。これらにより、CLIはvercel linkを必要とせずに適切なプロジェクトをターゲットにできます。

# 環境を確認
printenv VERCEL_PROJECT_ID
printenv VERCEL_ORG_ID

# または.envを確認
grep -i 'vercel' .env 2>/dev/null

プロジェクトURLがある場合(例: https://vercel.com/my-team/my-project)、チームスラッグを抽出します。

# 例: "https://vercel.com/my-team/my-project"から"my-team"
echo "$PROJECT_URL" | sed 's|https://vercel.com/||' | cut -d/ -f1

環境にVERCEL_ORG_IDVERCEL_PROJECT_IDの両方がある場合、それらをエクスポートします。CLIはこれらを自動的に使用し、.vercel/ディレクトリをスキップします。

export VERCEL_ORG_ID="<org-id>"
export VERCEL_PROJECT_ID="<project-id>"

注: VERCEL_ORG_IDVERCEL_PROJECT_IDは一緒に設定する必要があります。どちらか一方だけを設定するとエラーが発生します。

CLIセットアップ

Vercel CLIがインストールされていることを確認します。

npm install -g vercel
vercel --version

プロジェクトのデプロイ

ユーザーが明示的に本番環境を要求しない限り、常にプレビューとしてデプロイします。利用可能なものに基づいて方法を選択してください。

クイックデプロイ(プロジェクトIDがある場合 — リンク不要)

VERCEL_TOKENVERCEL_PROJECT_IDが環境に設定されている場合、直接デプロイします。

vercel deploy -y --no-wait

チームスコープがある場合(VERCEL_ORG_IDまたは--scope経由):

vercel deploy --scope <team-slug> -y --no-wait

本番環境(明示的に要求された場合のみ):

vercel deploy --prod --scope <team-slug> -y --no-wait

ステータスを確認します。

vercel inspect <deployment-url>

フルデプロイフロー(プロジェクトIDがない場合 — リンクが必要)

トークンとチームはあるが、既存のプロジェクトIDがない場合に使用します。

まずプロジェクトの状態を確認する

# プロジェクトにgitリモートはありますか?
git remote get-url origin 2>/dev/null

# すでにVercelプロジェクトにリンクされていますか?
cat .vercel/project.json 2>/dev/null || cat .vercel/repo.json 2>/dev/null

プロジェクトをリンクする

gitリモートがある場合(推奨):

vercel link --repo --scope <team-slug> -y

gitリモートを読み取り、一致するVercelプロジェクトに接続します。.vercel/repo.jsonを作成します。ディレクトリ名で一致させるだけの通常のvercel linkよりも信頼性が高いです。

gitリモートがない場合:

vercel link --scope <team-slug> -y

.vercel/project.jsonを作成します。

名前で特定のプロジェクトにリンクする:

vercel link --project <project-name> --scope <team-slug> -y

プロジェクトがすでにリンクされている場合は、.vercel/project.jsonまたは.vercel/repo.jsonorgIdを確認して、意図したチームと一致していることを確認します。

リンク後のデプロイ

A) Gitプッシュデプロイ — gitリモートがある場合(推奨)

GitプッシュはVercelの自動デプロイをトリガーします。

  1. プッシュする前にユーザーに尋ねてください。明示的な承認なしにプッシュしないでください。
  2. コミットしてプッシュします。
    git add .
    git commit -m "deploy: <description of changes>"
    git push
  3. Vercelが自動的にビルドします。非本番ブランチはプレビューデプロイメントを取得します。
  4. デプロイURLを取得します。
    sleep 5
    vercel ls --format json --scope <team-slug>

    deployments配列の最新のエントリを見つけます。

B) CLIデプロイ — gitリモートがない場合

vercel deploy --scope <team-slug> -y --no-wait

ステータスを確認します。

vercel inspect <deployment-url>

リモートリポジトリからのデプロイ(コードがローカルにクローンされていない場合)

  1. リポジトリをクローンします。
    git clone <repo-url>
    cd <repo-name>
  2. Vercelにリンクします。
    vercel link --repo --scope <team-slug> -y
  3. gitプッシュ(プッシュアクセスがある場合)またはCLIデプロイでデプロイします。

.vercel/ディレクトリについて

リンクされたプロジェクトには、次のいずれかがあります。

  • .vercel/project.jsonvercel linkから。projectIdorgIdを含みます。
  • .vercel/repo.jsonvercel link --repoから。orgIdremoteName、およびprojectsマップを含みます。

VERCEL_ORG_ID + VERCEL_PROJECT_IDが両方とも環境に設定されている場合は不要です。

リンクされていないディレクトリでvercel lsvercel project inspect、またはvercel linkを実行して状態を検出しないでください。これらは対話的にプロンプトを表示したり、副作用としてサイレントにリンクしたりします。vercel whoamiのみがどこでも安全に実行できます。

環境変数の管理

# すべての環境に設定
echo "value" | vercel env add VAR_NAME
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Vercel CLI with Tokens

Deploy and manage projects on Vercel using the CLI with token-based authentication, without relying on vercel login.

Step 1: Locate the Vercel Token

Before running any Vercel CLI commands, identify where the token is coming from. Work through these scenarios in order:

A) VERCEL_TOKEN is already set in the environment

printenv VERCEL_TOKEN

If this returns a value, you're ready. Skip to Step 2.

B) Token is in a .env file under VERCEL_TOKEN

grep '^VERCEL_TOKEN=' .env 2>/dev/null

If found, export it:

export VERCEL_TOKEN=$(grep '^VERCEL_TOKEN=' .env | cut -d= -f2-)

C) Token is in a .env file under a different name

Look for any variable that looks like a Vercel token (Vercel tokens typically start with vca_):

grep -i 'vercel' .env 2>/dev/null

Inspect the output to identify which variable holds the token, then export it as VERCEL_TOKEN:

export VERCEL_TOKEN=$(grep '^<VARIABLE_NAME>=' .env | cut -d= -f2-)

D) No token found — ask the user

If 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.


Important: Once VERCEL_TOKEN is exported as an environment variable, the Vercel CLI reads it natively — do not pass it as a --token flag. Putting secrets in command-line arguments exposes them in shell history and process listings.

# Bad — token visible in shell history and process listings
vercel deploy --token "vca_abc123"

# Good — CLI reads VERCEL_TOKEN from the environment
export VERCEL_TOKEN="vca_abc123"
vercel deploy

Step 2: Locate the Project and Team

Similarly, check for the project ID and team scope. These let the CLI target the right project without needing vercel link.

# Check environment
printenv VERCEL_PROJECT_ID
printenv VERCEL_ORG_ID

# Or check .env
grep -i 'vercel' .env 2>/dev/null

If you have a project URL (e.g. https://vercel.com/my-team/my-project), extract the team slug:

# e.g. "my-team" from "https://vercel.com/my-team/my-project"
echo "$PROJECT_URL" | sed 's|https://vercel.com/||' | cut -d/ -f1

If you have both VERCEL_ORG_ID and VERCEL_PROJECT_ID in your environment, export them — the CLI will use these automatically and skip any .vercel/ directory:

export VERCEL_ORG_ID="<org-id>"
export VERCEL_PROJECT_ID="<project-id>"

Note: VERCEL_ORG_ID and VERCEL_PROJECT_ID must be set together — setting only one causes an error.

CLI Setup

Ensure the Vercel CLI is installed:

npm install -g vercel
vercel --version

Deploying a Project

Always deploy as preview unless the user explicitly requests production. Choose a method based on what you have available.

Quick Deploy (have project ID — no linking needed)

When VERCEL_TOKEN and VERCEL_PROJECT_ID are set in the environment, deploy directly:

vercel deploy -y --no-wait

With a team scope (either via VERCEL_ORG_ID or --scope):

vercel deploy --scope <team-slug> -y --no-wait

Production (only when explicitly requested):

vercel deploy --prod --scope <team-slug> -y --no-wait

Check status:

vercel inspect <deployment-url>

Full Deploy Flow (no project ID — need to link)

Use this when you have a token and team but no pre-existing project ID.

Check project state first

# Does the project have a git remote?
git remote get-url origin 2>/dev/null

# Is it already linked to a Vercel project?
cat .vercel/project.json 2>/dev/null || cat .vercel/repo.json 2>/dev/null

Link the project

With git remote (preferred):

vercel link --repo --scope <team-slug> -y

Reads 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.

Without git remote:

vercel link --scope <team-slug> -y

Creates .vercel/project.json.

Link to a specific project by name:

vercel link --project <project-name> --scope <team-slug> -y

If the project is already linked, check orgId in .vercel/project.json or .vercel/repo.json to verify it matches the intended team.

Deploy after linking

A) Git Push Deploy — has git remote (preferred)

Git pushes trigger automatic Vercel deployments.

  1. Ask the user before pushing. Never push without explicit approval.
  2. Commit and push:
    git add .
    git commit -m "deploy: <description of changes>"
    git push
  3. Vercel builds automatically. Non-production branches get preview deployments.
  4. Retrieve the deployment URL:
    sleep 5
    vercel ls --format json --scope <team-slug>

    Find the latest entry in the deployments array.

B) CLI Deploy — no git remote

vercel deploy --scope <team-slug> -y --no-wait

Check status:

vercel inspect <deployment-url>

Deploying from a Remote Repository (code not cloned locally)

  1. Clone the repository:
    git clone <repo-url>
    cd <repo-name>
  2. Link to Vercel:
    vercel link --repo --scope <team-slug> -y
  3. Deploy via git push (if you have push access) or CLI deploy.

About .vercel/ Directory

A linked project has either:

  • .vercel/project.json — from vercel link. Contains projectId and orgId.
  • .vercel/repo.json — from vercel link --repo. Contains orgId, remoteName, and a projects map.

Not needed when VERCEL_ORG_ID + VERCEL_PROJECT_ID are both set in the environment.

Do NOT run vercel ls, vercel project inspect, or vercel link in an unlinked directory to detect state — they will interactively prompt or silently link as a side-effect. Only vercel whoami is safe to run anywhere.

Managing Environment Variables

# Set for all environments
echo "value" | vercel env add VAR_NAME --scope <team-slug>

# Set for a specific environment (production, preview, development)
echo "value" | vercel env add VAR_NAME production --scope <team-slug>

# List environment variables
vercel env ls --scope <team-slug>

# Pull env vars to local .env file
vercel env pull --scope <team-slug>

# Remove a variable
vercel env rm VAR_NAME --scope <team-slug> -y

Inspecting Deployments

# List recent deployments
vercel ls --format json --scope <team-slug>

# Inspect a specific deployment
vercel inspect <deployment-url>

# View build logs
vercel logs <deployment-url>

Managing Domains

# List domains
vercel domains ls --scope <team-slug>

# Add a domain to the project
vercel domains add <domain> --scope <team-slug>

Working Agreement

  • Never pass VERCEL_TOKEN as a --token flag. Export it as an environment variable and let the CLI read it natively.
  • Check the environment for tokens before asking the user. Look in the current env and .env files first.
  • Default to preview deployments. Only deploy to production when explicitly asked.
  • Ask before pushing to git. Never push commits without the user's approval.
  • Do not read or modify .vercel/ files directly. The CLI manages this directory.
  • Do not curl/fetch deployed URLs to verify. Just return the link to the user.
  • Use --format json when structured output will help with follow-up steps.
  • Use -y on commands that prompt for confirmation to avoid interactive blocking.

Troubleshooting

Token not found

Check the environment and any .env files present:

printenv | grep -i vercel
grep -i vercel .env 2>/dev/null

Authentication error

If the CLI fails with Authentication required:

  • The token may be expired or invalid.
  • Verify: vercel whoami (uses VERCEL_TOKEN from environment).
  • Ask the user for a fresh token.

Wrong team

Verify the scope is correct:

vercel whoami --scope <team-slug>

Build failure

Check the build logs:

vercel logs <deployment-url>

Common causes:

  • Missing dependencies — ensure package.json is complete and committed.
  • Missing environment variables — add with vercel env add.
  • Framework misconfiguration — check vercel.json. Vercel auto-detects frameworks (Next.js, Remix, Vite, etc.) from package.json; override with vercel.json if detection is wrong.

CLI not installed

npm install -g vercel