wrangler

作者: Cloudflare

Cloudflare Workers CLI,用於部署、開發及管理 Workers、KV、R2、D1、Vectorize、Hyperdrive、Workers AI、Containers、Queues、Workflows、Pipelines 與 Secrets Store。在執行 wrangler 指令前載入,以確保正確語法與最佳實踐。

npx skills add https://github.com/cloudflare/skills --skill wrangler

Wrangler CLI

Use the project's Wrangler version and retrieve the relevant documentation before writing commands or configuration. CLI flags and configuration fields change; do not rely on memorized examples.

Inspect the Project

  • Find the package manager, installed Wrangler version, package scripts, framework, and Wrangler config. Run commands through the project's scripts or package manager so they use its local version. Install dependencies using the existing lockfile when needed; do not silently upgrade Wrangler to match current docs. If Wrangler is not a dependency, follow the installation guide to add it locally.
  • Identify the config used by the build or deploy command, including framework-generated config. Edit its source rather than generated output.
  • Establish the target account, Worker, environment, and resource before running commands that change them. For data operations, determine whether the target is local or remote.

Retrieve What the Task Needs

Use the Cloudflare MCP docs tool if available, or fetch the relevant linked page directly. Follow links to the specific command or product involved; avoid loading the entire reference. If a page moves, rediscover it through the Wrangler command index or Cloudflare docs search.

TaskSource
Discover commands and flags, including resource management, deployments, rollback, and diagnosticsProject-local wrangler --help and wrangler <command> --help; command reference
Edit config or add a bindingInstalled wrangler/config-schema.json (usually under node_modules); configuration reference
Deploy a framework applicationFramework guides; follow the guide for the project's existing framework and adapter
Migrate an application to Workers when requestedPages to Workers; Vercel to Workers
Configure staging or productionEnvironments
Set secrets locally, in CI, or on a deployed WorkerSecrets
Generate binding and runtime typesTypeScript
Run locally or choose a testing approachLocal development; testing
Diagnose authentication or select an accountGeneral commands, including whoami; authentication profiles
Deploy an unauthenticated prototypeClaim deployments for eligibility, expiry, and claim URL handling; use a permanent account for production or CI

Use installed help and schema to check whether documented features exist in the project's version. If a required feature needs an upgrade, make that dependency explicit. If retrieval is unavailable, state the gap and use available local evidence rather than inventing syntax.

Apply the Change

  • Prefer wrangler.jsonc for new config. Set a new project's compatibility date to today; review runtime changes and test when advancing an existing project's date. Preserve existing project conventions and avoid incidental format migrations.
  • Check environment inheritance before adding bindings or variables. Some fields must be specified separately for each environment; a working default config does not establish that staging is configured.
  • With the Cloudflare Vite plugin, select the environment via CLOUDFLARE_ENV at dev or build time. Deploy the resulting build; setting an environment at deploy time does not retarget its flattened config. See Vite environments.
  • Reconcile dashboard changes with the config before deploying: Wrangler can overwrite dashboard variables and routes. When binding existing resources, verify their identifiers; omitted identifiers can trigger automatic provisioning.
  • Distinguish local simulation from remote bindings during development. A locally running Worker can still access real resources; check the selected bindings before testing writes.
  • Keep secret values out of command arguments, source code, and logs. Use the documented interactive input or protected file/stdin mechanism for the command. Local secret files must be ignored by version control and are not automatically uploaded as deployed secrets. For missing local secrets, check file precedence and any secrets.required declaration in the secrets docs.
  • Treat wrangler secret put and secret delete as deployments: they create a version and deploy it immediately. Use the documented wrangler versions secret workflow when the change must be staged.
  • Before a rollback, check rollback limitations: connected resources and their data are not rolled back with Worker code.

Validate

After changing config or bindings in a TypeScript project, regenerate types with the project's wrangler types command rather than hand-editing generated declarations. Run the relevant existing typecheck or tests.

For deployment changes, use the project's build workflow and wrangler deploy --dry-run where supported, with the intended config and environment. A successful dry run checks the build and packaging; it does not prove remote resources or runtime behavior work. Use task-specific local or remote checks as appropriate to the requested work.

Report what changed, the target environment, checks performed, and any unresolved validation gaps. Link the documentation used when the result depends on current command or configuration behavior.

來自 Cloudflare 的更多技能

agents-sdk
Cloudflare
在 Cloudflare Workers 上使用 Agents SDK 建置 AI 代理。建立有狀態代理、持久化工作流程、即時 WebSocket 應用程式、排程任務、MCP 伺服器或聊天應用程式時載入。涵蓋 Agent 類別、狀態管理、可呼叫 RPC、Workflows 整合及 React hooks。
building-ai-agent-on-cloudflare
Cloudflare
在 Cloudflare 上使用 Agents SDK 建置 AI 代理,具備狀態管理、即時 WebSocket、排程任務、工具整合及聊天功能。產生可部署至 Workers 的正式環境代理程式碼。 適用時機:使用者想「建置代理」、「AI 代理」、「聊天代理」、「有狀態代理」,提及「Agents SDK」,需要「即時 AI」、「WebSocket AI」,或詢問代理的「狀態管理」、「排程任務」或「工具呼叫」。
development
building-mcp-server-on-cloudflare
Cloudflare
在 Cloudflare Workers 上建置遠端 MCP(模型上下文協定)伺服器,包含工具、OAuth 驗證與正式環境部署。可產生伺服器程式碼、設定驗證提供者,並部署至 Workers。 使用時機:使用者提及「建置 MCP 伺服器」、「建立 MCP 工具」、「遠端 MCP」、「部署 MCP」、為 MCP 加入「OAuth」,或提到 Cloudflare 上的模型上下文協定。亦會觸發於「MCP 驗證」或「MCP 部署」。
development
cloudflare
Cloudflare
涵蓋 Cloudflare 平台的完整技能,包括 Workers、Pages、儲存(KV、D1、R2)、AI(Workers AI、Vectorize、Agents SDK)、網路(Tunnel、Spectrum)、安全(WAF、DDoS)以及基礎設施即程式碼(Terraform、Pulumi)。適用於任何 Cloudflare 開發任務。
durable-objects
Cloudflare
建立與審查 Cloudflare Durable Objects。適用於建構有狀態的協調機制(聊天室、多人遊戲、預訂系統)、實作 RPC 方法、SQLite 儲存、警報、WebSocket,或審查 DO 程式碼以符合最佳實務。涵蓋 Workers 整合、wrangler 設定,以及使用 Vitest 進行測試。
sandbox-sdk
Cloudflare
為安全程式碼執行建置沙盒應用程式。在建立AI程式碼執行、程式碼直譯器、CI/CD系統、互動式開發環境或執行不受信任的程式碼時載入。涵蓋Sandbox SDK生命週期、指令、檔案、程式碼直譯器及預覽URL。
web-perf
Cloudflare
使用 Chrome DevTools MCP 分析網頁效能。測量核心網頁指標(FCP、LCP、TBT、CLS、速度指數),識別渲染阻塞資源、網路依賴鏈、版面位移、快取問題及無障礙缺口。當被要求稽核、剖析、除錯或優化頁面載入效能、Lighthouse 分數或網站速度時使用。
workers-best-practices
Cloudflare
審查並指導 Cloudflare Workers 程式碼遵循生產最佳實踐。在撰寫新的 Workers、審查 Worker 程式碼、設定 wrangler.jsonc,或檢查常見的 Workers 反模式(串流、懸浮承諾、全域狀態、機密、綁定、可觀測性)時載入。傾向從 Cloudflare 文件檢索,而非依賴預先訓練的知識。