/cloudflare-vm:durable-objectsfrom cloudflare-vm
Cloudflare Durable Objects: Expert guidance for building stateful applications with Cloudflare Durable Objects.
Ships in cloudflare-vm. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Vendored from themusebook/skills (derived from cloudflare/skills, Apache-2.0). This snapshot may be outdated: confirm limits, pricing, API signatures and config options against https://developers.cloudflare.com/ before you cite them. When this file and the docs disagree, trust the docs.
When invoked: read every file in this skill's directory before answering, so you have the full reference: api.md, configuration.md, gotchas.md, patterns.md. Then answer the user's question (or, if none was given, summarise the product: what it is, config, API, patterns and gotchas). Related products are sibling skills, linked as ../<product>/.
Expert guidance for building stateful applications with Cloudflare Durable Objects.
Durable Objects combine compute with storage in globally-unique, strongly-consistent packages:
Critical rules preventing most production issues:
ctx.waitUntil() for cleanup - Ensures completion after response sentsetAlarm() for reliable schedulingAll DOs extend DurableObject base class with constructor receiving DurableObjectState (storage, WebSockets, alarms) and Env (bindings).
[Not Created] → [Active] ⇄ [Hibernated] → [Evicted]
↓
[Destroyed]
Workers use bindings to get stubs, then call RPC methods directly (recommended) or use fetch handler (legacy).
RPC vs fetch() decision:
├─ New project + compat ≥2024-04-03 → RPC (type-safe, simpler)
├─ Need HTTP semantics (headers, status) → fetch()
├─ Proxying requests to DO → fetch()
└─ Legacy compatibility → fetch()
See Patterns: RPC vs fetch() for examples.
idFromName(): Deterministic, named coordination (rate limiting, locks)newUniqueId(): Random IDs for sharding high-throughput workloadsidFromString(): Derive from existing IDsWhich storage API?
├─ Structured data, relations, transactions → SQLite (recommended)
├─ Simple KV on SQLite DO → ctx.storage.kv (sync KV)
└─ Legacy KV-only DO → ctx.storage (async KV)
See DO Storage for deep dive.
import { DurableObject } from "cloudflare:workers";
export class Counter extends DurableObject<Env> {
async increment(): Promise<number> {
const result = this.ctx.storage.sql.exec(
`INSERT INTO counters (id, value) VALUES (1, 1)
ON CONFLICT(id) DO UPDATE SET value = value + 1
RETURNING value`
).one();
return result.value;
}
}
// Worker access
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const id = env.COUNTER.idFromName("global");
const stub = env.COUNTER.get(id);
const count = await stub.increment();
return new Response(`Count: ${count}`);
}
};
├─ Coordinate requests (rate limit, lock, session)
│ → idFromName(identifier) → [Patterns: Rate Limiting/Locks](./patterns.md)
│
├─ High throughput (>1K req/s)
│ → Sharding with newUniqueId() or hash → [Patterns: Sharding](./patterns.md)
│
├─ Real-time updates (WebSocket, chat, collab)
│ → WebSocket hibernation + room pattern → [Patterns: Real-time](./patterns.md)
│
├─ Background work (cleanup, notifications, scheduled tasks)
│ → Alarms + queue pattern (1 alarm/DO) → [Patterns: Multiple Events](./patterns.md)
│
└─ User sessions with expiration
→ Session pattern + alarm cleanup → [Patterns: Session Management](./patterns.md)
├─ New project + typed methods → RPC (compat ≥2024-04-03)
├─ Need HTTP semantics → fetch()
├─ Proxying to DO → fetch()
└─ Legacy compat → fetch()
See Patterns: RPC vs fetch() for examples.
├─ Structured data, SQL queries, transactions → SQLite (recommended)
├─ Simple KV on SQLite DO → ctx.storage.kv (sync API)
└─ Legacy KV-only DO → ctx.storage (async API)
See DO Storage for complete guide.
npx wrangler dev # Local dev with DOs
npx wrangler dev --remote # Test against prod DOs
npx wrangler deploy # Deploy + auto-apply migrations
Docs: https://developers.cloudflare.com/durable-objects/
API Reference: https://developers.cloudflare.com/durable-objects/api/
Examples: https://developers.cloudflare.com/durable-objects/examples/
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub vmaia00/claude-specs --plugin cloudflare-vm64 skills in this plugin
/agents-sdkCloudflare Agents SDK: Cloudflare Agents SDK enables building AI-powered agents on Durable Objects with state, WebSockets, SQL, scheduling, and AI integration./ai-gatewayCloudflare AI Gateway: Expert guidance for implementing Cloudflare AI Gateway - a universal gateway for AI model providers with analytics, caching, rate limiting, and routing capabilities./ai-searchCloudflare AI Search Reference: Expert guidance for implementing Cloudflare AI Search (formerly AutoRAG), Cloudflare's managed semantic search and RAG service./analytics-engineCloudflare Workers Analytics Engine Reference: Expert guidance for implementing unlimited-cardinality analytics at scale using Cloudflare Workers Analytics Engine./apiCloudflare API Integration: Guide for working with Cloudflare's REST API - authentication, SDK usage, common patterns, and troubleshooting./api-shieldCloudflare API Shield Reference: Expert guidance for API Shield - comprehensive API security suite for discovery, protection, and monitoring.