Cloudflare Workers & Edge AI Development
БесплатноБез исполняемых скриптовНе проверенBuild ultra-low-latency edge computing applications with Cloudflare Workers, Workers AI for LLM inference, V8 isolates, Durable Objects, and serverless…
от bobmatnyc★ 19 звёзд на GitHubОб этом скилле
Cloudflare Workers & Edge AI Development
Overview
Master Cloudflare Workers - the fastest serverless platform with <1ms cold starts and Workers AI for running LLMs at the edge. Deploy across 330+ data centers globally for ultra-low-latency applications that run close to your users.
When to Use This Skill
- Building globally distributed APIs with <50ms latency
- Running AI/LLM inference at the edge (Workers AI)
- Creating serverless backends without managing infrastructure
- Implementing edge middleware (auth, rate limiting, A/B testing)
- Building real-time collaborative applications (Durable Objects)
- Processing high-traffic workloads cost-effectively
- Deploying static sites with dynamic edge logic
Core Principles
1. V8 Isolates (Not Containers)
Workers run in V8 isolates - much faster than containers
// Basic Worker structure
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
// ✅ <1ms cold start (V8 isolate, not container!)
// ✅ Runs in 330+ locations automatically
// ✅ 0ms warm start (keeps isolate alive)
return new Response("Hello from the edge!", {
headers: { "Content-Type": "text/plain" }
});
}
};
// WRONG: Don't use Node.js APIs (not available)
// import fs from 'fs'; // ❌ No filesystem
// process.env.VAR; // ❌ No process object
// CORRECT: Use Workers APIs
const value = env.MY_KV_NAMESPACE.get("key"); // ✅ KV storage
const response = await fetch("https://api.example.com"); // ✅ fetch API
Key Differences from Node.js/Lambda:
- ❌ No filesystem access
- ❌ No Node.js built-ins (fs, http, crypto from Node)
- ✅ Web Standard APIs (fetch, Request, Response, WebSockets)
- ✅ Sub-millisecond cold starts
- ✅ No VPC configuration needed
2. Workers AI - LLM Inference at the Edge
// Run LLaMA 2, Mistral, or other models at the edge
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const { prompt } = await request.json();
// Text generation with LLaMA 2
const response = await env.AI.run("@cf/meta/llama-2-7b-chat-int8", {
messages: [
{ role: "system", content: "You are a helpful assistant" },
{ role: "user", content: prompt }
]
});
return Response.json(response);
}
};
// Image generation
const image = await env.AI.run("@cf/stabilityai/stable-diffusion-xl-base-1.0", {
prompt: "A futuristic city at sunset"
});
// Text embeddings (for vector search)
const embeddings = await env.AI.run("@cf/baai/bge-base-en-v1.5", {
text: "Hello, world!"
});
// Image classification
const result = await env.AI.run("@cf/microsoft/resnet-50", {
image: imageBytes
});
Workers AI Benefits:
- 🚀 <50ms inference latency globally
- 💰 Pay only for inference time (no idle costs)
- 🌍 Runs in 330+ locations automatically
- 🔒 Data never leaves Cloudflare's network
3. KV Storage for Edge Data
// wrangler.toml
# kv_namespaces = [
# { binding = "MY_KV", id = "xxxxx", preview_id = "yyyyy" }
# ]
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const url = new URL(request.url);
const key = url.pathname.slice(1);
// Read from KV (eventually consistent)
const value = await env.MY_KV.get(key);
if (value === null) {
return new Response("Not found", { status: 404 });
}
// Write to KV
await env.MY_KV.put("user:123", JSON.stringify({ name: "Alice" }), {
expirationTtl: 3600, // Expire in 1 hour
metadata: { createdAt: Date.now() }
});
// List keys
const list = await env.MY_KV.list({ prefix: "user:" });
// Delete key
await env.MY_KV.delete(key);
return new Response(value);
}
};
KV Best Practices:
- ✅ Use for read-heavy workloads (caching, config)
- ✅ Values up to 25 MB
- ✅ Eventually consistent (may take 60s to propagate)
- ❌ Not for transactional data or immediate consistency
4. Durable Objects for Stateful Logic
// Durable Object - Single-instance, strongly consistent storage
export class RateLimiter {
state: DurableObjectState;
constructor(state: DurableObjectState, env: Env) {
this.state = state;
}
async fetch(request: Request) {
const count = (await this.state.storage.get("count")) || 0;
const newCount = count + 1;
if (newCount > 100) {
return new Response("Rate limit exceeded", { status: 429 });
}
await this.state.storage.put("count", newCount);
return new Response(`Request ${newCount}/100`);
}
}
// Worker that uses Durable Object
export default {
async fetch(request: Request, env: Env): Promise<Response> {
// Get Durable Object instance (one per user)
const id = env.RATE_LIMITER.idFromName("user:123");
const stub = env.RATE_LIMITER.get(id);
// Forward request to Durable Object
return stub.fetch(request);
}
};
// wrangler.toml
# durable_objects.bindings
# na
Установить Cloudflare Workers & Edge AI Development в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Cloudflare Workers & Edge AI Development?
Build ultra-low-latency edge computing applications with Cloudflare Workers, Workers AI for LLM inference, V8 isolates, Durable Objects, and serverless patterns deployed across 330+ data centers worldwide
Как установить скилл Cloudflare Workers & Edge AI Development?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Cloudflare Workers & Edge AI Development запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic