Cloudflare workers do deploy
Skill bokuwalily/claude-code-skills/skills/cloudflare-workers-do-deploy
Cloudflare Workers + Durable Objects + D1 + 静的アセット(SPA)を無料で本番デプロイする時。wrangler login後の手順とハマりどころ(サブドメイン変更・証明書待ち・secret衝突・無料DO)に使うFrom its SKILL.md
npx -y skills add bokuwalily/claude-code-skills --skill cloudflare-workers-do-deployAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
3.7 KB, ~1.2k tokens by cl100k_base, as published. Nobody here has run it
Procedure
Cloudflare全部入り(Workers + Durable Objects + D1 + SPAアセット)の本番化手順。実例=中の人AI(~/dev/nakanohito-ai)。
- 無料DO設定:
wrangler.tomlの `` にnew_sqlite_classes = ["ClassA",...]を指定(SQLite backendのDOは無料プランで$0。new_classesだとWorkers Paid要求になり得る)。[assets] directory/binding/not_found_handling="single-page-application"でSPA同居。 - ログイン(対話/本人):
! npx wrangler login(ブラウザOAuth。Claudeから不可)。 - D1作成→id差替:
npx wrangler d1 create <db>→ 出力database_idをwrangler.tomlの `` に貼る。 - 本番マイグレ:
npx wrangler d1 migrations apply <db> --remote(非対話でも fallback yes で進む)。 - 初回デプロイの前提: アカウントにworkers.devサブドメイン未作成だと
ERROR 10063で落ちる→ダッシュボードの Workers & Pages を一度開くと自動作成。 - デプロイ:
npm run deploy(= フロントbuild &&wrangler deploy)。URL=<worker名>.<アカウントサブドメイン>.workers.dev。 - secret投入:
printf '%s' "$VALUE" | npx wrangler secret put NAME(値は画面に出さない)。 - 検証:
curl https://.../api/health→ 本番E2E(test/e2e.mjsをHTTPS/WSSに差し替えて実行)→ テストデータをwrangler d1 execute <db> --remote --command "DELETE FROM ..."で一掃。
Pitfalls
- サブドメインに個人情報が乗る: アカウントサブドメインは初期値がメール由来(例
your-handle)。公開URLに旧ハンドルが出る→ダッシュボード「Change account subdomain」でブランド名に変更。⚠️APIの PUT/accounts/{id}/workers/subdomainは既存だと10036で変更不可=GUI必須。⚠️アカウント単位=全Workerが*.<新サブドメイン>.workers.devになるのでアプリ名でなくブランド名(例bokuwalily)にする。 - 新サブドメインのTLS証明書発行に10〜15分。
digは引けるのにcurlがsslv3 alert handshake failure / http_code=000になる=証明書待ち。deploy自体は証明書と無関係に成功するので、待つ間に sitemap/GA4/secret 等を進める。証明書発行直後の初回WS接続もコールドスタートで数分遅い(E2Eが2分超過しても少し後に再実行で通る)。 - var と secret の名前衝突:
wrangler.toml [vars] NAME=""を残したままsecret put NAMEすると10053 Binding name already in use。→ tomlから該当varを消して再デプロイしてから secret put。 wrangler subdomainコマンドは非推奨(deprecated)。サブドメイン操作はGUIへ。- 委譲の空振り: フロント等を
codex execに投げると banner出力のみ・exit0でもファイル0のことがある→git status/findで実体確認、空ならSonnetサブエージェントへフォールバック。
Verification
curl -s https://<url>/api/health→{"ok":true}- 本番E2Eスクリプト全PASS(WS往復+永続状態)
wrangler d1 execute <db> --remote --json --command "SELECT count(*) ..."で本番テストデータが0- secret:
wrangler secret listに登録名が出る/webhook等はリポにcommitされていない(grep -r 'webhooks' src webが空)
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.