Cloudflare workers deploy

From clowlove/Hermes-House · View interactive version

Cloudflare workers deploy is an AI agent skill from the GitHub repository clowlove/Hermes-House. Deploy and manage Cloudflare Workers with D1, R2, KV, and Workers KV store

How to use this skill

Skill file

Cloudflare Workers Deployment

Workflow

Phase 1: Scout & Plan

  1. Clone/fetch the repo, read wrangler.toml and package.json
  2. Identify required Cloudflare resources (D1, R2, KV) and their bindings
  3. If resources don't exist yet, create them via REST API

Phase 2: Create Cloudflare Resources

# D1 Database
curl -s -X POST "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/d1/database" \
  -H "Authorization: Bearer $API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "database_name"}'

# R2 Bucket
curl -s -X POST "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/r2/buckets" \
  -H "Authorization: Bearer $API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "bucket-name"}'

# KV Namespace
curl -s -X POST "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/storage/kv/namespaces" \
  -H "Authorization: Bearer $API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title": "namespace-name"}'

Phase 3: Configure wrangler.toml

Update wrangler.toml with resource IDs:

[[d1_databases]]
binding = "DB"
database_name = "database_name"
database_id = "<uuid>"

[[kv_namespaces]]
binding = "STATIC_ASSETS"
id = "<uuid>"

Phase 4: Initialize Database

# Run SQL migrations (use --remote for production D1)
npx wrangler d1 execute database_name --file=schema/schema.sql --remote

Phase 5: Deploy

npx wrangler deploy

KV Settings Pattern (website_settings)

Many CF Workers projects store site config in KV as JSON. This pattern recurs in B2B/ecommerce templates.

Correct way to write JSON to KV:

# Must use --path <file>, NOT stdin/heredoc — wrangler reads value from file
echo '{"site_name":"...","email":"..."}' > /tmp/settings.json
npx wrangler kv key put "website_settings" --path /tmp/settings.json --namespace-id <uuid> --remote

Pitfalls

Verification

curl -sLo /dev/null -w "%{http_code}" "https://worker.workers.dev/"
curl -s "https://worker.workers.dev/api/settings"

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.