roedyrustam/vibes-plug/cloudflare-workers-expert

Claude Code and agent skill by roedyrustam/vibes-plug

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Cloudflare Workers ecosystem: D1, KV, R2, Queues, Durable Objects / Ekosistem Cloudflare Workers: D1, KV, R2, Queues, Durable Objects.

Install

npx vskill@latest install roedyrustam/vibes-plug/cloudflare-workers-expert

SKILL.md

The same SKILL.md was published earlier as roedyrustam/vibes-plug/cloudflare-workers-expert.

Cloudflare Workers Ecosystem Expert (2026 Edition)

English | Bahasa Indonesia


<a name="english"></a>

English

Orchestration & Integration

Connects and orchestrates with domain skills:

  • Edge Backend & APIs: js-backend-expert (Hono v4 on Workers, V8 isolates), api-design-expert (edge REST & RPC endpoints), and sse-websocket-streaming-expert (Durable Objects WebSockets).
  • Edge Storage & DBs: database-orm-expert (Drizzle with D1, Hyperdrive pooling), file-upload-media-expert (R2 presigned URLs), and vector-db-rag-expert (Vectorize & Workers AI).
  • Frontend & Cloud: cloud-hosting-expert (custom domains, CDN rules), senior-frontend (Workers Static Assets), and anti-slop (clean edge architecture without node:fs polyfill traps).
  • Lifecycle & DevOps: ci-cd-devops-architect (GitHub Actions Wrangler deployments), brainstorming, and zero-to-prod-orchestrator (Phase 4: Backend & APIs).
Description

Expert guide for building full-stack edge applications using the Cloudflare Workers ecosystem. Covers Workers runtime, D1 (SQLite at edge), KV (key-value store), R2 (S3-compatible object storage), Queues (message queues), Durable Objects (stateful edge), Hyperdrive (database connection pooling), Workers AI (inference at edge), and Wrangler CLI for development and deployment.

Trigger Conditions
  • Building serverless edge applications on Cloudflare Workers.
  • Using D1 as an edge SQLite database.
  • Storing files with R2 (S3-compatible, zero egress fees).
  • Implementing KV for distributed key-value caching.
  • Building stateful applications with Durable Objects.
  • Setting up Queues for async job processing at the edge.
  • Connecting to external databases via Hyperdrive connection pooling.
  • Running AI inference at the edge with Workers AI.
  • Deploying with Wrangler CLI and wrangler.toml configuration.
  • Using Hono v4 as the web framework on Workers.
What's New in 2026
Cloudflare Workers — Platform Updates
  • D1 GA: SQLite at the edge — fully production-ready with point-in-time recovery, read replicas, and up to 10GB databases.
  • Queues GA: Reliable message queues for async processing, dead letter queues, and batch consumption.
  • Hyperdrive GA: Connection pooling for PostgreSQL, MySQL — eliminates cold connection latency from Workers.
  • Workers AI Stable: Run LLM inference (Llama 3, Mistral, embedding models) at the edge with zero cold starts.
  • Durable Objects Hibernation: Cost-effective stateful edge — objects hibernate when idle, wake instantly on request.
  • Workers Static Assets: Serve static files directly from Workers without separate Pages deployment.
  • Node.js Compatibility Mode: Import Node.js built-in modules (node:crypto, node:buffer, node:streams) directly in Workers.
