Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Create and review Cloudflare Durable Objects. Use when building stateful coordination (chat rooms, multiplayer games, booking systems), implementing RPC methods, SQLite storage, alarms, WebSockets, or reviewing DO code for best practices. Covers Workers integration, wrangler config, and testing with Vitest. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.
.claude/skills/kunanonj-cursor-cf-marketplace-durable-objects/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-03 | ✗→✓ | ▲ Improved | 42% | 0% |
| case-01 | ✗→✓ | ▲ Improved | -3% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 35% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 73% | 0% |
| case-18 | ✗→✓ | ▲ Improved | 89% | 0% |
Build stateful, coordinated applications on Cloudflare's edge using Durable Objects.
Your knowledge of Durable Objects APIs and configuration may be outdated. Prefer retrieval over pre-training for any Durable Objects task.
| Resource | URL | |----------|-----| | Docs | https://developers.cloudflare.com/durable-objects/ | | API Reference | https://developers.cloudflare.com/durable-objects/api/ | | Best Practices | https://developers.cloudflare.com/durable-objects/best-practices/ | | Examples | https://developers.cloudflare.com/durable-objects/examples/ |
Fetch the relevant doc page when implementing features.
@cloudflare/vitest-pool-workers./references/rules.md - Core rules, storage, concurrency, RPC, alarms./references/testing.md - Vitest setup, unit/integration tests, alarm testing./references/workers.md - Workers handlers, types, wrangler config, observabilitySearch: blockConcurrencyWhile, idFromName, getByName, setAlarm, sql.exec
| Need | Example | |------|---------| | Coordination | Chat rooms, multiplayer games, collaborative docs | | Strong consistency | Inventory, booking systems, turn-based games | | Per-entity storage | Multi-tenant SaaS, per-user data | | Persistent connections | WebSockets, real-time notifications | | Scheduled work per entity | Subscription renewals, game timeouts |
jsonc// wrangler.jsonc { "durable_objects": { "bindings": [{ "name": "MY_DO", "class_name": "MyDurableObject" }] }, "migrations": [{ "tag": "v1", "new_sqlite_classes": ["MyDurableObject"] }] }
typescriptimport { DurableObject } from "cloudflare:workers"; export interface Env { MY_DO: DurableObjectNamespace<MyDurableObject>; } export class MyDurableObject extends DurableObject<Env> { constructor(ctx: DurableObjectState, env: Env) { super(ctx, env); ctx.blockConcurrencyWhile(async () => { this.ctx.storage.sql.exec(` CREATE TABLE IF NOT EXISTS items ( id INTEGER PRIMARY KEY AUTOINCREMENT, data TEXT NOT NULL ) `); }); } async addItem(data: string): Promise<number> { const result = this.ctx.storage.sql.exec<{ id: number }>( "INSERT INTO items (data) VALUES (?) RETURNING id", data ); return result.one().id; } } export default { async fetch(request: Request, env: Env): Promise<Response> { const stub = env.MY_DO.getByName("my-instance"); const id = await stub.addItem("hello"); return Response.json({ id }); }, };
getByName() for deterministic routing - Same input = same DO instancenew_sqlite_classes in migrationsblockConcurrencyWhile() for schema setup onlysetAlarm() replaces any existing alarmblockConcurrencyWhile() on every request (kills throughput)await between related storage writes (breaks atomicity)blockConcurrencyWhile() across fetch() or external I/Otypescript// Deterministic - preferred for most cases const stub = env.MY_DO.getByName("room-123"); // From existing ID string const id = env.MY_DO.idFromString(storedIdString); const stub = env.MY_DO.get(id); // New unique ID - store mapping externally const id = env.MY_DO.newUniqueId(); const stub = env.MY_DO.get(id);
typescript// SQL (synchronous, recommended) this.ctx.storage.sql.exec("INSERT INTO t (c) VALUES (?)", value); const rows = this.ctx.storage.sql.exec<Row>("SELECT * FROM t").toArray(); // KV (async) await this.ctx.storage.put("key", value); const val = await this.ctx.storage.get<Type>("key");
typescript// Schedule (replaces existing) await this.ctx.storage.setAlarm(Date.now() + 60_000); // Handler async alarm(): Promise<void> { // Process scheduled work // Optionally reschedule: await this.ctx.storage.setAlarm(...) } // Cancel await this.ctx.storage.deleteAlarm();
typescriptimport { env } from "cloudflare:test"; import { describe, it, expect } from "vitest"; describe("MyDO", () => { it("should work", async () => { const stub = env.MY_DO.getByName("test"); const result = await stub.addItem("test"); expect(result).toBe(1); }); });
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-03 | fail→pass | 14,566 | 14,549 | -0% | 1 | 1 | 0% | 3,330 | 4,740 | +42% | 0 | 0 | — |
case-01 | fail→pass | 14,461 | 8,708 | -40% | 1 | 1 | 0% | 3,434 | 3,328 | -3% | 0 | 0 | — |
case-02 | fail→pass | 14,316 | 10,666 | -25% | 1 | 1 | 0% | 3,014 | 4,079 | +35% | 0 | 0 | — |
case-04 | pass→pass | 10,818 | 12,020 | +11% | 1 | 1 | 0% | 2,677 | 4,052 | +51% | 0 | 0 | — |
case-05 | pass→pass | 10,732 | 6,870 | -36% | 1 | 1 | 0% | 2,449 | 3,047 | +24% | 0 | 0 | — |
case-06 | pass→pass | 10,565 | 7,616 | -28% | 1 | 1 | 0% | 2,012 | 2,850 | +42% | 0 | 0 | — |
case-07 | pass→pass | 8,928 | 4,942 | -45% | 1 | 1 | 0% | 1,847 | 2,457 | +33% | 0 | 0 | — |
case-08 | pass→pass | 11,254 | 6,395 | -43% | 1 | 1 | 0% | 2,126 | 2,720 | +28% | 0 | 0 | — |
case-21 | pass→pass | 10,543 | 7,049 | -33% | 1 | 1 | 0% | 1,867 | 3,005 | +61% | 0 | 0 | — |
case-09 | pass→pass | 4,704 | 4,171 | -11% | 1 | 1 | 0% | 1,060 | 2,373 | +124% | 0 | 0 | — |
case-10 | fail→pass | 5,865 | 3,626 | -38% | 1 | 1 | 0% | 1,230 | 2,126 | +73% | 0 | 0 | — |
case-11 | pass→pass | 5,676 | 4,187 | -26% | 1 | 1 | 0% | 1,073 | 2,270 | +112% | 0 | 0 | — |
case-12 | pass→pass | 6,479 | 3,392 | -48% | 1 | 1 | 0% | 1,342 | 2,038 | +52% | 0 | 0 | — |
case-13 | pass→pass | 12,321 | 4,419 | -64% | 1 | 1 | 0% | 1,860 | 2,337 | +26% | 0 | 0 | — |
case-14 | pass→pass | 6,572 | 3,834 | -42% | 1 | 1 | 0% | 1,403 | 2,189 | +56% | 0 | 0 | — |
case-15 | pass→pass | 3,260 | 3,027 | -7% | 1 | 1 | 0% | 531 | 2,046 | +285% | 0 | 0 | — |
case-16 | pass→pass | 11,490 | 7,836 | -32% | 1 | 1 | 0% | 2,107 | 3,109 | +48% | 0 | 0 | — |
case-17 | pass→pass | 9,464 | 7,828 | -17% | 1 | 1 | 0% | 2,047 | 3,172 | +55% | 0 | 0 | — |
case-18 | fail→pass | 8,210 | 9,435 | +15% | 1 | 1 | 0% | 1,832 | 3,458 | +89% | 0 | 0 | — |
case-19 | pass→pass | 6,732 | 5,610 | -17% | 1 | 1 | 0% | 1,534 | 2,794 | +82% | 0 | 0 | — |
case-20 | fail→pass | 3,878 | 3,644 | -6% | 1 | 1 | 0% | 752 | 2,159 | +187% | 0 | 0 | — |
case-22 | pass→pass | 4,812 | 5,095 | +6% | 1 | 1 | 0% | 905 | 2,464 | +172% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +27 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.