tech/cloudflare

CLOUDFLARE

Cloudflare platform skills. Use skills in this domain when:

production Cloudflare Workers, Cloudflare Pages, Wrangler CLI
improves: tech

Cloudflare Platform

The 2nth.ai deployment substrate. All client applications and platform services run on Cloudflare's edge network.

Core Services

ServiceTierPurpose2nth Usage
workersFree/PaidEdge compute (JS/TS)API logic, agent runtimes
pagesFreeStatic + FunctionsFrontend deployments, skills catalog
d1Free/PaidSQLite at the edgePer-client databases
kvFree/PaidKey-value storeSessions, feature flags, caching
r2Free/PaidObject storageDocuments, assets, zero egress
durable-objectsPaidStateful computeWebSockets, per-entity locks
queuesPaidReliable messagingAsync AI inference, webhook ingestion
workflowsPaid (beta)Durable multi-step executionAI pipeline orchestration
workers-aiFree/PaidEdge inferenceIntent routing, embeddings
ai-gatewayFree/PaidAI control planeToken metering, caching, fallback
vectorizePaidVector databaseRAG for skill retrieval
hyperdrivePaidDB connection poolingClient SOR (Postgres/MySQL) access
analytics-engineIncludedTime-series metricsToken economy, billing reports
emailFreeInbound/outbound emailPenny briefings, client intake
tunnelFreeSecure outbound connectorOn-premise SOR access
workers-for-platformsPaidMulti-tenant Worker executionFuture: client plugin namespaces

Common Commands

wrangler pages dev ./public          # local dev (Pages)
wrangler dev                         # local dev (Worker)
wrangler pages deploy ./public       # deploy Pages
wrangler deploy                      # deploy Worker
wrangler d1 execute DB --file=migrations/0001_initial.sql --local
wrangler d1 execute DB --file=migrations/0001_initial.sql --remote
wrangler secret put SECRET_NAME      # set encrypted secret

wrangler.toml Pattern

name = "project-name"
compatibility_date = "2024-12-01"
compatibility_flags = ["nodejs_compat"]

[[d1_databases]]
binding = "DB"
database_name = "project-db"
database_id = "your-d1-id"

[[kv_namespaces]]
binding = "KV"
id = "your-kv-id"

[ai]
binding = "AI"

[[r2_buckets]]
binding = "R2"
bucket_name = "project-bucket"

D1 Migration Convention

migrations/
  0001_initial.sql
  0002_add_indexes.sql
  0003_descriptive_name.sql

Never modify existing migrations. Always add new files.

Workers AI — Edge Routing Pattern

const response = await env.AI.run('@cf/meta/llama-3.1-8b-instruct', {
  messages: [
    { role: 'system', content: 'Classify intent. Reply with one word: erp | crm | general' },
    { role: 'user', content: userMessage }
  ],
  max_tokens: 10
});
// Fast, zero-latency classification at the edge
// Then route to Claude via AI Gateway for depth

Common Gotchas

See Also