Core Architecture Patterns
1. Project Setup (Wrangler + Hono)
bash
# Create new Workers project with Hono
npm create cloudflare@latest my-app -- --framework=hono
cd my-app
# wrangler.toml configuration
toml
# wrangler.toml
name = "my-app"
compatibility_date = "2026-10-01"
compatibility_flags = ["nodejs_compat_v2"]
# D1 Database
[[d1_databases]]
binding = "DB"
database_name = "my-app-db"
database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
# KV Namespace
[[kv_namespaces]]
binding = "CACHE"
id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# R2 Bucket
[[r2_buckets]]
binding = "STORAGE"
bucket_name = "my-app-assets"
# Queue Producer
[[queues.producers]]
queue = "email-queue"
binding = "EMAIL_QUEUE"
# Queue Consumer
[[queues.consumers]]
queue = "email-queue"
max_batch_size = 10
max_batch_timeout = 30
# Durable Object
[[durable_objects.bindings]]
name = "RATE_LIMITER"
class_name = "RateLimiter"
[[migrations]]
tag = "v1"
new_classes = ["RateLimiter"]
# Hyperdrive (PostgreSQL connection pooling)
[[hyperdrive]]
binding = "HYPERDRIVE"
id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Workers AI
[ai]
binding = "AI"
2. Hono Application on Workers
typescript
import { Hono } from 'hono';
import { cors } from 'hono/cors';
import { bearerAuth } from 'hono/bearer-auth';
type Bindings = {
DB: D1Database;
CACHE: KVNamespace;
STORAGE: R2Bucket;
EMAIL_QUEUE: Queue;
AI: Ai;
HYPERDRIVE: Hyperdrive;
};
const app = new Hono<{ Bindings: Bindings }>();
app.use('*', cors());
// D1 SQLite query
app.get('/api/products', async (c) => {
const { results } = await c.env.DB.prepare(
'SELECT id, name, price FROM products WHERE active = 1 ORDER BY created_at DESC LIMIT 50'
).all();
return c.json(results);
});
// KV cache-aside pattern
app.get('/api/config/:key', async (c) => {
const key = c.req.param('key');
const cached = await c.env.CACHE.get(key, 'json');
if (cached) return c.json(cached);
const { results } = await c.env.DB.prepare(
'SELECT value FROM config WHERE key = ?'
).bind(key).all();
if (results.length > 0) {
await c.env.CACHE.put(key, JSON.stringify(results[0]), { expirationTtl: 3600 });
return c.json(results[0]);
}
return c.notFound();
});
// R2 file upload
app.post('/api/upload', async (c) => {
const formData = await c.req.formData();
const file = formData.get('file') as File;
const key = `uploads/${Date.now()}-${file.name}`;
await c.env.STORAGE.put(key, file.stream(), {
httpMetadata: { contentType: file.type },
});
return c.json({ key, url: `/files/${key}` });
});
// Queue producer — send async job
app.post('/api/send-email', async (c) => {
const body = await c.req.json();
await c.env.EMAIL_QUEUE.send({
to: body.email,
subject: body.subject,
template: body.template,
});
return c.json({ status: 'queued' });
});
// Workers AI — text generation
app.post('/api/ai/generate', async (c) => {
const { prompt } = await c.req.json();
const response = await c.env.AI.run('@cf/meta/llama-3.1-8b-instruct', {
messages: [{ role: 'user', content: prompt }],
});
return c.json(response);
});
interface EmailJob {
to: string;
subject: string;
template: string;
}
async function sendEmail(to: string, subject: string, template: string): Promise<void> {
console.info(`[EmailWorker] Dispatched template=${template} to=${to} subject=${subject}`);
}
// Unified Hono HTTP fetch + Cloudflare Queue consumer export
export default {
fetch: app.fetch,
async queue(batch: MessageBatch<EmailJob>, env: Bindings, ctx: ExecutionContext): Promise<void> {
for (const message of batch.messages) {
try {
const { to, subject, template } = message.body;
await sendEmail(to, subject, template);
message.ack();
} catch (err) {
console.error('[QueueConsumerError]', err);
message.retry({ delaySeconds: 30 });
}
}
},
};
3. D1 Migrations
bash
# Create migration
wrangler d1 migrations create my-app-db create_products
# Write SQL migration
# migrations/0001_create_products.sql
sql
CREATE TABLE products (
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
name TEXT NOT NULL,
price REAL NOT NULL CHECK(price >= 0),
description TEXT DEFAULT '',
active INTEGER DEFAULT 1,
created_at TEXT DEFAULT (datetime('now')),
updated_at TEXT DEFAULT (datetime('now'))
);
CREATE INDEX idx_products_active ON products(active);
CREATE INDEX idx_products_created ON products(created_at DESC);
bash
# Apply migration
wrangler d1 migrations apply my-app-db
4. Durable Objects (Stateful Edge)
typescript
export class RateLimiter implements DurableObject {
private requests: number[] = [];
private readonly limit = 100;
private readonly windowMs = 60_000;
constructor(private state: DurableObjectState, private env: Bindings) {}
async fetch(request: Request): Promise<Response> {
const now = Date.now();
this.requests = this.requests.filter(t => now - t < this.windowMs);
if (this.requests.length >= this.limit) {
return new Response('Rate limit exceeded', { status: 429 });
}
this.requests.push(now);
await this.state.storage.put('requests', this.requests);
return new Response('OK', {
headers: {
'X-RateLimit-Remaining': String(this.limit - this.requests.length),
'X-RateLimit-Limit': String(this.limit),
},
});
}
}
5. Hyperdrive (External Database Connection)
typescript
import { Client } from 'pg';
app.get('/api/users', async (c) => {
const client = new Client({ connectionString: c.env.HYPERDRIVE.connectionString });
await client.connect();
const { rows } = await client.query('SELECT id, email, name FROM users LIMIT 100');
await client.end();
return c.json(rows);
});
6. Durable Objects SQLite Storage (ctx.storage.sql) & WebSocket Hibernation API

