cloud-native-cloudflare-workers
Use when the user asks about Cloudflare Workers, wrangler, Durable Objects, Workers KV, D1, R2, Queues, V8 isolates, or running code at the edge. Produces…
от j4flmao★ 47 звёзд на GitHub
Установить cloud-native-cloudflare-workers в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Cloudflare Workers and V8 Isolates
Purpose
Run request-path logic close to users on Cloudflare's network. Workers use V8 isolates rather than per-function VMs or containers, which makes startup cheap but imposes a Web-standard runtime with CPU and memory limits; storage choice drives consistency and latency.
Agent Protocol
Trigger
"cloudflare workers", "v8 isolates", "edge function", "wrangler", "durable objects", "workers kv", "D1", "R2", "edge compute".
Input Context
- Workload: request rewriting/auth, API, full-stack app, websockets, scheduled jobs.
- Data needs: read-heavy config, relational queries, blobs, strongly consistent per-key state.
- Node.js library dependencies.
Output Artifact
wrangler.toml/wrangler.jsonc and Worker code. No file unless requested.
Response Format
Runtime fit: {ok|needs nodejs_compat|not a fit (why)}
Storage: {KV|D1|R2|Durable Objects|Queues|Hyperdrive} (why)
Consistency: {eventual|strong per object|...}
Limits to watch: {CPU ms, memory, subrequests}
Completion Criteria
- Storage primitive matches the consistency requirement.
- Bindings declared in wrangler config; secrets via
wrangler secret put. - No blocking/long CPU work in the request path.
Isolates vs MicroVMs
| V8 isolate (Workers) | MicroVM (Lambda/Firecracker) | |
|---|---|---|
| Unit of isolation | Isolate (separate heap) inside a shared runtime process, plus process-level sandboxing | Dedicated lightweight VM with its own guest kernel |
| Startup | Milliseconds; Cloudflare also pre-warms during the TLS handshake | Tens of ms to seconds depending on runtime and init code |
| Runtime | Web-standard APIs (fetch, Request, Response, Web Crypto, Streams) + optional Node.js compatibility |
Full OS process, any language/binary |
| Memory | 128 MB per isolate | Up to 10,240 MB |
| Good for | Latency-sensitive request handling, auth, routing, APIs | Heavy compute, native binaries, long jobs |
Containers do not boot a kernel — they share the host kernel; Lambda's cost comes from booting a microVM, starting the language runtime, and running init code.
Storage Primitives
| Need | Use | Consistency |
|---|---|---|
| Read-heavy config, flags, sessions tolerant of staleness | Workers KV | Eventually consistent; writes can take up to ~60 s to be visible globally |
| Relational data, SQL | D1 (SQLite-based) | Strong on the primary; read replication optional |
| Large objects, user uploads | R2 (S3-compatible API, no egress fees) | Strong read-after-write |
| Per-key coordination: counters, rate limits, chat rooms, websockets | Durable Objects | Strongly consistent, single-threaded per object |
| Async work, retries | Queues | At-least-once |
| Existing Postgres/MySQL | Hyperdrive (pooling + caching) | Same as origin DB |
Example Worker (ES modules, TypeScript)
export interface Env {
CONFIG: KVNamespace;
DB: D1Database;
RATE_LIMITER: DurableObjectNamespace<RateLimiter>;
}
export default {
async fetch(req: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
const ip = req.headers.get("CF-Connecting-IP") ?? "unknown";
const limiter = env.RATE_LIMITER.get(env.RATE_LIMITER.idFromName(ip));
if (!(await limiter.allow())) return new Response("Too Many Requests", { status: 429 });
const url = new URL(req.url);
if (url.pathname.startsWith("/products/")) {
const id = url.pathname.split("/")[2];
const row = await env.DB.prepare("SELECT id, name, price FROM products WHERE id = ?")
.bind(id).first();
if (!row) return new Response("Not found", { status: 404 });
ctx.waitUntil(env.CONFIG.put(`last-viewed:${id}`, new Date().toISOString())); // after response
return Response.json(row);
}
return fetch(req); // pass through to origin
},
} satisfies ExportedHandler<Env>;
import { DurableObject } from "cloudflare:workers";
export class RateLimiter extends DurableObject {
async allow(): Promise<boolean> {
const now = Date.now();
const windowStart = (await this.ctx.storage.get<number>("windowStart")) ?? now;
let count = (await this.ctx.storage.get<number>("count")) ?? 0;
if (now - windowStart > 60_000) { count = 0; await this.ctx.storage.put("windowStart", now); }
if (count >= 100) return false;
await this.ctx.storage.put("count", count + 1);
return true;
}
}
# wrangler.toml
name = "shop-edge"
main = "src/index.ts"
compatibility_date = "2025-09-01"
compatibility_flags = ["nodejs_compat"]
kv_namespaces
binding = "CONFIG"
id = "<kv-namespace-id>"
d1_databases
binding = "DB"
database_name = "shop"
database_id = "<d1-database-id>"
durable_objects.bindings
name = "RATE_LIMITER"
class_name = "RateLimiter"
migrations
tag = "v1"
new_sqlite_classes = ["RateLimiter"]
Decision Rules
- Need strong consistency on a key → Durable Object, never KV.
- Fan-out to many origins → mind the subrequest limit per invocation (50 on Fr
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл cloud-native-cloudflare-workers?
Use when the user asks about Cloudflare Workers, wrangler, Durable Objects, Workers KV, D1, R2, Queues, V8 isolates, or running code at the edge. Produces Workers code and picks the right storage primitive within isolate limits. Not for CDN caching rules (use cdn-edge) or AWS Lambda (use cloud-native-aws-serverless).
Как установить скилл cloud-native-cloudflare-workers?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cloud-native-cloudflare-workers запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…