durable-objects — cloudflare durable-objects, official, cloudflare, ide skills, workers, Claude Code, Cursor, Windsurf

Verified
v1.0.0
GitHub

About this Skill

Perfect for Edge Computing Agents needing stateful coordination and storage using Durable Objects on Cloudflare's edge 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.

# Core Topics

cloudflare cloudflare
[526]
[63]
Updated: 3/5/2026

Agent Capability Analysis

The durable-objects skill by cloudflare is an open-source official AI agent skill for Claude Code and other IDE workflows, helping agents execute tasks with better context, repeatability, and domain-specific guidance. Optimized for cloudflare, workers.

Ideal Agent Persona

Perfect for Edge Computing Agents needing stateful coordination and storage using Durable Objects on Cloudflare's edge

Core Value

Empowers agents to build stateful, coordinated applications using Cloudflare Durable Objects, implementing RPC methods, SQLite storage, alarms, WebSockets, and integrating with Workers, while following best practices from Cloudflare docs

Capabilities Granted for durable-objects

Building stateful chat rooms with real-time updates using WebSockets
Implementing multiplayer game logic with Durable Objects and Workers integration
Creating booking systems with coordinated storage and RPC methods

! Prerequisites & Limits

  • Requires Cloudflare account and Workers setup
  • Prefer retrieval from Cloudflare docs over pre-trained knowledge for any Durable Objects task
  • Compatibility issues may arise if Durable Objects APIs and configuration are outdated
Labs Demo

Browser Sandbox Environment

⚡️ Ready to unleash?

Experience this Agent in a zero-setup browser environment powered by WebContainers. No installation required.

Boot Container Sandbox

durable-objects

Create and review Cloudflare Durable Objects. Use when building stateful coordination (chat rooms, multiplayer games, booking systems), implementing RPC...

SKILL.md
Readonly

Durable Objects

Build stateful, coordinated applications on Cloudflare's edge using Durable Objects.

Retrieval Sources

Your knowledge of Durable Objects APIs and configuration may be outdated. Prefer retrieval over pre-training for any Durable Objects task.

ResourceURL
Docshttps://developers.cloudflare.com/durable-objects/
API Referencehttps://developers.cloudflare.com/durable-objects/api/
Best Practiceshttps://developers.cloudflare.com/durable-objects/best-practices/
Exampleshttps://developers.cloudflare.com/durable-objects/examples/

Fetch the relevant doc page when implementing features.

When to Use

  • Creating new Durable Object classes for stateful coordination
  • Implementing RPC methods, alarms, or WebSocket handlers
  • Reviewing existing DO code for best practices
  • Configuring wrangler.jsonc/toml for DO bindings and migrations
  • Writing tests with @cloudflare/vitest-pool-workers
  • Designing sharding strategies and parent-child relationships

Reference Documentation

  • ./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, observability

Search: blockConcurrencyWhile, idFromName, getByName, setAlarm, sql.exec

Core Principles

Use Durable Objects For

NeedExample
CoordinationChat rooms, multiplayer games, collaborative docs
Strong consistencyInventory, booking systems, turn-based games
Per-entity storageMulti-tenant SaaS, per-user data
Persistent connectionsWebSockets, real-time notifications
Scheduled work per entitySubscription renewals, game timeouts

Do NOT Use For

  • Stateless request handling (use plain Workers)
  • Maximum global distribution needs
  • High fan-out independent requests

Quick Reference

Wrangler Configuration

jsonc
1// wrangler.jsonc 2{ 3 "durable_objects": { 4 "bindings": [{ "name": "MY_DO", "class_name": "MyDurableObject" }] 5 }, 6 "migrations": [{ "tag": "v1", "new_sqlite_classes": ["MyDurableObject"] }] 7}

Basic Durable Object Pattern

typescript
1import { DurableObject } from "cloudflare:workers"; 2 3export interface Env { 4 MY_DO: DurableObjectNamespace<MyDurableObject>; 5} 6 7export class MyDurableObject extends DurableObject<Env> { 8 constructor(ctx: DurableObjectState, env: Env) { 9 super(ctx, env); 10 ctx.blockConcurrencyWhile(async () => { 11 this.ctx.storage.sql.exec(` 12 CREATE TABLE IF NOT EXISTS items ( 13 id INTEGER PRIMARY KEY AUTOINCREMENT, 14 data TEXT NOT NULL 15 ) 16 `); 17 }); 18 } 19 20 async addItem(data: string): Promise<number> { 21 const result = this.ctx.storage.sql.exec<{ id: number }>( 22 "INSERT INTO items (data) VALUES (?) RETURNING id", 23 data 24 ); 25 return result.one().id; 26 } 27} 28 29export default { 30 async fetch(request: Request, env: Env): Promise<Response> { 31 const stub = env.MY_DO.getByName("my-instance"); 32 const id = await stub.addItem("hello"); 33 return Response.json({ id }); 34 }, 35};

