Communitygithub.com

alfathafp/portofolio-web-design

使用基於令牌的身份驗證在 Vercel 上部署和管理專案。當需要透過存取令牌而非互動式登入來使用 Vercel CLI 時使用,例如「部署到 Vercel」、「設定 Vercel」、「將環境變數新增到 Vercel」。

portofolio-web-design 是什麼?

此技能(alfathafp/portofolio-web-design)提供了一個使用 Vercel CLI 且搭配令牌(Token)進行非互動式驗證的完整工作流程。它能讓 AI 代理無需 `vercel login` 指令即可安全地完成部署、管理環境變數、檢查部署狀態以及設定網域等操作。技能會自動從環境變數或 `.env` 檔案中尋找 `VERCEL_TOKEN`,並優先使用 `VERCEL_ORG_ID` 與 `VERCEL_PROJECT_ID` 來避免互動式連結。它支援快速部署(環境變數已設定的情況)以及完整部署流程(需要連結專案),並始終以預覽(Preview)部署為預設值,除非使用者明確要求生產環境。技能還涵蓋了 Stripe Projects 的套餐變更管理、常見問題排錯(如令牌失效、團隊錯誤、建置失敗)以及明確的工作協議,例如絕不將令牌作為 `--token` 參數傳遞,以及推送程式碼前需獲得使用者同意。此技能主要設計用於 Cursor、Claude Code 或 Codex 等 AI 編碼代理,透過自動化繁瑣的設定步驟並強化安全性來提升開發效率。

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

在你喜歡的 AI 中提問

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

說明文件

使用令牌的 Vercel CLI

透過 CLI 搭配基於令牌的身份驗證來部署和管理 Vercel 上的專案,無需依賴 vercel login。

步驟 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 參數傳遞。將機密資訊放在指令行引數中會暴露在 shell 歷史記錄和程序列表中。

# 不好的做法 — 令牌在 shell 歷史記錄和程序列表中可見
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_ID 與 VERCEL_PROJECT_ID,請將它們匯出 — CLI 將自動使用這些值,並跳過任何 .vercel/ 目錄:

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

注意:VERCEL_ORG_ID 與 VERCEL_PROJECT_ID 必須同時設定 — 僅設定其中一個會導致錯誤。

CLI 設定

確保 Vercel CLI 已安裝且是最新版本:

npm install -g vercel
vercel --version

部署專案

除非使用者明確要求,否則一律部署為預覽版本。根據您擁有的資訊選擇一種方法。

快速部署(擁有專案 ID — 無需連結)

當環境中已設定 VERCEL_TOKEN 和 VERCEL_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.json 中的 orgId 以確認它與預期的團隊相符。

連結後部署

A) Git Push 部署 — 有 git 遠端(首選)

Git 推送會觸發自動的 Vercel 部署。

  1. 在推送之前詢問使用者。 未經明確批准,絕不推送。
  2. 提交並推送:
    git add .
    git commit -m "deploy: <變更的描述>"
    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 push(如果您有推送權限)或 CLI 部署。

關於 .vercel/ 目錄

一個已連結的專案會有以下兩種情況之一:

  • .vercel/project.json — 來自 vercel link。包含 projectId 和 orgId。
  • .vercel/repo.json — 來自 vercel link --repo。包含 orgId、remoteName 以及一個 projects 對應。

當環境中同時設定了 VERCEL_ORG_ID 與 VERCEL_PROJECT_ID 時,則不需要此目錄。

不要在未連結的目錄中執行 vercel project inspect 或 vercel link 來偵測狀態 — 它們會互動式地提示或作為副作用默默地連結。vercel ls 是安全的(在未連結的目錄中,它預設會顯示該範圍的所有部署)。vercel whoami 在任何地方都是安全的。

管理環境變數

# 為所有環境設定
echo "value" | vercel env add VAR_NAME --scope <team-slug>

# 為特定環境設定(production, preview, development)
echo "value" | vercel env add VAR_NAME production --scope <team-slug>

# 列出環境變數
vercel env ls --scope <team-slug>

