durable-objects
Skill2 starsChanged 3 months 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. Covers Workers integration, wrangler config, and testing with Vitest. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.
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
- delorenj/skillsedited, first seen Nov 7, 2026
- d-o-hub/github-template-ai-agentsedited, first seen Nov 3, 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 3 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
- +3 more from cloudflare
Other versions34 projects use a version of this.
Word for word · 0
None found.
Edited · 30
- openai/plugins★ 7.8k99% same
- cloudflare/skills★ 3.3k74% same
- Kilo-Org/cloud★ 2395% same
- d-padmanabhan/agent-engineering-handbook★ 1799% same
- delorenj/skills★ 1799% same
- kevyder/banrepco_mcp★ 999% same
- adrienlupo/Claude-code-config★ 378% same
- meowdiocre/meowpi★ 391% same
- d-o-hub/github-template-ai-agents★ 268% same
- Hahuyphananh/GRYND★ 278% 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 repository93 other files it gives its agents.
- AGENTS.mdAGENTS.md
- npm/AGENTS.mdAGENTS.md
- advanced-image-slicing-skillSkill
- agents-sdkSkill
- agent-weaver-builderSkill
- alphafold-database-fetch-and-analyzeSkill
- alphagenome-single-variant-analysisSkill
- animation-scroll-effectsSkill
- backend-api-shield-servicesSkill
- chembl-databaseSkill
- chronicle-logger-timestampSkill
- cicd-automation-deploySkill
- cinematic-animator-gsapSkill
- clinical-trials-databaseSkill
- clinvar-databaseSkill
- cloudflare-ai-resourcesSkill
- cloudflare-email-serviceSkill
- cloudflare-one-migrationsSkill
- cloudflare-oneSkill
- cloudflareSkill
- data-modeler-schemaSkill
- dbsnp-databaseSkill
- design-system-master-hslSkill
- embl-ebi-olsSkill
- encode-ccres-databaseSkill
- ensembl-databaseSkill
- explode-animation-skillSkill
- find-skillsSkill
- foldseek-structural-searchSkill
- frontend-clean-coder-jsSkill
- gnomad-databaseSkill
- google-antigravity-sdkSkill
- gtex-databaseSkill
- human-protein-atlas-databaseSkill
- inner-learner-feedbackSkill
- integrative-architect-docsSkill
- intent-observer-audit360Skill
- interpro-databaseSkill
- isolated-sandbox-environmentSkill
- jaspar-databaseSkill
- k6-load-testingSkill
- lightweight-dep-managerSkill
- literature-search-arxivSkill
- literature-search-biorxivSkill
- literature-search-europepmcSkill
- literature-search-openalexSkill
- maestro-hadi-orchestrationSkill
- majlis-rulesSkill
- marketing-funnel-skillSkill
- ncbi-sequence-fetchSkill
- neuro-marketing-copywriterSkill
- nuclei-security-auditorSkill
- openfda-databaseSkill
- opentargets-databaseSkill
- owasp-zap-api-shieldSkill
- pdb-databaseSkill
- pdf-scan-layer-cleanerSkill
- premium-visual-polish-skillSkill
- protein-sequence-msaSkill
- protein-sequence-similarity-searchSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. 2 are common, 0 are distinctive, and 2 are very specific to this project.
2
Common
Most of the 34 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 43
Search: blockConcurrencyWhile, idFromName, getByName, setAlarm, sql.exec
- Very specific: line 122
Initialize in constructor: - Use blockConcurrencyWhile() for schema setup only
- Common: line 123
Use RPC methods: - Not fetch() handler (compatibility date >= 2024-04-03)
- Common: line 124
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.
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
| 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 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 });
},
};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
Stub Creation
// 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
// 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
// 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 Quick Start
import { 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);
});
});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.