Use this.ctx.storage.sql.exec(...) for zero-latency ACID SQLite inside Durable Objects and this.ctx.acceptWebSocket(server) so idle WebSocket connections hibernate at zero compute cost:

typescript
import { DurableObject } from 'cloudflare:workers';
export class TenantQuotaCoordinator extends DurableObject {
constructor(ctx: DurableObjectState, env: Record<string, unknown>) {
super(ctx, env);
this.ctx.blockConcurrencyWhile(async () => {
this.ctx.storage.sql.exec(`
CREATE TABLE IF NOT EXISTS quota_ledger (
bucket_key TEXT PRIMARY KEY,
consumed INTEGER NOT NULL DEFAULT 0,
updated_at INTEGER NOT NULL
)
`);
});
}
async consumeTokens(bucketKey: string, delta: number, maxQuota: number): Promise<{ allowed: boolean; remaining: number }> {
const now = Date.now();
const rows = this.ctx.storage.sql
.exec<{ consumed: number }>('SELECT consumed FROM quota_ledger WHERE bucket_key = ?', bucketKey)
.toArray();
const current = rows[0]?.consumed ?? 0;
if (current + delta > maxQuota) {
return { allowed: false, remaining: Math.max(0, maxQuota - current) };
}
const nextConsumed = current + delta;
this.ctx.storage.sql.exec(
`INSERT INTO quota_ledger (bucket_key, consumed, updated_at)
VALUES (?, ?, ?)
ON CONFLICT(bucket_key) DO UPDATE SET consumed = excluded.consumed, updated_at = excluded.updated_at`,
bucketKey,
nextConsumed,
now
);
return { allowed: true, remaining: maxQuota - nextConsumed };
}
}
Hard Guardrails (Declarative Invariants)
  • Prepared & Bound D1 Statements Only: MUST execute D1 queries exclusively with env.DB.prepare('... WHERE id = ?').bind(id) and never interpolate raw strings into prepare() or exec().
  • Non-Blocking Background Tasks via `ctx.waitUntil`: MUST wrap post-response telemetry, cache population, and audit logging inside c.executionCtx.waitUntil(promise) so the isolate is not terminated before completion.
  • Explicit Queue `ack()` / `retry({ delaySeconds })`: MUST acknowledge each processed message with message.ack() and catch transient failures with message.retry({ delaySeconds }) backed by a configured Dead Letter Queue.
  • Zero Mutable Isolate Globals for Request State: MUST never store user/tenant session state in module-level variables across requests, as a single V8 isolate serves multiple concurrent requests.
  • Hyperdrive Pooling for External TCP Databases: MUST connect to external PostgreSQL/MySQL databases through env.HYPERDRIVE.connectionString instead of opening raw cold TCP/TLS connections per request.

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/roedyrustam/vibes-plug/cloudflare-workers-expert/badge)](https://verified-skill.com/skills/roedyrustam/vibes-plug/cloudflare-workers-expert)

Something wrong with this skill or its page? Tell us.