deploy-to-vercel by vercel-labs/agent-skills
npx skills add https://github.com/vercel-labs/agent-skills --skill deploy-to-vercel将任何项目部署到 Vercel。除非用户明确要求生产环境,否则始终部署为预览版本。
目标是让用户获得最佳的长期设置:他们的项目通过 git-push 部署链接到 Vercel。下面的每种方法都试图让用户更接近这种状态。
在决定使用哪种方法之前,运行所有四项检查:
# 1. 检查 git 远程仓库
git remote get-url origin 2>/dev/null
# 2. 检查是否在本地链接到 Vercel 项目(存在任一文件即表示已链接)
cat .vercel/project.json 2>/dev/null || cat .vercel/repo.json 2>/dev/null
# 3. 检查 Vercel CLI 是否已安装并认证
vercel whoami 2>/dev/null
# 4. 列出可用团队(如果已认证)
vercel teams list --format json 2>/dev/null
如果用户属于多个团队,请将所有可用的团队标识符以项目符号列表形式呈现,并询问要部署到哪个团队。一旦用户选择了团队,立即进行下一步——不要请求额外的确认。
在所有后续的 CLI 命令中通过 --scope 传递团队标识符(vercel deploy、vercel link、vercel inspect 等):
vercel deploy [path] -y --no-wait --scope <team-slug>
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
如果项目已链接(存在 .vercel/project.json 或 .vercel/repo.json),这些文件中的 orgId 决定了团队——无需再次询问。如果只有一个团队(或仅个人账户),跳过提示并直接使用。
关于 .vercel/ 目录: 已链接的项目包含以下任一文件:
.vercel/project.json — 由 vercel link 创建(单项目链接)。包含 projectId 和 orgId。.vercel/repo.json — 由 vercel link --repo 创建(基于仓库的链接)。包含 orgId、remoteName 和一个将目录映射到 Vercel 项目 ID 的 projects 数组。任一文件都意味着项目已链接。请检查两者。
请勿 在未链接的目录中使用 vercel project inspect、vercel ls 或 vercel link 来检测状态——如果没有 .vercel/ 配置,它们会交互式地提示(或者使用 --yes 时,会静默链接作为副作用)。只有 vercel whoami 可以在任何地方安全运行。
.vercel/)+ 有 git 远程仓库 → Git Push这是理想状态。项目已链接并具有 git 集成。
推送前询问用户。 未经明确批准绝不推送:
此项目已通过 git 连接到 Vercel。我可以提交并推送以触发部署。需要我继续吗?
提交并推送:
git add .
git commit -m "deploy: <更改描述>"
git push
Vercel 会自动从推送构建。非生产分支获得预览部署;生产分支(通常是 main)获得生产部署。
获取预览 URL。 如果 CLI 已认证:
sleep 5
vercel ls --format json
JSON 输出包含一个 deployments 数组。找到最新的条目——它的 url 字段就是预览 URL。
如果 CLI 未认证,告诉用户检查 Vercel 仪表板或其 git 提供商的提交状态检查以获取预览 URL。
.vercel/)+ 无 git 远程仓库 → vercel deploy项目已链接但没有 git 仓库。直接使用 CLI 部署。
vercel deploy [path] -y --no-wait
使用 --no-wait 让 CLI 立即返回部署 URL,而不是阻塞直到构建完成(构建可能需要一段时间)。然后使用以下命令检查部署状态:
vercel inspect <deployment-url>
对于生产部署(仅在用户明确要求时):
vercel deploy [path] --prod -y --no-wait
CLI 正常工作但项目尚未链接。这是让用户进入最佳状态的机会。
询问用户要部署到哪个团队。 将步骤 1 中的团队标识符以项目符号列表形式呈现。如果只有一个团队(或仅个人账户),跳过此步骤。
一旦选择了团队,直接进行链接。 告诉用户将要发生什么,但不要请求单独的确认:
将此项目链接到 Vercel 上的 <团队名称>。这将创建一个 Vercel 项目用于部署,并在未来的 git 推送时启用自动部署。
如果存在 git 远程仓库,使用基于仓库的链接并指定选定的团队范围:
vercel link --repo --scope <team-slug>
这会读取 git 远程 URL 并将其与从该仓库部署的现有 Vercel 项目进行匹配。它会创建 .vercel/repo.json。这比 vercel link(不带 --repo)可靠得多,后者尝试按目录名匹配,当本地文件夹和 Vercel 项目命名不同时经常失败。
如果没有 git 远程仓库,则回退到标准链接:
vercel link --scope <team-slug>
这会提示用户选择或创建项目。它会创建 .vercel/project.json。
vercel deploy [path] -y --no-wait --scope <team-slug>,然后 vercel inspect <url> 检查状态Vercel CLI 完全没有设置。
安装 CLI(如果尚未安装):
npm install -g vercel
认证:
vercel login
用户在浏览器中完成认证。如果在无法登录的非交互式环境中运行,请跳转到下面的 无认证回退方案。
询问要部署到哪个团队 — 将 vercel teams list --format json 中的团队标识符以项目符号列表形式呈现。如果只有一个团队/个人账户,跳过。一旦选定,立即继续。
链接项目 并指定选定的团队范围(如果存在 git 远程仓库则使用 --repo,否则使用普通的 vercel link):
vercel link --repo --scope <team-slug> # 如果存在 git 远程仓库
vercel link --scope <team-slug> # 如果没有 git 远程仓库
部署 使用最佳可用方法(如果存在远程仓库则使用 git push,否则使用 vercel deploy -y --no-wait --scope <team-slug>,然后 vercel inspect <url> 检查状态)。
何时使用: 当 CLI 无法在 claude.ai 沙盒中安装或认证时的最后手段。这不需要认证——它返回一个 预览 URL(实时站点)和一个 认领 URL(转移到您的 Vercel 账户)。
bash /mnt/skills/user/deploy-to-vercel/resources/deploy.sh [path]
参数:
path - 要部署的目录,或一个 .tgz 文件(默认为当前目录)示例:
# 部署当前目录
bash /mnt/skills/user/deploy-to-vercel/resources/deploy.sh
# 部署特定项目
bash /mnt/skills/user/deploy-to-vercel/resources/deploy.sh /path/to/project
# 部署现有压缩包
bash /mnt/skills/user/deploy-to-vercel/resources/deploy.sh /path/to/project.tgz
该脚本从 package.json 自动检测框架,打包项目(排除 node_modules、.git、.env),上传它,并等待构建完成。
告诉用户: "您的部署已在 [previewUrl] 准备就绪。在 [claimUrl] 认领它以管理您的部署。"
何时使用: 在 CLI 可能未认证的 Codex 沙盒中。Codex 默认在沙盒环境中运行——首先尝试 CLI,如果认证失败则回退到部署脚本。
检查 Vercel CLI 是否已安装(此检查无需提升权限):
command -v vercel
如果 vercel 已安装,尝试使用 CLI 部署:
vercel deploy [path] -y --no-wait
如果 vercel 未安装,或者 CLI 失败并显示“未找到现有凭据”,使用回退脚本:
skill_dir="<path-to-skill>"
# 部署当前目录
bash "$skill_dir/resources/deploy-codex.sh"
# 部署特定项目
bash "$skill_dir/resources/deploy-codex.sh" /path/to/project
# 部署现有压缩包
bash "$skill_dir/resources/deploy-codex.sh" /path/to/project.tgz
该脚本处理框架检测、打包和部署。它等待构建完成并返回包含 previewUrl 和 claimUrl 的 JSON。
告诉用户: "您的部署已在 [previewUrl] 准备就绪。在 [claimUrl] 认领它以管理您的部署。"
提升的网络访问权限: 仅当沙盒化阻止了网络调用时才提升实际部署命令的权限(sandbox_permissions=require_escalated)。不要 提升 command -v vercel 检查的权限。
您拥有完整的 shell 访问权限。不要 使用 /mnt/skills/ 路径。直接使用 CLI 遵循上述决策流程。
对于无认证回退方案,从技能安装位置运行部署脚本:
bash ~/.claude/skills/deploy-to-vercel/resources/deploy.sh [path]
路径可能因用户安装技能的位置而异。
您很可能无法运行 vercel login 或 git push。直接转到 无认证回退方案 — claude.ai 沙盒。
Codex 在沙盒中运行。首先检查 CLI 是否可用,然后回退到部署脚本。转到 无认证回退方案 — Codex 沙盒。
始终向用户显示部署 URL。
Git push: 使用 vercel ls --format json 查找预览 URL。如果 CLI 未认证,告诉用户检查 Vercel 仪表板或提交状态检查。
CLI 部署: 显示 vercel deploy --no-wait 返回的 URL。使用 vercel inspect <url> 检查构建状态并向用户报告。
无认证回退方案: 同时显示预览 URL 和认领 URL:
部署成功!
预览 URL:https://my-app-abc123.vercel.app
认领 URL:https://vercel.com/claim-deployment?code=...
在预览 URL 查看您的站点。
要将此部署转移到您的 Vercel 账户,请访问认领 URL。
请勿 使用 curl 或 fetch 获取已部署的 URL 来验证其是否正常工作。只需返回链接。
如果部署因 claude.ai 上的网络限制而失败,请告诉用户:
部署因网络限制而失败。要解决此问题:
1. 前往 https://claude.ai/settings/capabilities
2. 添加 *.vercel.com 到允许的域名
3. 再次尝试部署
如果部署因沙盒环境中的网络问题(超时、DNS 错误、连接重置)而失败,请使用提升的权限重新运行(sandbox_permissions=require_escalated)。不要提升初始 CLI 可用性检查的权限——仅提升实际部署命令的权限。
给用户的示例指导:
部署需要提升的网络访问权限才能部署到 Vercel。我可以使用提升的权限重新运行命令——需要我继续吗?
如果 vercel login 或 vercel deploy 因认证错误而失败,请回退到无认证部署脚本(根据环境选择 claude.ai 或 Codex 变体)。
每周安装量
14.3K
仓库
GitHub 星标数
23.8K
首次出现
2026年3月6日
安全审计
安装于
codex12.6K
opencode12.5K
gemini-cli12.4K
cursor12.4K
github-copilot12.3K
cline12.3K
Deploy any project to Vercel. Always deploy as preview (not production) unless the user explicitly asks for production.
The goal is to get the user into the best long-term setup: their project linked to Vercel with git-push deploys. Every method below tries to move the user closer to that state.
Run all four checks before deciding which method to use:
# 1. Check for a git remote
git remote get-url origin 2>/dev/null
# 2. Check if locally linked to a Vercel project (either file means linked)
cat .vercel/project.json 2>/dev/null || cat .vercel/repo.json 2>/dev/null
# 3. Check if the Vercel CLI is installed and authenticated
vercel whoami 2>/dev/null
# 4. List available teams (if authenticated)
vercel teams list --format json 2>/dev/null
If the user belongs to multiple teams, present all available team slugs as a bulleted list and ask which one to deploy to. Once the user picks a team, proceed immediately to the next step — do not ask for additional confirmation.
Pass the team slug via --scope on all subsequent CLI commands (vercel deploy, vercel link, vercel inspect, etc.):
vercel deploy [path] -y --no-wait --scope <team-slug>
If the project is already linked (.vercel/project.json or .vercel/repo.json exists), the orgId in those files determines the team — no need to ask again. If there is only one team (or just a personal account), skip the prompt and use it directly.
About the.vercel/ directory: A linked project has either:
.vercel/project.json — created by vercel link (single project linking). Contains projectId and orgId..vercel/repo.json — created by vercel link --repo (repo-based linking). Contains orgId, remoteName, and a projects array mapping directories to Vercel project IDs.Either file means the project is linked. Check for both.
Do NOT use vercel project inspect, vercel ls, or vercel link to detect state in an unlinked directory — without a .vercel/ config, they will interactively prompt (or with --yes, silently link as a side-effect). Only vercel whoami is safe to run anywhere.
.vercel/ exists) + has git remote → Git PushThis is the ideal state. The project is linked and has git integration.
Ask the user before pushing. Never push without explicit approval:
This project is connected to Vercel via git. I can commit and push to
trigger a deployment. Want me to proceed?
Commit and push:
git add .
git commit -m "deploy: <description of changes>"
git push
Vercel automatically builds from the push. Non-production branches get preview deployments; the production branch (usually main) gets a production deployment.
Retrieve the preview URL. If the CLI is authenticated:
sleep 5
vercel ls --format json
The JSON output has a deployments array. Find the latest entry — its url field is the preview URL.
If the CLI is not authenticated, tell the user to check the Vercel dashboard or the commit status checks on their git provider for the preview URL.
.vercel/ exists) + no git remote → vercel deployThe project is linked but there's no git repo. Deploy directly with the CLI.
vercel deploy [path] -y --no-wait
Use --no-wait so the CLI returns immediately with the deployment URL instead of blocking until the build finishes (builds can take a while). Then check on the deployment status with:
vercel inspect <deployment-url>
For production deploys (only if user explicitly asks):
vercel deploy [path] --prod -y --no-wait
The CLI is working but the project isn't linked yet. This is the opportunity to get the user into the best state.
Ask the user which team to deploy to. Present the team slugs from Step 1 as a bulleted list. If there's only one team (or just a personal account), skip this step.
Once a team is selected, proceed directly to linking. Tell the user what will happen but do not ask for separate confirmation:
Linking this project to <team name> on Vercel. This will create a Vercel
project to deploy to and enable automatic deployments on future git pushes.
If a git remote exists , use repo-based linking with the selected team scope:
vercel link --repo --scope <team-slug>
This reads the git remote URL and matches it to existing Vercel projects that deploy from that repo. It creates .vercel/repo.json. This is much more reliable than vercel link (without --repo), which tries to match by directory name and often fails when the local folder and Vercel project are named differently.
If there is no git remote , fall back to standard linking:
vercel link --scope <team-slug>
This prompts the user to select or create a project. It creates .vercel/project.json.
Then deploy using the best available method:
vercel deploy [path] -y --no-wait --scope <team-slug>, then vercel inspect <url> to check statusThe Vercel CLI isn't set up at all.
Install the CLI (if not already installed):
npm install -g vercel
Authenticate:
vercel login
The user completes auth in their browser. If running in a non-interactive environment where login is not possible, skip to the no-auth fallback below.
Ask which team to deploy to — present team slugs from vercel teams list --format json as a bulleted list. If only one team / personal account, skip. Once selected, proceed immediately.
Link the project with the selected team scope (use --repo if a git remote exists, plain vercel link otherwise):
vercel link --repo --scope <team-slug> # if git remote exists
vercel link --scope <team-slug> # if no git remote
Deploy using the best available method (git push if remote exists, otherwise vercel deploy -y --no-wait --scope <team-slug>, then vercel inspect <url> to check status).
When to use: Last resort when the CLI can't be installed or authenticated in the claude.ai sandbox. This requires no authentication — it returns a Preview URL (live site) and a Claim URL (transfer to your Vercel account).
bash /mnt/skills/user/deploy-to-vercel/resources/deploy.sh [path]
Arguments:
path - Directory to deploy, or a .tgz file (defaults to current directory)Examples:
# Deploy current directory
bash /mnt/skills/user/deploy-to-vercel/resources/deploy.sh
# Deploy specific project
bash /mnt/skills/user/deploy-to-vercel/resources/deploy.sh /path/to/project
# Deploy existing tarball
bash /mnt/skills/user/deploy-to-vercel/resources/deploy.sh /path/to/project.tgz
The script auto-detects the framework from package.json, packages the project (excluding node_modules, .git, .env), uploads it, and waits for the build to complete.
Tell the user: "Your deployment is ready at [previewUrl]. Claim it at [claimUrl] to manage your deployment."
When to use: In the Codex sandbox where the CLI may not be authenticated. Codex runs in a sandboxed environment by default — try the CLI first, and fall back to the deploy script if auth fails.
Check whether the Vercel CLI is installed (no escalation needed for this check):
command -v vercel
Ifvercel is installed, try deploying with the CLI:
vercel deploy [path] -y --no-wait
Ifvercel is not installed, or the CLI fails with "No existing credentials found", use the fallback script:
skill_dir="<path-to-skill>"
# Deploy current directory
bash "$skill_dir/resources/deploy-codex.sh"
# Deploy specific project
bash "$skill_dir/resources/deploy-codex.sh" /path/to/project
# Deploy existing tarball
bash "$skill_dir/resources/deploy-codex.sh" /path/to/project.tgz
The script handles framework detection, packaging, and deployment. It waits for the build to complete and returns JSON with previewUrl and claimUrl.
Tell the user: "Your deployment is ready at [previewUrl]. Claim it at [claimUrl] to manage your deployment."
Escalated network access: Only escalate the actual deploy command if sandboxing blocks the network call (sandbox_permissions=require_escalated). Do not escalate the command -v vercel check.
You have full shell access. Do NOT use the /mnt/skills/ path. Follow the decision flow above using the CLI directly.
For the no-auth fallback, run the deploy script from the skill's installed location:
bash ~/.claude/skills/deploy-to-vercel/resources/deploy.sh [path]
The path may vary depending on where the user installed the skill.
You likely cannot run vercel login or git push. Go directly to the no-auth fallback — claude.ai sandbox.
Codex runs in a sandbox. Check if the CLI is available first, then fall back to the deploy script. Go to the no-auth fallback — Codex sandbox.
Always show the user the deployment URL.
Git push: Use vercel ls --format json to find the preview URL. If the CLI isn't authenticated, tell the user to check the Vercel dashboard or commit status checks.
CLI deploy: Show the URL returned by vercel deploy --no-wait. Use vercel inspect <url> to check build status and report it to the user.
No-auth fallback: Show both the preview URL and the claim URL:
Deployment successful!
Preview URL: https://my-app-abc123.vercel.app
Claim URL: https://vercel.com/claim-deployment?code=...
View your site at the Preview URL.
To transfer this deployment to your Vercel account, visit the Claim URL.
Do not curl or fetch the deployed URL to verify it works. Just return the link.
If deployment fails due to network restrictions on claude.ai, tell the user:
Deployment failed due to network restrictions. To fix this:
1. Go to https://claude.ai/settings/capabilities
2. Add *.vercel.com to the allowed domains
3. Try deploying again
If deployment fails due to network issues (timeouts, DNS errors, connection resets) in a sandboxed environment, rerun with escalated permissions (sandbox_permissions=require_escalated). Do not escalate the initial CLI availability check — only escalate the actual deploy command.
Example guidance to the user:
The deploy needs escalated network access to deploy to Vercel. I can rerun
the command with escalated permissions — want me to proceed?
If vercel login or vercel deploy fails with authentication errors, fall back to the no-auth deploy script (claude.ai or Codex variant, depending on the environment).
Weekly Installs
14.3K
Repository
GitHub Stars
23.8K
First Seen
Mar 6, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex12.6K
opencode12.5K
gemini-cli12.4K
cursor12.4K
github-copilot12.3K
cline12.3K
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装