Community程式設計與開發github.com

部署到 Vercel

將應用程式和網站部署到 Vercel。當使用者要求部署操作時使用,例如「部署我的應用程式」、「部署並給我連結」、「將此上線」或「建立預覽部署」。

部署到 Vercel 是什麼?

這是一個用於將專案部署到 Vercel 的 AI 代理技能,支援 Claude Code、claude.ai 和 Codex 等平台。其主要目標是引導使用者建立最理想的長期設定:將專案連結到 Vercel,並啟用 git push 自動部署。技能會先檢查專案狀態(git 遠端、Vercel 連結、CLI 認證與團隊),然後根據狀態選擇最合適的部署方法:已連結且有 git 遠端時使用 git push,已連結但無 git 遠端時使用 `vercel deploy`,未連結但 CLI 已認證時先連結再部署,未連結且 CLI 未認證時則安裝 CLI、登入、連結然後部署。在無法進行 CLI 認證的沙盒環境(claude.ai 或 Codex)中,技能提供無需認證的備用方案,使用部署腳本上傳專案並取得預覽 URL 和認領 URL。技能始終優先使用預覽部署,除非使用者明確要求生產部署。

相容平台✓Claude Code✓Codex CLI~Cursor
npx skills add https://github.com/alfathafp/portofolio-web-design/tree/HEAD/.agents/skills/deploy-to-vercel

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

部署到 Vercel 是做什麼的?

將任何專案部署到 Vercel。始終部署為預覽(非生產環境),除非使用者明確要求生產環境。

目標是讓使用者進入最佳的長期設定:將其專案連結到 Vercel,並啟用 git push 部署。以下每種方法都試圖讓使用者更接近該狀態。

步驟 1:收集專案狀態

在決定使用哪種方法之前,請執行所有四項檢查:

# 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

團隊選擇

如果使用者屬於多個團隊,請以項目符號清單呈現所有可用的團隊 slug,並詢問要部署到哪一個。一旦使用者選定團隊,立即進行下一步 — 無需要求額外確認。

在後續所有 CLI 指令中透過 --scope 傳遞團隊 slug(vercel deploy、vercel link、vercel inspect 等):

出 vercel deploy [path] -y --no-wait --scope <團隊-slug>