# 將環境變數拉取到本地的 .env.local 檔案
vercel env pull --scope <team-slug>

# 移除一個變數
vercel env rm VAR_NAME --scope <team-slug> -y

檢查部署

# 列出最近的部署
vercel ls --format json --scope <team-slug>

# 檢查特定部署
vercel inspect <deployment-url>

# 檢視建置日誌(需要 Vercel CLI v35+)
vercel inspect <deployment-url> --logs

# 檢視執行時期請求日誌(預設會持續跟蹤;加上 --no-follow 取得一次性快照)
vercel logs <deployment-url>

管理網域

# 列出網域
vercel domains ls --scope <team-slug>

# 將網域新增到專案 — 已連結或透過環境變數連結的目錄(1 個引數)
vercel domains add <domain> --scope <team-slug>

# 新增網域 — 未連結的目錄(需要 <project> 位置引數)
vercel domains add <domain> <project> --scope <team-slug>

Stripe Projects 套餐變更

如果此專案是由 Stripe Projects 管理的。在執行任何付費或破壞性套餐變更之前,先詢問使用者 — 升級會向真實的信用卡收費,降級則會移除席位。

首先執行 stripe projects status --json 以確認 Vercel 資源的本地名稱。以下範例假設使用預設名稱(vercel-plan);如果該名稱在 stripe projects add 時被重新命名,請替換為實際名稱。

  • 升級到 Pro: stripe projects add vercel/pro(或 stripe projects upgrade vercel-plan pro)
  • 降級到 Hobby: stripe projects downgrade vercel-plan hobby

Pro 方案提供的功能

  • 每月 $20 美元的平台費用,包含每月 $20 美元的使用額度。
  • 新專案預設使用 Turbo 建置機器(30 vCPU,60 GB 記憶體)— 比 Hobby 方案建置速度顯著更快。
  • 1 個部署席位 + 無限的免費檢視者席位(唯讀協作者、預覽評論)。
  • 更高的包含配額(每月 1 TB 快速資料傳輸、1000 萬個 Edge 請求)。
  • 可用的付費附加功能:SAML SSO、HIPAA BAA、Flags Explorer、Observability Plus、Speed Insights、Web Analytics Plus。

完整詳細資訊:https://vercel.com/docs/plans/pro-plan

工作協議

  • 絕不將 VERCEL_TOKEN 作為 --token 參數傳遞。 將它匯出為環境變數,讓 CLI 原生地讀取它。
  • 在詢問使用者之前,先檢查環境中的令牌。 首先檢查目前的環境和 .env 檔案。
  • 預設使用預覽部署。 僅在使用者明確要求時才部署到生產環境。
  • 在推送 git 之前先詢問。 未經使用者批准,絕不推送提交。
  • 不要直接修改 .vercel/ 檔案。 CLI 管理此目錄。讀取它們(例如驗證 orgId)是可以的。
  • 不要使用 curl/fetch 來驗證已部署的 URL。 只需將連結回傳給使用者。
  • 當結構化輸出有助於後續步驟時,使用 --format json。
  • 在會提示確認的指令上使用 -y,以避免互動式阻塞。

故障排除

找不到令牌

檢查環境和任何存在的 .env 檔案:

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

驗證錯誤

如果 CLI 因 Authentication required 而失敗:

  • 令牌可能已過期或無效。
  • 驗證:vercel whoami(使用環境中的 VERCEL_TOKEN)。
  • 向使用者請求一個新的令牌。

錯誤的團隊

確認範圍是否正確:

vercel whoami --scope <team-slug>

建置失敗

檢查建置日誌:

vercel inspect <deployment-url> --logs

常見原因:

  • 缺少相依套件 — 確保 package.json 完整且已提交。
  • 缺少環境變數 — 使用 vercel env add 新增。
  • 框架設定錯誤 — 檢查 vercel.json。Vercel 會從 package.json 自動偵測框架(Next.js、Remix、Vite 等);如果偵測錯誤,可以透過 vercel.json 覆寫。

CLI 未安裝

npm install -g vercel

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

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

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

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.

相關技能