Official agent skill

Durable Objects

by cloudflare in cloudflare/skills

Build, debug, or review Cloudflare Durable Objects code for persistent state and coordination.

OfficialApache-2.0Auto-check passedBackend & APIs

Install Durable Objects

skills CLI
$ npx skills add cloudflare/skills --skill durable-objects -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install cloudflare/skills durable-objects --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/cloudflare/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/durable-objects .claude/skills/durable-objects && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
durable-objects
GitHub stars
3k
Used in
2 other repos
Token cost
~1.5k tokens
SKILL.md length
395 words
Files
4 (incl. references)
Skills in repo
16
Repo updated
First seen
Licence
Apache-2.0

At a glance

Build, debug, or review Cloudflare Durable Objects code for persistent state and coordination.

  • Works in 7 steps: Model around coordination atoms - One DO… → Use getByName() for deterministic… → Use SQLite storage - Configure… → …
  • Tasks that involve Agent memory
  • SKILL.md covers Retrieval Sources, When to Use, Reference Documentation and Core Principles, plus 8 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Durable Objects is an agent skill from cloudflare/skills, published by the product's own GitHub organization. Build, debug, or review Cloudflare Durable Objects code for persistent state and coordination.

Its SKILL.md is about 1.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files, including reference files (for example `references/rules.md`, `references/testing.md` and `references/workers.md`).

It sits in Backend & APIs, covering Agent memory. It works with Cloudflare Durable Objects, Cloudflare Workers and Cloudflare. The repository describes itself as: Skills for teaching agents how to build on Cloudflare. The licence is Apache-2.0.

When your agent uses it

  • Tasks that involve Agent memory

Example prompts

  • “/durable-objects”

Workflow steps

7 steps, taken from the first numbered list in SKILL.md.

  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

What it can do on your machine

Read from SKILL.md and the folder at commit 41e0d19. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript and jsonc).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • developers.cloudflare.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Durable Objects loads about 1.5k tokens when it runs, and up to ~4.7k if it reads all its reference files. Until then it costs about 28 tokens; SKILL.md has 395 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~28
When it runs · the whole SKILL.md, loaded when a task matches
~1.5k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from cloudflare/skills at commit 41e0d19, republished under its Apache-2.0 licence (© cloudflare). 395 words, ~1,510 tokens.

Download SKILL.mdSave it as .claude/skills/durable-objects/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
durable-objects
description
Build, debug, or review Cloudflare Durable Objects code for persistent state and coordination.

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.

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’s Vitest integration
  • Designing sharding strategies and parent-child relationships

Reference Documentation

  • ./references/rules.md - Core rules, storage, concurrency, RPC, alarms
  • Testing reference - Current Vitest documentation, migration choices, and test selection
  • ./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
// wrangler.jsonc
{
  "durable_objects": {
    "bindings": [{ "name": "MY_DO", "class_name": "MyDurableObject" }]
  },
  "migrations": [{ "tag": "v1", "new_sqlite_classes": ["MyDurableObject"] }]
}
Basic Durable Object Pattern
typescript
import { 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 });
  },
};
Show full SKILL.md (194 more words)Show less

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

Authorization

Durable Objects do not have separate roles or permissions; access follows the Worker that implements them. Retrieve the current Durable Objects authorization guidance before granting observability or Data Studio access, and scope the Workers role to the intended Worker or Workers product.

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
// 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);

Storage Operations

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");

Alarms

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();

Testing

Read the testing reference before configuring a suite or writing Durable Object tests. It routes to current setup, APIs, and examples and identifies the behavior to cover.

© cloudflare, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (references) in skills/durable-objects of cloudflare/skills.

  • SKILL.md
  • references/rules.md
  • references/testing.md
  • references/workers.md

Open the folder on GitHubat commit 41e0d19

Used in 2 other repositories

We found 2 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 2 other GitHub owners. This page covers the copy in cloudflare/skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Durable Objects next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Durable Objects compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Durable Objects this skillcloudflare/skills3k2 repos~1.5kAutomated safety check: PassApache-2.0
Durable Objectshodgef/apiker1274 repos~1.5kAutomated safety check: PassMIT
Sharehtml Collaborationjonesphillip/sharehtml132—~902Automated safety check: PassApache-2.0
Apikerhodgef/apiker127—~1.4kAutomated safety check: PassMIT
Cloudflare WorkersEpicenterHQ/epicenter4.8k—~576Automated safety check: PassCustom licence
Cloudflareericrisco/rsc-harness156—~2.6kAutomated safety check: PassMIT