Critical Rules

  1. Model around coordination atoms - One DO per chat room/game/user, not one global DO
  2. Use getByName() for deterministic routing - Same input = same DO instance
  3. Use SQLite storage - Configure new_sqlite_classes in migrations
  4. Initialize in constructor - Use blockConcurrencyWhile() for schema setup only
  5. Use RPC methods - Not fetch() handler (compatibility date >= 2024-04-03)
  6. Persist first, cache second - Always write to storage before updating in-memory state
  7. One alarm per DO - setAlarm() replaces any existing alarm

Anti-Patterns (NEVER)

  • Single global DO handling all requests (bottleneck)
  • Using blockConcurrencyWhile() on every request (kills throughput)
  • Storing critical state only in memory (lost on eviction/crash)
  • Using await between related storage writes (breaks atomicity)
  • Holding blockConcurrencyWhile() across fetch() or external I/O

Stub Creation

typescript
1// Deterministic - preferred for most cases 2const stub = env.MY_DO.getByName("room-123"); 3 4// From existing ID string 5const id = env.MY_DO.idFromString(storedIdString); 6const stub = env.MY_DO.get(id); 7 8// New unique ID - store mapping externally 9const id = env.MY_DO.newUniqueId(); 10const stub = env.MY_DO.get(id);

Storage Operations

typescript
1// SQL (synchronous, recommended) 2this.ctx.storage.sql.exec("INSERT INTO t (c) VALUES (?)", value); 3const rows = this.ctx.storage.sql.exec<Row>("SELECT * FROM t").toArray(); 4 5// KV (async) 6await this.ctx.storage.put("key", value); 7const val = await this.ctx.storage.get<Type>("key");

Alarms

typescript
1// Schedule (replaces existing) 2await this.ctx.storage.setAlarm(Date.now() + 60_000); 3 4// Handler 5async alarm(): Promise<void> { 6 // Process scheduled work 7 // Optionally reschedule: await this.ctx.storage.setAlarm(...) 8} 9 10// Cancel 11await this.ctx.storage.deleteAlarm();

Testing Quick Start

typescript
1import { env } from "cloudflare:test"; 2import { describe, it, expect } from "vitest"; 3 4describe("MyDO", () => { 5 it("should work", async () => { 6 const stub = env.MY_DO.getByName("test"); 7 const result = await stub.addItem("test"); 8 expect(result).toBe(1); 9 }); 10});

FAQ & Installation Steps

These questions and steps mirror the structured data on this page for better search understanding.

? Frequently Asked Questions

What is durable-objects?

Perfect for Edge Computing Agents needing stateful coordination and storage using Durable Objects on Cloudflare's edge 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.

How do I install durable-objects?

Run the command: npx killer-skills add cloudflare/skills/durable-objects. It works with Cursor, Windsurf, VS Code, Claude Code, and 19+ other IDEs.

What are the use cases for durable-objects?

Key use cases include: Building stateful chat rooms with real-time updates using WebSockets, Implementing multiplayer game logic with Durable Objects and Workers integration, Creating booking systems with coordinated storage and RPC methods.

Which IDEs are compatible with durable-objects?

This skill is compatible with Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer. Use the Killer-Skills CLI for universal one-command installation.

Are there any limitations for durable-objects?

Requires Cloudflare account and Workers setup. Prefer retrieval from Cloudflare docs over pre-trained knowledge for any Durable Objects task. Compatibility issues may arise if Durable Objects APIs and configuration are outdated.

How To Install

  1. 1. Open your terminal

    Open the terminal or command line in your project directory.

  2. 2. Run the install command

    Run: npx killer-skills add cloudflare/skills/durable-objects. The CLI will automatically detect your IDE or AI agent and configure the skill.

  3. 3. Start using the skill

    The skill is now active. Your AI agent can use durable-objects immediately in the current project.

Related Skills

Looking for an alternative to durable-objects or another official skill for your workflow? Explore these related open-source skills.

View All

flags

Logo of facebook
facebook

Use when you need to check feature flag states, compare channels, or debug why a feature behaves differently across release channels.

243.6k
0
Developer

extract-errors

Logo of facebook
facebook

Use when adding new error messages to React, or seeing unknown error code warnings.

243.6k
0
Developer

fix

Logo of facebook
facebook

Use when you have lint errors, formatting issues, or before committing code to ensure it passes CI.

243.6k
0
Developer

flow

Logo of facebook
facebook

Use when you need to run Flow type checking, or when seeing Flow type errors in React code.

243.6k
0
Developer