如果專案已連結(存在 .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 可以在任何地方安全執行。

步驟 2:選擇部署方式

已連結(存在 .vercel/)+ 有 git 遠端 → Git Push

這是理想的狀態。專案已連結並具有 git 整合。

  1. 在推送前詢問使用者。 未經明確批准,切勿推送:

    此專案已透過 git 連接到 Vercel。我可以提交並推送以觸發部署。
    要我繼續嗎?
    
  2. 提交並推送:

    git add .
    git commit -m "deploy: <變更的描述>"
    git push
    

    Vercel 會自動從推送進行構建。非生產分支會獲得預覽部署;生產分支(通常是 main)會獲得生產部署。

  3. 取得預覽 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 <部署-url>

對於生產部署(僅在使用者明確要求時):

vercel deploy [path] --prod -y --no-wait

未連結 + CLI 已認證 → 先連結,再部署

CLI 可正常運作但專案尚未連結。這是讓使用者進入最佳狀態的機會。

  1. 詢問使用者要部署到哪個團隊。 以項目符號清單呈現來自步驟 1 的團隊 slug。如果只有一個團隊(或僅有個人帳戶),則跳過此步驟。

  2. 一旦選定團隊,直接進行連結。 告知使用者即將發生的事情,但無需單獨確認:

    正在將此專案連結到 <團隊名稱> 的 Vercel。這將建立一個用於部署的 Vercel 專案,
    並在未來 git 推送時啟用自動部署。
    
  3. 如果存在 git 遠端,使用選定團隊範圍進行基於儲存庫的連結:

    vercel link --repo --scope <團隊-slug>
    

    這會讀取 git 遠端 URL 並將其與從該儲存庫部署的現有 Vercel 專案進行比對。它會建立 .vercel/repo.json。這比 vercel link(不帶 --repo)可靠得多,後者嘗試按目錄名稱進行比對,並且在本地資料夾和 Vercel 專案名稱不同時經常失敗。

    如果沒有 git 遠端,回退到標準連結:

    vercel link --scope <團隊-slug>
    

    這會提示使用者選擇或建立專案。它會建立 .vercel/project.json。

  4. 然後使用最佳可用方法部署:

    • 如果存在 git 遠端 → 提交並推送(請參閱上方的 git push 方法)
    • 如果沒有 git 遠端 → vercel deploy [path] -y --no-wait --scope <團隊-slug>,然後使用 vercel inspect <url> 檢查狀態

未連結 + CLI 未認證 → 安裝、認證、連結、部署

Vercel CLI 完全未設定。

  1. 安裝 CLI(如果尚未安裝):

    npm install -g vercel
    
  2. 認證:

    vercel login
    

    使用者在瀏覽器中完成認證。如果在非互動式環境中無法登入,請跳到下方的無認證備用方案。

  3. 詢問要部署到哪個團隊 — 以項目符號清單呈現來自 vercel teams list --format json 的團隊 slug。如果只有一個團隊或個人帳戶,則跳過。選定後,立即繼續。

  4. 使用選定的團隊範圍連結專案(如果存在 git 遠端則使用 --repo,否則使用普通的 vercel link):

    vercel link --repo --scope <團隊-slug>   # 如果存在 git 遠端
    vercel link --scope <團隊-slug>          # 如果沒有 git 遠端
    
  5. 使用最佳可用方法部署(如果存在遠端則使用 git push,否則使用 vercel deploy -y --no-wait --scope <團隊-slug>,然後使用 vercel inspect <url> 檢查狀態)。


無認證備用方案 — claude.ai 沙盒

何時使用: 在 claude.ai 沙盒中無法安裝或認證 CLI 時的最後手段。這不需要認證 — 它會返回一個預覽 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

# 部署現有的 tarball
bash /mnt/skills/user/deploy-to-vercel/resources/deploy.sh /path/to/project.tgz

該腳本會從 package.json 自動偵測框架,打包專案(排除 node_modules、.git、.env),上傳並等待構建完成。

告訴使用者:「您的部署已在 [previewUrl] 準備就緒。在 [claimUrl] 認領它以管理您的部署。」


無認證備用方案 — Codex 沙盒

何時使用: 在 Codex 沙盒中,CLI 可能未認證。Codex 預設在沙盒環境中執行 — 先嘗試使用 CLI,如果認證失敗則回退到部署腳本。

  1. 檢查 Vercel CLI 是否已安裝(此檢查無需升級權限):

    command -v vercel
    
  2. 如果 vercel 已安裝,嘗試使用 CLI 部署:

    vercel deploy [path] -y --no-wait
    
  3. 如果 vercel 未安裝,或 CLI 失敗並顯示「No existing credentials found」,使用備用腳本:

    skill_dir="<技能路徑>"
    
    # 部署當前目錄
    bash "$skill_dir/resources/deploy-codex.sh"
    
    # 部署特定專案
    bash "$skill_dir/resources/deploy-codex.sh" /path/to/project
    
    # 部署現有的 tarball
    bash "$skill_dir/resources/deploy-codex.sh" /path/to/project.tgz
    

該腳本處理框架偵測、打包和部署。它等待構建完成並傳回包含 previewUrl 和 claimUrl 的 JSON。

告訴使用者:「您的部署已在 [previewUrl] 準備就緒。在 [claimUrl] 認領它以管理您的部署。」

升級的網路存取: 僅在沙盒阻止網路呼叫時才升級實際的部署指令(sandbox_permissions=require_escalated)。請勿升級 command -v vercel 檢查。


代理特定注意事項

Claude Code / 基於終端機的代理

您擁有完整的 Shell 存取權限。請勿使用 /mnt/skills/ 路徑。直接使用 CLI 遵循上述決策流程。

對於無認證備用方案,從技能安裝位置執行部署腳本:

bash ~/.claude/skills/deploy-to-vercel/resources/deploy.sh [path]

路徑可能因使用者安裝技能的位置而異。

沙盒環境 (claude.ai)

您可能無法執行 vercel login 或 git push。直接前往無認證備用方案 — claude.ai 沙盒。

Codex

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)

如果由於 claude.ai 上的網路限制導致部署失敗,請告訴使用者:

部署因網路限制而失敗。若要修正此問題:

1. 前往 https://claude.ai/settings/capabilities
2. 將 *.vercel.com 新增到允許的網域
3. 再次嘗試部署

升級的網路存取 (Codex / 沙盒環境)

如果在沙盒環境中因網路問題(逾時、DNS 錯誤、連線重置)導致部署失敗,請使用升級權限重新執行(sandbox_permissions=require_escalated)。請勿升級初始的 CLI 可用性檢查 — 僅升級實際的部署指令。

給使用者的範例說明:

該部署需要升級的網路存取才能部署到 Vercel。我可以使用升級權限重新執行指令
— 要我繼續嗎?

CLI 認證失敗

