[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CFZ9DRMZH1DC4T5D4BS2SN":3,"skill-same:01M7CFZ9DRMZH1DC4T5D4BS2SN":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":29,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M7CFZ9DRMZH1DC4T5D4BS2SN","cloudflare-durable-objects",null,"Design and write Cloudflare Durable Objects. SQLite storage, RPC methods, WebSocket hibernation, alarms, class lifecycle (exports or migrations), and testing. Use for stateful coordination, rooms, per-user state, counters, rate limiters.","codewhale-hq\u002Fcodewhale-plugin-marketplace","codewhale-hq","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F326694313?v=4","01M6CDD9D70AD3631SMRJ7REW4","Codewhale","01M7CFYTPJMP417FBR6K9VE5VN",5,"MIT","https:\u002F\u002Fgithub.com\u002Fcodewhale-hq\u002Fcodewhale-plugin-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fcloudflare\u002Fskills\u002Fcloudflare-durable-objects\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: cloudflare-durable-objects\ndescription: Design and write Cloudflare Durable Objects. SQLite storage, RPC methods, WebSocket hibernation, alarms, class lifecycle (exports or migrations), and testing. Use for stateful coordination, rooms, per-user state, counters, rate limiters.\n---\n\n# Cloudflare Durable Objects\n\nA Durable Object is a class whose named instances each run in one place with\ntheir own storage. Use one object per coordination unit (a chat room, a\ndocument, a user, a game): that unit is the \"atom\". A single global object is a\nbottleneck and almost always the wrong design.\n\nCheck current syntax with the `cloudflare-docs` plugin or\nhttps:\u002F\u002Fdevelopers.cloudflare.com\u002Fdurable-objects\u002F before relying on memory;\nclass lifecycle configuration changed recently (see below).\n\n## Minimal SQLite-backed object with RPC\n\n```ts\nimport { DurableObject } from \"cloudflare:workers\";\n\nexport class Counter extends DurableObject\u003CEnv> {\n  constructor(ctx: DurableObjectState, env: Env) {\n    super(ctx, env);\n    \u002F\u002F Runs on every wake-up: keep it cheap and idempotent.\n    ctx.blockConcurrencyWhile(async () => {\n      ctx.storage.sql.exec(\"CREATE TABLE IF NOT EXISTS hits (n INTEGER NOT NULL)\");\n      ctx.storage.sql.exec(\"INSERT INTO hits (n) SELECT 0 WHERE NOT EXISTS (SELECT 1 FROM hits)\");\n    });\n  }\n\n  increment(): number {\n    this.ctx.storage.sql.exec(\"UPDATE hits SET n = n + 1\");\n    return this.ctx.storage.sql.exec(\"SELECT n FROM hits\").one().n as number;\n  }\n}\n\nexport default {\n  async fetch(request: Request, env: Env): Promise\u003CResponse> {\n    const stub = env.COUNTER.getByName(new URL(request.url).searchParams.get(\"id\") ?? \"default\");\n    return Response.json({ n: await stub.increment() }); \u002F\u002F RPC call\n  },\n} satisfies ExportedHandler\u003CEnv>;\n```\n\nBinding and SQLite lifecycle are declared together in typed config:\n\n```ts\nimport { bindings, defineConfig, exports } from \"cf\u002Fconfig\";\nexport default defineConfig({\n  worker: {\n    name: \"counter\", entrypoint: \"src\u002Findex.ts\", compatibilityDate: \"2026-10-01\",\n    env: { COUNTER: bindings.durableObject({ worker: \"counter\", exportName: \"Counter\" }) },\n    exports: { Counter: exports.durableObject({ storage: \"sqlite\" }) },\n  },\n});\n```\n\nReview `cf migrate --dry-run` for legacy configurations and preserve the\nexisting class identity, storage and imperative migration history. Never mix\nan existing migrations lifecycle with a new exports lifecycle. Use SQLite for\nnew namespaces; do not claim a deployed key-value class can be switched to it.\nCheck current cf\u002Fconfig helpers and generated lifecycle output against the\n[configuration reference](https:\u002F\u002Fdevelopers.cloudflare.com\u002Fcf\u002Fprojects\u002Fcloudflare-config\u002F).\nDo not infer correctness solely from a successful dry run: an ignored lifecycle\nentry can pass packaging and still deploy the wrong storage.\n\n## Lifecycle changes are dangerous\n\nDefining a class locally is safe. Renaming, deleting or transferring a class is a\ndata-affecting operation:\n\n- It is atomic: it cannot be uploaded as a version or deployed gradually, and\n  you cannot roll back past it. After approval, deploy it alone with\n  `cf deploy`.\n- Deleting a class deletes its stored data. Renaming without a rename entry\n  orphans data.\n- Always show the diff of the `exports` \u002F `migrations` block to the user, name\n  the class and say whether data is lost, and wait for approval, as described\n  in `cloudflare-deploy`.\n\n## WebSockets: use hibernation\n\n```ts\nasync fetch(request: Request) {\n  if (request.headers.get(\"Upgrade\") !== \"websocket\") return new Response(\"Expected WebSocket\", { status: 426 });\n  const [client, server] = Object.values(new WebSocketPair());\n  this.ctx.acceptWebSocket(server); \u002F\u002F not server.accept(): this allows hibernation\n  server.serializeAttachment({ joinedAt: Date.now() }); \u002F\u002F survives hibernation\n  return new Response(null, { status: 101, webSocket: client });\n}\nasync webSocketMessage(ws: WebSocket, message: string | ArrayBuffer) {\n  for (const peer of this.ctx.getWebSockets()) peer.send(message);\n}\nasync webSocketClose(ws: WebSocket, code: number, reason: string) { ws.close(code, reason); }\n```\n\n- Do not use `addEventListener` for server-side sockets in a Durable Object.\n- Memory is lost on hibernation. Anything needed after wake-up goes in storage or\n  `serializeAttachment`.\n- A pending `setTimeout`\u002F`setInterval` or an outbound WebSocket keeps the object\n  awake and billing; use alarms instead.\n\n## Alarms\n\n```ts\nawait this.ctx.storage.setAlarm(Date.now() + 60_000);\nasync alarm() { \u002F* do work; call setAlarm again to repeat *\u002F }\n```\n\nAlarms do not repeat on their own, and each object has one pending alarm. Only\nschedule one when there is work to do; waking many objects every few seconds is\nexpensive.\n\n## Rules of thumb\n\n- Methods on the object are RPC: arguments and results must be structured-\n  cloneable; throw errors you want the caller to see.\n- Reads and writes inside one request are protected by input\u002Foutput gates; use\n  `blockConcurrencyWhile` only for initialization.\n- Derive the object name from something stable (`getByName(userId)`), and\n  validate it; a user-supplied name creates an object.\n- Test with `@cloudflare\u002Fvitest-pool-workers`: call RPC methods on a stub and\n  trigger alarms with `runDurableObjectAlarm(stub)`. Run `cf dev` to try\n  it locally; state is simulated.\n\n## Checklist\n\n- [ ] one object per logical unit, named deterministically\n- [ ] SQLite storage; lifecycle entry present; one lifecycle style\n- [ ] WebSockets use `acceptWebSocket` and handler methods\n- [ ] no lifecycle change shipped without explicit approval\n- [ ] local tests exercise the RPC methods and any alarm\n","# Cloudflare Durable Objects\n\nA Durable Object is a class whose named instances each run in one place with\ntheir own storage. Use one object per coordination unit (a chat room, a\ndocument, a user, a game): that unit is the \"atom\". A single global object is a\nbottleneck and almost always the wrong design.\n\nCheck current syntax with the `cloudflare-docs` plugin or\nhttps:\u002F\u002Fdevelopers.cloudflare.com\u002Fdurable-objects\u002F before relying on memory;\nclass lifecycle configuration changed recently (see below).\n\n## Minimal SQLite-backed object with RPC\n\n```ts\nimport { DurableObject } from \"cloudflare:workers\";\n\nexport class Counter extends DurableObject\u003CEnv> {\n  constructor(ctx: DurableObjectState, env: Env) {\n    super(ctx, env);\n    \u002F\u002F Runs on every wake-up: keep it cheap and idempotent.\n    ctx.blockConcurrencyWhile(async () => {\n      ctx.storage.sql.exec(\"CREATE TABLE IF NOT EXISTS hits (n INTEGER NOT NULL)\");\n      ctx.storage.sql.exec(\"INSERT INTO hits (n) SELECT 0 WHERE NOT EXISTS (SELECT 1 FROM hits)\");\n    });\n  }\n\n  increment(): number {\n    this.ctx.storage.sql.exec(\"UPDATE hits SET n = n + 1\");\n    return this.ctx.storage.sql.exec(\"SELECT n FROM hits\").one().n as number;\n  }\n}\n\nexport default {\n  async fetch(request: Request, env: Env): Promise\u003CResponse> {\n    const stub = env.COUNTER.getByName(new URL(request.url).searchParams.get(\"id\") ?? \"default\");\n    return Response.json({ n: await stub.increment() }); \u002F\u002F RPC call\n  },\n} satisfies ExportedHandler\u003CEnv>;\n```\n\nBinding and SQLite lifecycle are declared together in typed config:\n\n```ts\nimport { bindings, defineConfig, exports } from \"cf\u002Fconfig\";\nexport default defineConfig({\n  worker: {\n    name: \"counter\", entrypoint: \"src\u002Findex.ts\", compatibilityDate: \"2026-10-01\",\n    env: { COUNTER: bindings.durableObject({ worker: \"counter\", exportName: \"Counter\" }) },\n    exports: { Counter: exports.durableObject({ storage: \"sqlite\" }) },\n  },\n});\n```\n\nReview `cf migrate --dry-run` for legacy configurations and preserve the\nexisting class identity, storage and imperative migration history. Never mix\nan existing migrations lifecycle with a new exports lifecycle. Use SQLite for\nnew namespaces; do not claim a deployed key-value class can be switched to it.\nCheck current cf\u002Fconfig helpers and generated lifecycle output against the\n[configuration reference](https:\u002F\u002Fdevelopers.cloudflare.com\u002Fcf\u002Fprojects\u002Fcloudflare-config\u002F).\nDo not infer correctness solely from a successful dry run: an ignored lifecycle\nentry can pass packaging and still deploy the wrong storage.\n\n## Lifecycle changes are dangerous\n\nDefining a class locally is safe. Renaming, deleting or transferring a class is a\ndata-affecting operation:\n\n- It is atomic: it cannot be uploaded as a version or deployed gradually, and\n  you cannot roll back past it. After approval, deploy it alone with\n  `cf deploy`.\n- Deleting a class deletes its stored data. Renaming without a rename entry\n  orphans data.\n- Always show the diff of the `exports` \u002F `migrations` block to the user, name\n  the class and say whether data is lost, and wait for approval, as described\n  in `cloudflare-deploy`.\n\n## WebSockets: use hibernation\n\n```ts\nasync fetch(request: Request) {\n  if (request.headers.get(\"Upgrade\") !== \"websocket\") return new Response(\"Expected WebSocket\", { status: 426 });\n  const [client, server] = Object.values(new WebSocketPair());\n  this.ctx.acceptWebSocket(server); \u002F\u002F not server.accept(): this allows hibernation\n  server.serializeAttachment({ joinedAt: Date.now() }); \u002F\u002F survives hibernation\n  return new Response(null, { status: 101, webSocket: client });\n}\nasync webSocketMessage(ws: WebSocket, message: string | ArrayBuffer) {\n  for (const peer of this.ctx.getWebSockets()) peer.send(message);\n}\nasync webSocketClose(ws: WebSocket, code: number, reason: string) { ws.close(code, reason); }\n```\n\n- Do not use `addEventListener` for server-side sockets in a Durable Object.\n- Memory is lost on hibernation. Anything needed after wake-up goes in storage or\n  `serializeAttachment`.\n- A pending `setTimeout`\u002F`setInterval` or an outbound WebSocket keeps the object\n  awake and billing; use alarms instead.\n\n## Alarms\n\n```ts\nawait this.ctx.storage.setAlarm(Date.now() + 60_000);\nasync alarm() { \u002F* do work; call setAlarm again to repeat *\u002F }\n```\n\nAlarms do not repeat on their own, and each object has one pending alarm. Only\nschedule one when there is work to do; waking many objects every few seconds is\nexpensive.\n\n## Rules of thumb\n\n- Methods on the object are RPC: arguments and results must be structured-\n  cloneable; throw errors you want the caller to see.\n- Reads and writes inside one request are protected by input\u002Foutput gates; use\n  `blockConcurrencyWhile` only for initialization.\n- Derive the object name from something stable (`getByName(userId)`), and\n  validate it; a user-supplied name creates an object.\n- Test with `@cloudflare\u002Fvitest-pool-workers`: call RPC methods on a stub and\n  trigger alarms with `runDurableObjectAlarm(stub)`. Run `cf dev` to try\n  it locally; state is simulated.\n\n## Checklist\n\n- [ ] one object per logical unit, named deterministically\n- [ ] SQLite storage; lifecycle entry present; one lifecycle style\n- [ ] WebSockets use `acceptWebSocket` and handler methods\n- [ ] no lifecycle change shipped without explicit approval\n- [ ] local tests exercise the RPC methods and any alarm\n",{"name":5,"description":7},"main","e83cac15fc63134280e964895df4d584e5702c13","plugins\u002Fcloudflare\u002Fskills\u002Fcloudflare-durable-objects",2,"https:\u002F\u002Fgithub.com\u002Fcodewhale-hq\u002Fcodewhale-plugin-marketplace","https:\u002F\u002Fcodewhale.net","https:\u002F\u002Fgithub.com\u002Fcodewhale-hq","Open-source coding agent for your terminal. Works with the model provider you choose.","2026-11-13 11:48:42",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add codewhale-hq\u002Fcodewhale-plugin-marketplace --skill cloudflare-durable-objects",{"tool":39,"command":40},"bunx","bunx skills add codewhale-hq\u002Fcodewhale-plugin-marketplace --skill cloudflare-durable-objects",{"tool":42,"command":43},"pnpm","pnpm dlx skills add codewhale-hq\u002Fcodewhale-plugin-marketplace --skill cloudflare-durable-objects","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fcodewhale-hq\u002Fcodewhale-plugin-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fcloudflare\u002Fskills\u002Fcloudflare-durable-objects\u002FSKILL.md",true,[],[48,55,62,69,75,82],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M7CG92AM4VSATJQ927PE34G4","xlsx","Create\u002Fedit\u002Fanalyze\u002Fverify spreadsheet workbooks including XLSX\u002FCSV\u002FTSV.","https:\u002F\u002Fgithub.com\u002Fcodewhale-hq\u002Fcodewhale-plugin-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fxlsx\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M7CG8ZBZXPCJACH06SFV39NM","webapp-testing","Start\u002Freuse a local app, wait for readiness, inspect rendered state\u002Fconsole\u002Fnetwork, act from observed selectors, and verify with evidence.","https:\u002F\u002Fgithub.com\u002Fcodewhale-hq\u002Fcodewhale-plugin-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M7CG8XF83CD62S7TCPMECV4N","verify","Exercise the real app\u002FAPI\u002FCLI and collect observable evidence; tests alone do not count as end-to-end verification.","https:\u002F\u002Fgithub.com\u002Fcodewhale-hq\u002Fcodewhale-plugin-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fverify\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M7CG8VF7HN4EHQM3PP877PB6","tts","https:\u002F\u002Fgithub.com\u002Fcodewhale-hq\u002Fcodewhale-plugin-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Ftts\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M7CG8RSMADT0QKP2ZSF6EN6T","test","Detect the project’s test stack, run the narrowest useful tests, create tests when authorized, and report coverage\u002Fgaps honestly.","https:\u002F\u002Fgithub.com\u002Fcodewhale-hq\u002Fcodewhale-plugin-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Ftest\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M7CG8MQTZ8VT7E4V3VY78F8X","spreadsheets","Compatibility alias for the xlsx skill. Prefer loading xlsx.","https:\u002F\u002Fgithub.com\u002Fcodewhale-hq\u002Fcodewhale-plugin-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fspreadsheets\u002FSKILL.md",[],[]]