Similar skills

  • Durable Objects

    hodgef/apiker

    Create and review Cloudflare Durable Objects. An agent skill from hodgef/apiker.

    127 GitHub starsUsed in 4 repos~1.5k tokens
    Backend & APIsAuto-check passed
  • Sharehtml Collaboration

    jonesphillip/sharehtml

    A skill your agent uses when a user wants to deploy, update, diff, pull, or review feedback on documents managed with the sharehtml CLI.

    132 GitHub stars~902 tokensUpdated 6 mo ago
    Backend & APIsAuto-check passed
  • Apiker

    hodgef/apiker

    Develop, review, and extend the Apiker library — a framework for building serverless REST APIs on Cloudflare Workers + Durable Objects.

    127 GitHub stars~1.4k tokensUpdated 1 mo ago
    Backend & APIsAuto-check passed
  • Cloudflare Workers

    EpicenterHQ/epicenter

    Cloudflare Workers patterns for Worker runtime APIs, Durable Objects, KV, R2, D1, Queues, WebSockets, streaming responses, bindings, wrangler configuration, and deployment limits.

    4.8k GitHub stars~576 tokensUpdated today
    Backend & APIsAuto-check passed
  • Cloudflare

    ericrisco/rsc-harness

    A skill your agent uses when working on Cloudflare's edge platform — wrangler.jsonc bindings, choosing between D1/KV/R2/Durable Objects/Queues, deploying a Worker or SPA via Static Assets, or…

    156 GitHub stars~2.6k tokensUpdated today
    Backend & APIsAuto-check passed
  • Cloudflare

    hoodini/ai-agents-skills

    Build and deploy on Cloudflare's edge platform. An agent skill from hoodini/ai-agents-skills.

    282 GitHub stars~3k tokensUpdated 2 mo ago
    Backend & APIsAuto-check passed

More from cloudflare/skills

All 16 skills in this repo
  • Turnstile Spin

    cloudflare/skills

    Official

    Set up, repair, or migrate to Cloudflare Turnstile bot verification in an existing frontend and backend, including server-side Siteverify.

    3k GitHub starsUsed in 4 repos~7.2k tokens
    Auto-check: notes
  • Nextjs On Cloudflare

    cloudflare/skills

    Official

    Build, migrate, and deploy Next.js apps on Cloudflare Workers with vinext.

    3k GitHub starsUsed in 2 repos~678 tokens
    Auto-check passed
  • Agents SDK

    cloudflare/skills

    Official

    Build, debug, or review Cloudflare Agents SDK applications using the agents package.

    3k GitHub starsUsed in 2 repos~3k tokens
    Auto-check passed
  • Sandbox Next

    cloudflare/skills

    Official

    Build or maintain Cloudflare Sandbox apps on @cloudflare/sandbox@next (SDK 1.0 preview).

    3k GitHub starsUsed in 2 repos~1.7k tokens
    Auto-check passed
  • Cloudflare One Migrations

    cloudflare/skills

    Official

    Assess and plan migrations from existing VPN, SWG, or SASE platforms to Cloudflare One, including policy mapping, parity gaps, and rollout.

    3k GitHub starsUsed in 6 repos~3.1k tokens
    Auto-check passed
  • Workers Best Practices

    cloudflare/skills

    Official

    Cloudflare Workers best practices for production applications.

    3k GitHub starsUsed in 2 repos~1.4k tokens
    Auto-check passed

Questions about Durable Objects

What does Durable Objects do?

Build, debug, or review Cloudflare Durable Objects code for persistent state and coordination. Durable Objects is an agent skill from cloudflare/skills, published by the product's own GitHub organization. Build, debug, or review Cloudflare Durable Objects code for persistent state and coordination.

When should I use Durable Objects?

Durable Objects fits situations like: tasks that involve Agent memory.

How do I install Durable Objects in Claude Code?

Run `npx skills add cloudflare/skills --skill durable-objects -a claude-code`. Or copy the skill folder (skills/durable-objects in cloudflare/skills) into .claude/skills/durable-objects in your project. Claude Code loads it when a task matches its description.

How do I install Durable Objects in Codex?

Run `npx skills add cloudflare/skills --skill durable-objects -a codex`. Or copy the skill folder (skills/durable-objects in cloudflare/skills) into .agents/skills/durable-objects in your project. Codex loads it when a task matches its description.

Can I use Durable Objects in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add cloudflare/skills --skill durable-objects -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/durable-objects, .gemini/skills/durable-objects, .github/skills/durable-objects and .opencode/skills/durable-objects in your project.

What does Durable Objects need to run?

SKILL.md names no scripts, command-line tools or credentials: Durable Objects is instructions for the agent only.

Does Durable Objects access the network?

SKILL.md names 1 domain. As links in the text: developers.cloudflare.com. This is read from the text; nothing was executed.

Is Durable Objects safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Durable Objects use?

Durable Objects is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Durable Objects use?

About 1.5k tokens (SKILL.md is roughly 6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 3.2k tokens, read only when the agent opens those files.

What are the alternatives to Durable Objects?

Skills that share tags, products or a category with Durable Objects: Durable Objects (hodgef/apiker, 127 stars), Sharehtml Collaboration (jonesphillip/sharehtml, 132 stars), Apiker (hodgef/apiker, 127 stars) and Cloudflare Workers (EpicenterHQ/epicenter, 4.8k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Durable Objects?

cloudflare (a GitHub organization, an official publisher) maintains it in cloudflare/skills, which has 2,999 GitHub stars. The repository holds 16 skills in this directory. The repository was last updated on October 1, 2026.

Source: cloudflare/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.