如果 vercel login 或 vercel deploy 因認證錯誤而失敗,請回退到無認證部署腳本(視環境而定為 claude.ai 或 Codex 變體)。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

alfathafp/portofolio-web-design

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).

alfathafp/portofolio-web-design

Tests in real browsers via Chrome DevTools MCP. Use when building or debugging anything that runs in a browser. Use when you need to inspect the DOM, capture console errors, analyze network requests, profile performance, or verify visual output with real runtime data. Requires the chrome-devtools MCP server to be configured.

alfathafp/portofolio-web-design

Automates CI/CD pipeline setup. Use when setting up or modifying build and deployment pipelines. Use when you need to automate quality gates, configure test runners in CI, or establish deployment strategies.

alfathafp/portofolio-web-design

Conducts multi-axis code review. Use before merging any change. Use when reviewing code written by yourself, another agent, or a human. Use when you need to assess code quality across multiple dimensions before it enters the main branch. Use when asked to review a diff or a pull request, even when the diff is pasted inline.

alfathafp/portofolio-web-design

Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.

alfathafp/portofolio-web-design

Establishes a project's quality bar as a written contract and stops agents quietly lowering it. Interviews the user on which dimensions matter, supplies sane default thresholds when they have no number in mind, records everything in CONSTRAINTS.md, and watches the diff for a weakened bar — new @ts-ignore or eslint-disable suppressions, skipped or deleted tests, assertions stripped out, unimplemented stubs, thresholds edited down. Use when no quality bar is written down, when the user says "set up constraints" or "define our standards", when the user wants dimensions they care about — accessibility, web performance, coverage — set up as enforced constraints, when an agent keeps silencing checks or skipping tests to get to green, when you need a coverage or performance threshold and don't know what number to pick, or when an agent writes more code than anyone will read.

alfathafp/portofolio-web-design

Optimizes agent context setup. Use when starting a new session, when agent output quality degrades, when switching between tasks, or when you need to configure rules files and context for a project.

alfathafp/portofolio-web-design

Guides systematic root-cause debugging. Use when tests fail, builds break, something that worked yesterday broke, behavior doesn't match expectations, or you encounter any unexpected error. Use when you need to figure out what broke and why — a systematic approach to finding and fixing the root cause rather than guessing.

alfathafp/portofolio-web-design

Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.

alfathafp/portofolio-web-design

Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.

alfathafp/portofolio-web-design

Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies

alfathafp/portofolio-web-design

Records decisions and documentation. Use when you need to document an architecture decision (ADR) or the reasoning behind a design choice, when changing public APIs, shipping features, or when you need to record context that future engineers and agents will need to understand the codebase.

alfathafp/portofolio-web-design

Subjects every non-trivial decision to a fresh-context adversarial review before it stands. Use when you want every assumption cross-examined before proceeding, when stress-testing a plan for hidden failure modes, when correctness matters more than speed, when working in unfamiliar code, when stakes are high (production auth, security-sensitive logic, a high-stakes migration, irreversible operations), or any time a confident output would be cheaper to verify now than to debug later.

alfathafp/portofolio-web-design

Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available

alfathafp/portofolio-web-design

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work

alfathafp/portofolio-web-design

Builds production-quality, accessible, responsive user-facing UIs. Use when building or modifying interfaces and pages, creating components, implementing layouts, meeting WCAG accessibility requirements, managing state, or when the output needs to look and feel production-quality rather than AI-generated.

alfathafp/portofolio-web-design

Structures git workflow practices. Use when making any code change. Use when committing, branching, resolving conflicts, splitting uncommitted work in a messy working tree into clean atomic commits, opening or reviewing a pull request (PR), pushing to a remote, or when you need to organize work across multiple parallel streams. Use when cutting a release, choosing a semantic version bump, tagging, or writing a changelog.

alfathafp/portofolio-web-design

Refines raw ideas into sharp, actionable concepts through structured divergent and convergent thinking. Use when an idea is still vague, when you need to stress-test assumptions before committing to a plan, or when you want to expand options before converging on one. Triggers on "ideate", "refine this idea", or "stress-test my plan".

alfathafp/portofolio-web-design

Delivers changes incrementally in thin, verifiable slices. Use when implementing any feature or change that touches more than one file, or when picking up the next task from a plan. Use when rolling a change out behind a feature flag, when you're about to write a large amount of code at once, or when a task feels too big to land in one step.

alfathafp/portofolio-web-design

Guides stable API and interface design. Use when designing APIs, module boundaries, or any public interface. Use when creating REST or GraphQL endpoints, defining type contracts between modules, or establishing boundaries between frontend and backend.

相關技能