durable-objects
Skill2 starsChanged 9 days agoMITView on GitHub
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. Even if they just say "create a Durable Object", "add RPC methods", or "set up SQLite in a DO". Covers Workers integration, wrangler config, and testing with Vitest. Biases towards retrieval from Cloudflare docs over pre-trained knowledge. Not for Worker API routes (use cloudflare-worker-api) or general Workers deployment.
34 other projects use a version of this, 30 of them edited.
Adopted by
Most recently taken up by
- artivilla/agent-skillsedited, first seen Nov 8, 2026
- 1stANUNNAKI/majlisedited, first seen Nov 8, 2026
- delorenj/skillsedited, first seen Nov 7, 2026
- jackson2w/claude-code-skillsedited, first seen Nov 3, 2026
- jjsizemore/jjskillsedited, first seen Nov 1, 2026
- adrienlupo/Claude-code-configedited, first seen Oct 30, 2026
Used with
Projects with it also use nextjs-on-cloudflare, basin and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
CloudflareSkillnextjs-on-cloudflare
Build, migrate, and deploy Next.js apps on Cloudflare Workers with vinext. Use when starting a Next.js project on Cloudflare, moving an existing app to Workers, choosing between vinext and OpenNext, or setting up vinext for Workers. For setup, migration, or deployment, install vinext's upstream skills with `npx skills add cloudflare/vinext` if missing, then read and follow the applicable skill and docs.
Also in 6 projects that use this
CloudflareSkillbasin
Build and troubleshoot Cloudflare Basin analytics workflows with Basin Pipelines, Basin Catalog, and Basin SQL. Use for streaming data into R2 Iceberg tables, managing catalogs, or querying those tables; also use for requests using the former Data Platform, Pipelines, R2 Data Catalog, or R2 SQL names.
Also in 6 projects that use this
- +10 more from cloudflare
Other versions34 projects use a version of this.
Word for word · 0
None found.
Edited · 30
- openai/plugins★ 7.8k65% same
- cloudflare/skills★ 3.3k51% same
- Kilo-Org/cloud★ 2362% same
- d-padmanabhan/agent-engineering-handbook★ 1765% same
- delorenj/skills★ 1765% same
- kevyder/banrepco_mcp★ 965% same
- adrienlupo/Claude-code-config★ 353% same
- meowdiocre/meowpi★ 360% same
- 1stANUNNAKI/majlis★ 263% same
- Hahuyphananh/GRYND★ 253% same
20 more not listed
Wrote their own version · 4
- butterbase-ai/butterbase-plugin★ 535same name
- butterbase-ai/butterbase-skills★ 535same name
- swyxio/skills★ 194same name
- zllovesuki/cloudflare-agent-skills★ 9same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository63 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .agents/skills/avoid-ai-writing/AGENTS.mdAGENTS.md
- .agents/skills/do-web-doc-resolver/AGENTS.mdAGENTS.md
- .agents/skills/skill-evaluator/AGENTS.mdAGENTS.md
- scripts/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- llms-full.txtllms.txt
- llms.txtllms.txt
- accessibility-auditorSkill
- agent-browserSkill
- agentic-abstentionSkill
- agents-mdSkill
- api-design-firstSkill
- architecture-diagramSkill
- avoid-ai-writingSkill
- cicd-pipelineSkill
- cloudflare-worker-apiSkill
- codacySkill
- codeberg-apiSkill
- code-review-assistantSkill
- css-render-performanceSkill
- database-devopsSkill
- debuggerSkill
- delegateSkill
- dependency-upgradesSkill
- dist-channel-selectionSkill
- docs-hookSkill
- document-rendering-and-locatorsSkill
- dogfoodSkill
- dora-reportSkill
- do-web-doc-resolverSkill
- eu-ai-act-complianceSkill
- git-github-workflowSkill
- goap-agentSkill
- implementerSkill
- intent-classifierSkill
- iterative-refinementSkill
- jules-delegatorSkill
- learnSkill
- lifecycle-managementSkill
- local-context-sanitizationSkill
- memory-contextSkill
- migration-refactoringSkill
- nested-build-isolationSkill
- privacy-firstSkill
- progressive-deliverySkill
- pwa-offline-syncSkill
- reader-ui-uxSkill
- readme-best-practicesSkill
- secrets-managementSkill
- secure-invite-and-accessSkill
- security-code-auditorSkill
- shell-script-qualitySkill
- skill-creatorSkill
- skill-evaluatorSkill
- static-analysisSkill
- testing-strategySkill
- test-runnerSkill
- triz-solverSkill
- turso-dbSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. 1 is common, 0 are distinctive, and 1 is very specific to this project.
1
Common
Most of the 34 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 113
Initialize in constructor: - Use blockConcurrencyWhile() for schema setup only.
- Common: line 115
Persist first, cache second: - Always write to storage before updating in-memory state.
“Common” is measured: kept by at least 6 in 10 of the 34 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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.
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
Core Principles
Use Durable Objects For
| 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 |
Do NOT Use For
- Stateless request handling (use plain Workers)
- Maximum global distribution needs
- High fan-out independent requests
Quick Reference
Wrangler Configuration
// wrangler.jsonc
{
"durable_objects": {
"bindings": [{ "name": "MY_DO", "class_name": "MyDurableObject" }],
},
"migrations": [{ "tag": "v1", "new_sqlite_classes": ["MyDurableObject"] }],
}Basic Durable Object Pattern
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 entries (
id INTEGER PRIMARY KEY AUTOINCREMENT,
data TEXT NOT NULL
)
`);
});
}
async appendEntry(data: string): Promise<number> {
const result = this.ctx.storage.sql.exec<{ id: number }>(
"INSERT INTO entries (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("instance-123");
const id = await stub.appendEntry("hello world");
return Response.json({ id });
},
};Critical Rules
- Model around coordination atoms - One DO per chat room/game/user, not one global DO.
- Use getByName() for deterministic routing - Same input = same DO instance.
- Use SQLite storage - Configure
new_sqlite_classesin migrations. - Initialize in constructor - Use
blockConcurrencyWhile()for schema setup only. - Use RPC methods - Not
fetch()handler (compatibility date >= 2024-04-03). - Persist first, cache second - Always write to storage before updating in-memory state.
- 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
awaitbetween related storage writes (breaks atomicity). - Holding
blockConcurrencyWhile()acrossfetch()or external I/O.
References
references/rules.md- Core rules, storage, concurrency, RPC, alarms
See Also
cloudflare-worker-api— Cloudflare Worker API routesturso-db— Database development
Rationalizations
| Rationalization | Reality |
| "I can handle state in a global variable." | Durable Objects provide persistence across restarts and evictions. |
| "Writing to storage on every request is slow." | SQLite storage is extremely fast and ensures data integrity. |
| "I'll just use fetch() for communication." | RPC methods provide better type safety and performance (no HTTP overhead). |
Red Flags
- Using a single Durable Object for all application state.
- Performing external API calls inside
blockConcurrencyWhile(). - Lack of a migration strategy for SQLite schema updates.
- Using
newUniqueId()without storing the ID elsewhere (lost reference).
Voice & Context
- Default:
professional+blog - Reference:
voice-profilesskill for definitions and auto-detection.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

