pi-cloudflare 0.10.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/README.md +78 -177
  2. package/package.json +7 -42
  3. package/plugin.json +3 -3
  4. package/skills/agents-sdk/SKILL.md +17 -36
  5. package/skills/agents-sdk/references/client-sdk.md +7 -106
  6. package/skills/agents-sdk/references/human-in-the-loop.md +6 -63
  7. package/skills/agents-sdk/references/mcp.md +9 -184
  8. package/skills/agents-sdk/references/queue-retries.md +12 -73
  9. package/skills/agents-sdk/references/server-driven-messages.md +4 -60
  10. package/skills/agents-sdk/references/state-scheduling.md +10 -166
  11. package/skills/agents-sdk/references/streaming-chat.md +11 -193
  12. package/skills/agents-sdk/references/webhooks-push.md +2 -2
  13. package/skills/agents-sdk/references/workflows.md +14 -125
  14. package/skills/cloudflare/SKILL.md +135 -248
  15. package/skills/cloudflare/references/ai-gateway/README.md +17 -165
  16. package/skills/cloudflare/references/ai-gateway/configuration.md +14 -107
  17. package/skills/cloudflare/references/ai-gateway/dynamic-routing.md +12 -79
  18. package/skills/cloudflare/references/ai-gateway/features.md +22 -96
  19. package/skills/cloudflare/references/ai-gateway/sdk-integration.md +17 -112
  20. package/skills/cloudflare/references/ai-gateway/troubleshooting.md +14 -86
  21. package/skills/cloudflare/references/ai-search/README.md +17 -130
  22. package/skills/cloudflare/references/ai-search/api.md +10 -84
  23. package/skills/cloudflare/references/ai-search/configuration.md +16 -88
  24. package/skills/cloudflare/references/ai-search/gotchas.md +13 -81
  25. package/skills/cloudflare/references/ai-search/patterns.md +12 -82
  26. package/skills/cloudflare/references/analytics-engine/api.md +1 -1
  27. package/skills/cloudflare/references/api/README.md +2 -2
  28. package/skills/cloudflare/references/api/configuration.md +1 -1
  29. package/skills/cloudflare/references/bindings/README.md +11 -117
  30. package/skills/cloudflare/references/bindings/api.md +17 -201
  31. package/skills/cloudflare/references/bindings/configuration.md +20 -188
  32. package/skills/cloudflare/references/bindings/gotchas.md +16 -206
  33. package/skills/cloudflare/references/bindings/patterns.md +15 -195
  34. package/skills/cloudflare/references/bot-management/README.md +1 -1
  35. package/skills/cloudflare/references/browser-rendering/README.md +13 -73
  36. package/skills/cloudflare/references/browser-rendering/api.md +9 -105
  37. package/skills/cloudflare/references/browser-rendering/configuration.md +9 -75
  38. package/skills/cloudflare/references/browser-rendering/gotchas.md +12 -85
  39. package/skills/cloudflare/references/browser-rendering/patterns.md +9 -88
  40. package/skills/cloudflare/references/c3/README.md +6 -5
  41. package/skills/cloudflare/references/c3/api.md +3 -4
  42. package/skills/cloudflare/references/c3/patterns.md +4 -6
  43. package/skills/cloudflare/references/cache-reserve/README.md +1 -1
  44. package/skills/cloudflare/references/containers/README.md +15 -77
  45. package/skills/cloudflare/references/containers/api.md +13 -187
  46. package/skills/cloudflare/references/containers/configuration.md +15 -188
  47. package/skills/cloudflare/references/containers/gotchas.md +16 -178
  48. package/skills/cloudflare/references/containers/patterns.md +14 -198
  49. package/skills/cloudflare/references/cron-triggers/README.md +13 -92
  50. package/skills/cloudflare/references/cron-triggers/api.md +11 -191
  51. package/skills/cloudflare/references/cron-triggers/configuration.md +11 -175
  52. package/skills/cloudflare/references/cron-triggers/gotchas.md +13 -195
  53. package/skills/cloudflare/references/cron-triggers/patterns.md +12 -184
  54. package/skills/cloudflare/references/d1/README.md +9 -127
  55. package/skills/cloudflare/references/d1/api.md +16 -194
  56. package/skills/cloudflare/references/d1/configuration.md +16 -189
  57. package/skills/cloudflare/references/d1/gotchas.md +16 -96
  58. package/skills/cloudflare/references/d1/patterns.md +14 -183
  59. package/skills/cloudflare/references/do-storage/README.md +11 -70
  60. package/skills/cloudflare/references/do-storage/api.md +11 -99
  61. package/skills/cloudflare/references/do-storage/configuration.md +11 -107
  62. package/skills/cloudflare/references/do-storage/gotchas.md +12 -147
  63. package/skills/cloudflare/references/do-storage/patterns.md +11 -190
  64. package/skills/cloudflare/references/do-storage/testing.md +8 -178
  65. package/skills/cloudflare/references/email-routing/README.md +14 -84
  66. package/skills/cloudflare/references/email-routing/api.md +10 -192
  67. package/skills/cloudflare/references/email-routing/configuration.md +13 -186
  68. package/skills/cloudflare/references/email-routing/gotchas.md +12 -193
  69. package/skills/cloudflare/references/email-routing/patterns.md +10 -226
  70. package/skills/cloudflare/references/email-workers/README.md +13 -146
  71. package/skills/cloudflare/references/email-workers/api.md +12 -234
  72. package/skills/cloudflare/references/email-workers/configuration.md +14 -110
  73. package/skills/cloudflare/references/email-workers/gotchas.md +15 -125
  74. package/skills/cloudflare/references/email-workers/patterns.md +14 -100
  75. package/skills/cloudflare/references/flagship/README.md +2 -2
  76. package/skills/cloudflare/references/hyperdrive/README.md +17 -72
  77. package/skills/cloudflare/references/hyperdrive/api.md +19 -136
  78. package/skills/cloudflare/references/hyperdrive/configuration.md +27 -159
  79. package/skills/cloudflare/references/hyperdrive/gotchas.md +15 -72
  80. package/skills/cloudflare/references/hyperdrive/patterns.md +12 -187
  81. package/skills/cloudflare/references/images/README.md +9 -58
  82. package/skills/cloudflare/references/images/api.md +13 -96
  83. package/skills/cloudflare/references/images/configuration.md +17 -211
  84. package/skills/cloudflare/references/images/gotchas.md +16 -99
  85. package/skills/cloudflare/references/images/patterns.md +16 -115
  86. package/skills/cloudflare/references/kv/README.md +9 -83
  87. package/skills/cloudflare/references/kv/api.md +12 -154
  88. package/skills/cloudflare/references/kv/configuration.md +11 -139
  89. package/skills/cloudflare/references/kv/gotchas.md +15 -129
  90. package/skills/cloudflare/references/kv/patterns.md +15 -190
  91. package/skills/cloudflare/references/miniflare/README.md +15 -98
  92. package/skills/cloudflare/references/miniflare/api.md +16 -187
  93. package/skills/cloudflare/references/miniflare/configuration.md +12 -169
  94. package/skills/cloudflare/references/miniflare/gotchas.md +15 -160
  95. package/skills/cloudflare/references/miniflare/patterns.md +15 -177
  96. package/skills/cloudflare/references/network-interconnect/README.md +1 -1
  97. package/skills/cloudflare/references/network-interconnect/gotchas.md +1 -1
  98. package/skills/cloudflare/references/network-interconnect/patterns.md +1 -1
  99. package/skills/cloudflare/references/observability/README.md +20 -81
  100. package/skills/cloudflare/references/observability/api.md +20 -164
  101. package/skills/cloudflare/references/observability/configuration.md +18 -164
  102. package/skills/cloudflare/references/observability/gotchas.md +19 -109
  103. package/skills/cloudflare/references/observability/patterns.md +12 -103
  104. package/skills/cloudflare/references/pages/README.md +13 -81
  105. package/skills/cloudflare/references/pages/api.md +10 -201
  106. package/skills/cloudflare/references/pages/configuration.md +16 -201
  107. package/skills/cloudflare/references/pages/gotchas.md +13 -197
  108. package/skills/cloudflare/references/pages/patterns.md +11 -200
  109. package/skills/cloudflare/references/pages-functions/README.md +13 -91
  110. package/skills/cloudflare/references/pages-functions/api.md +10 -140
  111. package/skills/cloudflare/references/pages-functions/configuration.md +11 -119
  112. package/skills/cloudflare/references/pages-functions/gotchas.md +17 -94
  113. package/skills/cloudflare/references/pages-functions/patterns.md +12 -133
  114. package/skills/cloudflare/references/pipelines/README.md +1 -1
  115. package/skills/cloudflare/references/pulumi/README.md +2 -2
  116. package/skills/cloudflare/references/queues/README.md +15 -87
  117. package/skills/cloudflare/references/queues/api.md +10 -200
  118. package/skills/cloudflare/references/queues/configuration.md +18 -142
  119. package/skills/cloudflare/references/queues/gotchas.md +16 -204
  120. package/skills/cloudflare/references/queues/patterns.md +19 -218
  121. package/skills/cloudflare/references/r2/README.md +17 -86
  122. package/skills/cloudflare/references/r2/api.md +14 -198
  123. package/skills/cloudflare/references/r2/configuration.md +17 -163
  124. package/skills/cloudflare/references/r2/gotchas.md +15 -188
  125. package/skills/cloudflare/references/r2/patterns.md +16 -191
  126. package/skills/cloudflare/references/r2-data-catalog/README.md +11 -70
  127. package/skills/cloudflare/references/r2-data-catalog/api.md +14 -89
  128. package/skills/cloudflare/references/r2-data-catalog/configuration.md +15 -96
  129. package/skills/cloudflare/references/r2-data-catalog/gotchas.md +14 -51
  130. package/skills/cloudflare/references/r2-data-catalog/patterns.md +11 -116
  131. package/skills/cloudflare/references/realtime-sfu/README.md +1 -1
  132. package/skills/cloudflare/references/realtimekit/README.md +1 -1
  133. package/skills/cloudflare/references/secrets-store/README.md +14 -66
  134. package/skills/cloudflare/references/secrets-store/api.md +14 -193
  135. package/skills/cloudflare/references/secrets-store/configuration.md +16 -176
  136. package/skills/cloudflare/references/secrets-store/gotchas.md +14 -92
  137. package/skills/cloudflare/references/secrets-store/patterns.md +14 -194
  138. package/skills/cloudflare/references/smart-placement/README.md +2 -2
  139. package/skills/cloudflare/references/static-assets/README.md +15 -59
  140. package/skills/cloudflare/references/static-assets/api.md +12 -195
  141. package/skills/cloudflare/references/static-assets/configuration.md +16 -186
  142. package/skills/cloudflare/references/static-assets/gotchas.md +18 -162
  143. package/skills/cloudflare/references/static-assets/patterns.md +13 -185
  144. package/skills/cloudflare/references/stream/README.md +15 -107
  145. package/skills/cloudflare/references/stream/api-live.md +16 -193
  146. package/skills/cloudflare/references/stream/api.md +19 -197
  147. package/skills/cloudflare/references/stream/configuration.md +16 -139
  148. package/skills/cloudflare/references/stream/gotchas.md +16 -128
  149. package/skills/cloudflare/references/stream/patterns.md +20 -182
  150. package/skills/cloudflare/references/tail-workers/README.md +14 -82
  151. package/skills/cloudflare/references/tail-workers/api.md +10 -197
  152. package/skills/cloudflare/references/tail-workers/configuration.md +13 -174
  153. package/skills/cloudflare/references/tail-workers/gotchas.md +12 -188
  154. package/skills/cloudflare/references/tail-workers/patterns.md +11 -176
  155. package/skills/cloudflare/references/terraform/README.md +2 -2
  156. package/skills/cloudflare/references/tunnel/README.md +13 -122
  157. package/skills/cloudflare/references/tunnel/api.md +11 -190
  158. package/skills/cloudflare/references/tunnel/configuration.md +12 -155
  159. package/skills/cloudflare/references/tunnel/gotchas.md +12 -144
  160. package/skills/cloudflare/references/tunnel/networking.md +12 -166
  161. package/skills/cloudflare/references/tunnel/patterns.md +12 -189
  162. package/skills/cloudflare/references/vectorize/README.md +15 -126
  163. package/skills/cloudflare/references/vectorize/api.md +14 -84
  164. package/skills/cloudflare/references/vectorize/configuration.md +14 -83
  165. package/skills/cloudflare/references/vectorize/gotchas.md +12 -73
  166. package/skills/cloudflare/references/vectorize/patterns.md +17 -83
  167. package/skills/cloudflare/references/waf/README.md +15 -107
  168. package/skills/cloudflare/references/waf/api.md +17 -202
  169. package/skills/cloudflare/references/waf/configuration.md +14 -199
  170. package/skills/cloudflare/references/waf/gotchas.md +15 -200
  171. package/skills/cloudflare/references/waf/patterns.md +13 -193
  172. package/skills/cloudflare/references/workerd/README.md +2 -2
  173. package/skills/cloudflare/references/workers-ai/README.md +14 -187
  174. package/skills/cloudflare/references/workers-ai/api.md +10 -109
  175. package/skills/cloudflare/references/workers-ai/configuration.md +11 -92
  176. package/skills/cloudflare/references/workers-ai/gotchas.md +12 -111
  177. package/skills/cloudflare/references/workers-ai/patterns.md +9 -115
  178. package/skills/cloudflare/references/workers-for-platforms/README.md +3 -3
  179. package/skills/cloudflare/references/workers-vpc/README.md +1 -1
  180. package/skills/cloudflare/references/workflows/README.md +15 -69
  181. package/skills/cloudflare/references/workflows/api.md +12 -213
  182. package/skills/cloudflare/references/workflows/configuration.md +16 -150
  183. package/skills/cloudflare/references/workflows/gotchas.md +17 -88
  184. package/skills/cloudflare/references/workflows/patterns.md +19 -164
  185. package/skills/cloudflare-api-token/SKILL.md +1 -1
  186. package/skills/cloudflare-cf-cli/SKILL.md +44 -13
  187. package/skills/cloudflare-email-service/SKILL.md +6 -36
  188. package/skills/cloudflare-email-service/references/rest-api.md +12 -179
  189. package/skills/cloudflare-email-service/references/sending.md +17 -250
  190. package/skills/cloudflare-one/SKILL.md +4 -2
  191. package/skills/cloudflare-one-migrations/SKILL.md +1 -1
  192. package/skills/cloudflare-token-roll/SKILL.md +2 -5
  193. package/skills/durable-objects/SKILL.md +10 -16
  194. package/skills/durable-objects/references/rules.md +17 -293
  195. package/skills/durable-objects/references/testing.md +16 -257
  196. package/skills/nextjs-on-cloudflare/SKILL.md +33 -0
  197. package/skills/sandbox-migrate-to-next/SKILL.md +2 -2
  198. package/skills/sandbox-next/SKILL.md +3 -2
  199. package/skills/sandbox-next/references/api-quick-ref.md +15 -90
  200. package/skills/sandbox-stable/SKILL.md +1 -1
  201. package/skills/turnstile-spin/SKILL.md +14 -8
  202. package/skills/workers-best-practices/SKILL.md +36 -103
  203. package/skills/workers-best-practices/references/configuration.md +139 -0
  204. package/skills/workers-best-practices/references/platform-apis.md +51 -0
  205. package/skills/workers-best-practices/references/{rules.md → runtime-patterns.md} +9 -134
  206. package/skills/wrangler/SKILL.md +48 -901
  207. package/bin/setup.mjs +0 -119
  208. package/dist/api-token.d.ts +0 -12
  209. package/dist/api-token.d.ts.map +0 -1
  210. package/dist/api-token.js +0 -23
  211. package/dist/api-token.js.map +0 -1
  212. package/dist/auth-flow.d.ts +0 -15
  213. package/dist/auth-flow.d.ts.map +0 -1
  214. package/dist/auth-flow.js +0 -90
  215. package/dist/auth-flow.js.map +0 -1
  216. package/dist/client.d.ts +0 -18
  217. package/dist/client.d.ts.map +0 -1
  218. package/dist/client.js +0 -47
  219. package/dist/client.js.map +0 -1
  220. package/dist/config.d.ts +0 -20
  221. package/dist/config.d.ts.map +0 -1
  222. package/dist/config.js +0 -10
  223. package/dist/config.js.map +0 -1
  224. package/dist/index.d.ts +0 -22
  225. package/dist/index.d.ts.map +0 -1
  226. package/dist/index.js +0 -65
  227. package/dist/index.js.map +0 -1
  228. package/dist/mcp-server.d.ts +0 -2
  229. package/dist/mcp-server.d.ts.map +0 -1
  230. package/dist/mcp-server.js +0 -106
  231. package/dist/mcp-server.js.map +0 -1
  232. package/dist/oauth.d.ts +0 -44
  233. package/dist/oauth.d.ts.map +0 -1
  234. package/dist/oauth.js +0 -135
  235. package/dist/oauth.js.map +0 -1
  236. package/dist/proxy.d.ts +0 -30
  237. package/dist/proxy.d.ts.map +0 -1
  238. package/dist/proxy.js +0 -41
  239. package/dist/proxy.js.map +0 -1
  240. package/dist/result-caps.d.ts +0 -23
  241. package/dist/result-caps.d.ts.map +0 -1
  242. package/dist/result-caps.js +0 -75
  243. package/dist/result-caps.js.map +0 -1
  244. package/dist/runtime.d.ts +0 -72
  245. package/dist/runtime.d.ts.map +0 -1
  246. package/dist/runtime.js +0 -249
  247. package/dist/runtime.js.map +0 -1
  248. package/dist/servers.d.ts +0 -19
  249. package/dist/servers.d.ts.map +0 -1
  250. package/dist/servers.js +0 -40
  251. package/dist/servers.js.map +0 -1
  252. package/dist/token-store.d.ts +0 -32
  253. package/dist/token-store.d.ts.map +0 -1
  254. package/dist/token-store.js +0 -61
  255. package/dist/token-store.js.map +0 -1
  256. package/dist/tool-cache.d.ts +0 -25
  257. package/dist/tool-cache.d.ts.map +0 -1
  258. package/dist/tool-cache.js +0 -43
  259. package/dist/tool-cache.js.map +0 -1
  260. package/mcp.json +0 -15
  261. package/skills/cloudflare/references/agents-sdk/README.md +0 -89
  262. package/skills/cloudflare/references/agents-sdk/api.md +0 -190
  263. package/skills/cloudflare/references/agents-sdk/configuration.md +0 -182
  264. package/skills/cloudflare/references/agents-sdk/gotchas.md +0 -158
  265. package/skills/cloudflare/references/agents-sdk/patterns.md +0 -192
  266. package/skills/cloudflare/references/durable-objects/README.md +0 -185
  267. package/skills/cloudflare/references/durable-objects/api.md +0 -187
  268. package/skills/cloudflare/references/durable-objects/configuration.md +0 -160
  269. package/skills/cloudflare/references/durable-objects/gotchas.md +0 -197
  270. package/skills/cloudflare/references/durable-objects/patterns.md +0 -201
  271. package/skills/cloudflare/references/sandbox/README.md +0 -96
  272. package/skills/cloudflare/references/sandbox/api.md +0 -198
  273. package/skills/cloudflare/references/sandbox/configuration.md +0 -143
  274. package/skills/cloudflare/references/sandbox/gotchas.md +0 -194
  275. package/skills/cloudflare/references/sandbox/patterns.md +0 -201
  276. package/skills/cloudflare/references/turnstile/README.md +0 -99
  277. package/skills/cloudflare/references/turnstile/api.md +0 -240
  278. package/skills/cloudflare/references/turnstile/configuration.md +0 -222
  279. package/skills/cloudflare/references/turnstile/gotchas.md +0 -218
  280. package/skills/cloudflare/references/turnstile/patterns.md +0 -193
  281. package/skills/cloudflare/references/workers/README.md +0 -108
  282. package/skills/cloudflare/references/workers/api.md +0 -195
  283. package/skills/cloudflare/references/workers/configuration.md +0 -185
  284. package/skills/cloudflare/references/workers/frameworks.md +0 -197
  285. package/skills/cloudflare/references/workers/gotchas.md +0 -137
  286. package/skills/cloudflare/references/workers/patterns.md +0 -198
  287. package/skills/cloudflare/references/wrangler/README.md +0 -135
  288. package/skills/cloudflare/references/wrangler/api.md +0 -188
  289. package/skills/cloudflare/references/wrangler/configuration.md +0 -197
  290. package/skills/cloudflare/references/wrangler/gotchas.md +0 -197
  291. package/skills/cloudflare/references/wrangler/patterns.md +0 -209
  292. package/skills/cloudflare-auth-setup/SKILL.md +0 -59
  293. package/skills/workers-best-practices/references/review.md +0 -174
@@ -1,94 +1,19 @@
1
- # `@next` cheatsheet (not the full API)
1
+ # Sandbox `@next` API documentation
2
2
 
3
- Scan aid for the **process / terminal / interpreter** shapes that differ most from stable. **Not exhaustive.**
3
+ Use this reference after the **sandbox-next** package-line gate. Existing stable apps use **sandbox-stable**; stable-to-preview migrations use **sandbox-migrate-to-next**.
4
4
 
5
- | For… | Go here |
6
- | ---- | ------- |
7
- | Full signatures and types | Installed `@cloudflare/sandbox@next` package types |
8
- | Preview API hub | https://developers.cloudflare.com/sandbox/1-0-preview/api/ |
9
- | Processes · terminals · errors · interpreter | Same hub (dedicated pages) |
10
- | Files, mounts, backups, ports, tunnels, lifecycle options | Main docs linked from the hub and from **`sandbox-next`** § Retrieve — ignore stable-only session/transport bits |
11
- | Mental model (exec, durability, ID vs container) | https://developers.cloudflare.com/sandbox/1-0-preview/processes/ · https://developers.cloudflare.com/sandbox/1-0-preview/lifecycle/ |
12
- | `Sandbox` extends `Container` | [Cloudflare Containers](https://developers.cloudflare.com/containers/) + Sandbox lifecycle docs above |
5
+ Fetch the page for the task before implementing and check signatures against installed `@cloudflare/sandbox@next` types.
13
6
 
14
- If something is missing here, it is almost certainly **documented elsewhere or in types**—do not invent it from this file.
7
+ | Task | Documentation |
8
+ | --- | --- |
9
+ | Launch commands, collect output, stream logs, wait for readiness, inspect or stop processes | [Processes API](https://developers.cloudflare.com/sandbox/1-0-preview/api/processes/) and [Process execution](https://developers.cloudflare.com/sandbox/1-0-preview/processes/) |
10
+ | Understand sandbox IDs, container lifetime, sleep, destruction, and durable state | [Sandbox lifecycle](https://developers.cloudflare.com/sandbox/1-0-preview/lifecycle/) |
11
+ | Configure sleep, keep-alive, and ID normalization | [Sandbox options](https://developers.cloudflare.com/sandbox/configuration/sandbox-options/); omit removed session and transport fields on `@next`. |
12
+ | Create, connect, write to, resize, or stop interactive terminals | [Terminals API](https://developers.cloudflare.com/sandbox/1-0-preview/api/terminals/) and [Terminals](https://developers.cloudflare.com/sandbox/1-0-preview/terminals/) |
13
+ | Attach the interpreter, manage contexts, run code, or consume streamed results | [Interpreter](https://developers.cloudflare.com/sandbox/1-0-preview/interpreter/) and [Interpreter API](https://developers.cloudflare.com/sandbox/1-0-preview/api/interpreter/) |
14
+ | Set sandbox or per-launch environment | [Environment variables](https://developers.cloudflare.com/sandbox/1-0-preview/environment/) |
15
+ | Keep external API credentials in the Worker | [Outbound traffic](https://developers.cloudflare.com/sandbox/guides/outbound-traffic/) |
16
+ | Handle startup failures, interrupted work, stale handles, or local wait cancellation | [Errors and recovery](https://developers.cloudflare.com/sandbox/1-0-preview/errors/) and [Errors API](https://developers.cloudflare.com/sandbox/1-0-preview/api/errors/) |
17
+ | Find other preview APIs | [Preview API reference](https://developers.cloudflare.com/sandbox/1-0-preview/api/) |
15
18
 
16
- ---
17
-
18
- ## Lifecycle (common options)
19
-
20
- ```ts
21
- getSandbox(binding, sandboxId, options?: {
22
- sleepAfter?: string | number;
23
- keepAlive?: boolean;
24
- normalizeId?: boolean;
25
- }): Sandbox
26
-
27
- await sandbox.destroy(): Promise<void>
28
- ```
29
-
30
- No `transport` / `enableDefaultSession` on `@next`.
31
-
32
- ## Processes
33
-
34
- ```ts
35
- await sandbox.exec(argv: readonly [string, ...string[]], options?: {
36
- cwd?: string;
37
- env?: Record<string, string>;
38
- timeout?: number; // remote process lifetime
39
- }): Promise<SandboxProcess>
40
-
41
- await sandbox.getProcess(id: string): Promise<SandboxProcess | null>
42
- await sandbox.listProcesses(): Promise<ProcessStatus[]>
43
-
44
- await process.output({ encoding?: "utf8"; maxBytes?; timeout?; signal? })
45
- await process.logs({ since?; replay?; follow?; signal? })
46
- await process.waitForExit({ timeout?; signal? })
47
- await process.waitForPort(port, { mode?: "tcp" | "http"; path?; timeout?; ... })
48
- await process.waitForLog(pattern, { stream?; timeout?; signal? })
49
- await process.kill(signal?: number) // default 15
50
- await process.status()
51
- ```
52
-
53
- `await exec` = launch succeeded, not exit. No process stdin.
54
-
55
- ## Terminals
56
-
57
- ```ts
58
- await sandbox.createTerminal({
59
- command: readonly [string, ...string[]];
60
- cwd?; env?; cols?; rows?; bufferSize?;
61
- }): Promise<Terminal>
62
-
63
- await sandbox.getTerminal(id): Promise<Terminal | null>
64
- await sandbox.listTerminals(): Promise<Terminal[]>
65
-
66
- await terminal.connect(request, { cursor?; cols?; rows? })
67
- await terminal.write(data: Uint8Array)
68
- await terminal.resize(cols, rows)
69
- await terminal.output({ since?; replay?; follow?; signal? })
70
- await terminal.interrupt()
71
- await terminal.terminate()
72
- ```
73
-
74
- ## Interpreter (extension)
75
-
76
- ```ts
77
- import { withInterpreter } from "@cloudflare/sandbox/interpreter";
78
- // subclass: interpreter = withInterpreter(this)
79
-
80
- await sandbox.interpreter.createCodeContext({ language?, cwd? })
81
- await sandbox.interpreter.runCode(code, { context?, language?, onStdout?, ... })
82
- await sandbox.interpreter.runCodeStream(code, { context?, language? })
83
- await sandbox.interpreter.listCodeContexts()
84
- await sandbox.interpreter.deleteCodeContext(id)
85
- ```
86
-
87
- ## Environment
88
-
89
- ```ts
90
- await sandbox.setEnvVars(Record<string, string | undefined>) // undefined removes
91
- // plus env on exec / createTerminal
92
- ```
93
-
94
- Non-secret config only. Secrets: Worker + outbound handlers.
19
+ For files, mounts, backups, ports, and tunnels, follow the shared-surface links in the [preview overview](https://developers.cloudflare.com/sandbox/1-0-preview/). Use main-docs signatures only where that overview says they still apply; ignore stable-only session and transport options.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: sandbox-stable
3
- description: Use when building or changing Cloudflare Sandbox apps on the current stable @cloudflare/sandbox package (default npm tag)—commands, sessions, files, ports, tunnels, terminals, bridge, production, or deprecated-API cleanup while staying on stable. Not for @cloudflare/sandbox@next (use sandbox-next) or for porting to 1.0 (use sandbox-migrate-to-next).
3
+ description: Build or maintain Cloudflare Sandbox apps on the stable @cloudflare/sandbox package. Use sandbox-next for preview apps and sandbox-migrate-to-next for stable-to-preview migrations.
4
4
  ---
5
5
 
6
6
  # Sandbox SDK — stable package
@@ -1,13 +1,6 @@
1
1
  ---
2
2
  name: turnstile-spin
3
- description: Set up Cloudflare Turnstile end-to-end in a project. Scan the codebase, create the widget via the Cloudflare API, embed it where user requests need bot verification (form submissions, SPA actions, API endpoints, download links, comment or vote submissions, etc.), wire canonical server-side siteverify in the customer's existing backend, validate, and persist the skill. Load this when a user asks to add Turnstile, set up CAPTCHA, protect a form or endpoint from bots, or fix a Turnstile integration. Mirrors developers.cloudflare.com/turnstile/spin.
4
- references:
5
- - vanilla-html
6
- - nextjs-app
7
- - nextjs-pages
8
- - astro
9
- - sveltekit
10
- - hugo
3
+ description: Set up, repair, or migrate to Cloudflare Turnstile bot verification in an existing frontend and backend, including server-side Siteverify.
11
4
  ---
12
5
 
13
6
  # Turnstile Spin skill
@@ -18,6 +11,19 @@ You are the agent. Run the wizard below by invoking the scripts under `scripts/`
18
11
 
19
12
  This file is the canonical machine-readable behavior. Product requirements come from the [Turnstile documentation](https://developers.cloudflare.com/turnstile/), and the hosted prompt must mirror this behavior.
20
13
 
14
+ ## Framework references
15
+
16
+ Read the reference for the existing frontend when wiring the integration:
17
+
18
+ | Frontend | Reference |
19
+ |---|---|
20
+ | Vanilla HTML | [vanilla-html](references/vanilla-html.md) |
21
+ | Next.js App Router | [nextjs-app](references/nextjs-app.md) |
22
+ | Next.js Pages Router | [nextjs-pages](references/nextjs-pages.md) |
23
+ | Astro | [astro](references/astro.md) |
24
+ | SvelteKit | [sveltekit](references/sveltekit.md) |
25
+ | Hugo | [hugo](references/hugo.md) |
26
+
21
27
  ## When to load this skill
22
28
 
23
29
  Load when the user's prompt mentions any of:
@@ -1,115 +1,55 @@
1
1
  ---
2
2
  name: workers-best-practices
3
- description: Reviews and authors Cloudflare Workers code against production best practices. Load when writing new Workers, reviewing Worker code, configuring wrangler.jsonc, or checking for common Workers anti-patterns (streaming, floating promises, global state, secrets, bindings, observability). Biases towards retrieval from Cloudflare docs over pre-trained knowledge.
3
+ description: Cloudflare Workers best practices for production applications. Use when writing, reviewing, or configuring Workers.
4
4
  ---
5
5
 
6
- Your knowledge of Cloudflare Workers APIs, types, and configuration may be outdated. **Prefer retrieval over pre-training** for any Workers code task — writing or reviewing.
6
+ Your knowledge of Cloudflare Workers APIs, types, and configuration may be outdated. **Prefer retrieval over pre-training** when writing or reviewing Workers code.
7
7
 
8
- ## Retrieval Sources
8
+ Use the project's installed versions, generated types, and Wrangler compatibility settings as the baseline for existing code. Retrieve relevant Cloudflare documentation to verify API, configuration, runtime behavior, and limit claims.
9
9
 
10
- Fetch the **latest** versions before writing or reviewing Workers code. Do not rely on baked-in knowledge for API signatures, config fields, or binding shapes.
10
+ ## References
11
11
 
12
- | Source | How to retrieve | Use for |
13
- |--------|----------------|---------|
14
- | Workers best practices | Fetch `https://developers.cloudflare.com/workers/best-practices/workers-best-practices/` | Canonical rules, patterns, anti-patterns |
15
- | Workers types | See `references/review.md` for retrieval steps | API signatures, handler types, binding types |
16
- | Wrangler config schema | `node_modules/wrangler/config-schema.json` | Config fields, binding shapes, allowed values |
17
- | Cloudflare docs | Search tool or `https://developers.cloudflare.com/workers/` | API reference, compatibility dates/flags |
12
+ Read the sections relevant to the task:
18
13
 
19
- ## FIRST: Fetch Latest References
14
+ | Reference | When to use it |
15
+ |-----------|----------------|
16
+ | [Configuration and observability](references/configuration.md) | Compatibility dates, bindings, generated types, secrets, logs, and traces |
17
+ | [Runtime patterns](references/runtime-patterns.md) | Streaming, promise lifetime, request state, service calls, security, and runtime tests |
18
+ | [Platform API checks](references/platform-apis.md) | Handler signatures, platform classes, binding access, and serialization |
20
19
 
21
- Before reviewing or writing Workers code, retrieve the current best practices page and relevant type definitions. If the project's `node_modules` has an older version, **prefer the latest published version**.
20
+ For missing evidence, consult [Workers best practices](https://developers.cloudflare.com/workers/best-practices/workers-best-practices/) or find the affected product in the [Cloudflare docs directory](https://developers.cloudflare.com/directory/). Use the installed Wrangler schema for config fields. A newer type package does not supersede the project's configured target.
22
21
 
23
- ```bash
24
- # Fetch latest workers types
25
- mkdir -p /tmp/workers-types-latest && \
26
- npm pack @cloudflare/workers-types --pack-destination /tmp/workers-types-latest && \
27
- tar -xzf /tmp/workers-types-latest/cloudflare-workers-types-*.tgz -C /tmp/workers-types-latest
28
- # Types at /tmp/workers-types-latest/package/index.d.ts
29
- ```
22
+ ## Keep Compatibility Dates Current
30
23
 
31
- ## Reference Documentation
24
+ Use today's date for new Workers. Encourage periodic updates for existing Workers, reviewing compatibility changes and running relevant tests. Assess existing behavior against its configured date and flags; see [compatibility guidance](references/configuration.md#keep-compatibility_date-current).
32
25
 
33
- - `references/rules.md` — all best practice rules with code examples and anti-patterns
34
- - `references/review.md` — type validation, config validation, binding access patterns, review process
26
+ ## Enable Observability
35
27
 
36
- ## Rules Quick Reference
37
-
38
- ### Configuration
39
-
40
- | Rule | Summary |
41
- |------|---------|
42
- | Compatibility date | Set `compatibility_date` to today on new projects; update periodically on existing ones |
43
- | nodejs_compat | Enable the `nodejs_compat` flag — many libraries depend on Node.js built-ins |
44
- | wrangler types | Run `wrangler types` to generate `Env` — never hand-write binding interfaces |
45
- | Secrets | Use `wrangler secret put`, never hardcode secrets in config or source |
46
- | wrangler.jsonc | Use JSONC config for non-secret settings — newer features are JSON-only |
47
-
48
- ### Request & Response Handling
49
-
50
- | Rule | Summary |
51
- |------|---------|
52
- | Streaming | Stream large/unknown payloads — never `await response.text()` on unbounded data |
53
- | waitUntil | Use `ctx.waitUntil()` for post-response work; do not destructure `ctx` |
54
-
55
- ### Architecture
56
-
57
- | Rule | Summary |
58
- |------|---------|
59
- | Bindings over REST | Use in-process bindings (KV, R2, D1, Queues) — not the Cloudflare REST API |
60
- | Queues & Workflows | Move async/background work off the critical path |
61
- | Service bindings | Use service bindings for Worker-to-Worker calls — not public HTTP |
62
- | Hyperdrive | Always use Hyperdrive for external PostgreSQL/MySQL connections |
63
-
64
- ### Observability
65
-
66
- | Rule | Summary |
67
- |------|---------|
68
- | Logs & Traces | Enable `observability` in config with `head_sampling_rate`; use structured JSON logging |
69
-
70
- ### Code Patterns
71
-
72
- | Rule | Summary |
73
- |------|---------|
74
- | No global request state | Never store request-scoped data in module-level variables |
75
- | Floating promises | Every Promise must be `await`ed, `return`ed, `void`ed, or passed to `ctx.waitUntil()` |
76
-
77
- ### Security
78
-
79
- | Rule | Summary |
80
- |------|---------|
81
- | Web Crypto | Use `crypto.randomUUID()` / `crypto.getRandomValues()` — never `Math.random()` for security |
82
- | No passThroughOnException | Use explicit try/catch with structured error responses |
28
+ Enable [Workers Logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/) and [Traces](https://developers.cloudflare.com/workers/observability/traces/) when creating or preparing a Worker for production. Set `observability.enabled` and `observability.traces.enabled` to `true`; the top-level setting alone does not enable traces. Use structured JSON logging and configure sampling for the workload. During reviews, flag missing logs or traces. See the [configuration example](references/configuration.md#enable-workers-logs-and-traces).
83
29
 
84
30
  ## Anti-Patterns to Flag
85
31
 
86
- | Anti-pattern | Why it matters |
87
- |-------------|----------------|
88
- | `await response.text()` on unbounded data | Memory exhaustion — 128 MB limit |
89
- | Hardcoded secrets in source or config | Credential leak via version control |
90
- | `Math.random()` for tokens/IDs | Predictable, not cryptographically secure |
91
- | Bare `fetch()` without `await` or `waitUntil` | Floating promise — dropped result, swallowed error |
92
- | Module-level mutable variables for request state | Cross-request data leaks, stale state, I/O errors |
93
- | Cloudflare REST API from inside a Worker | Unnecessary network hop, auth overhead, added latency |
94
- | `ctx.passThroughOnException()` as error handling | Hides bugs, makes debugging impossible |
95
- | Hand-written `Env` interface | Drifts from actual wrangler config bindings |
96
- | Direct string comparison for secret values | Timing side-channel — use `crypto.subtle.timingSafeEqual` |
97
- | Destructuring `ctx` (`const { waitUntil } = ctx`) | Loses `this` binding — throws "Illegal invocation" at runtime |
98
- | `any` on `Env` or handler params | Defeats type safety for all binding access |
99
- | `as unknown as T` double-cast | Hides real type incompatibilities — fix the design |
100
- | `implements` on platform base classes (instead of `extends`) | Legacy — loses `this.ctx`, `this.env`. Applies to DurableObject, WorkerEntrypoint, Workflow |
101
- | `env.X` inside platform base class | Should be `this.env.X` in classes extending DurableObject, WorkerEntrypoint, etc. |
102
-
103
- ## Review Workflow
104
-
105
- 1. **Retrieve** — fetch latest best practices page, workers types, and wrangler schema
106
- 2. **Read full files** — not just diffs; context matters for binding access patterns
107
- 3. **Check types** — binding access, handler signatures, no `any`, no unsafe casts (see `references/review.md`)
108
- 4. **Check config** — compatibility_date, nodejs_compat, observability, secrets, binding-code consistency
109
- 5. **Check patterns** — streaming, floating promises, global state, serialization boundaries
110
- 6. **Check security** — crypto usage, secret handling, timing-safe comparisons, error handling
111
- 7. **Validate with tools** — `npx tsc --noEmit`, lint for `no-floating-promises`
112
- 8. **Reference rules** — see `references/rules.md` for each rule's correct pattern
32
+ | Anti-pattern | Consequence and preferred pattern |
33
+ |-------------|-----------------------------------|
34
+ | `await response.text()` or similar buffering on unbounded data | Can exhaust Worker memory; [stream large or unbounded bodies](references/runtime-patterns.md#stream-request-and-response-bodies). |
35
+ | Hardcoded secrets in source or config | Leaks credentials through version control; use Wrangler secrets. |
36
+ | `Math.random()` for security-sensitive tokens or IDs | Predictable values; use `crypto.randomUUID()` or `crypto.getRandomValues()`. |
37
+ | Async work started without awaiting, returning, or attaching it to `ctx.waitUntil()` | Work can be dropped and errors missed; tie it to the request or background-work lifetime. |
38
+ | Module-level mutable request state | Leaks data across requests and can cause I/O ownership errors; pass request state explicitly. |
39
+ | Cloudflare REST API calls for operations available through Worker bindings | Adds network and authentication overhead; use the available binding. |
40
+ | `ctx.passThroughOnException()` used as general error handling | Can conceal Worker failures by forwarding to the origin; use explicit error handling and structured error responses. |
41
+ | Hand-written `Env` that duplicates Wrangler bindings | Can drift from configuration; generate binding types with `wrangler types`. |
42
+ | Direct string comparison of secret values | Can expose timing differences; use the [Web Crypto comparison pattern](references/runtime-patterns.md#use-web-crypto-for-secure-token-generation). |
43
+ | Destructuring `ctx` methods, such as `const { waitUntil } = ctx` | Loses the receiver; call `ctx.waitUntil(...)`. |
44
+ | `any` on `Env` or handler parameters | Hides binding and handler contract errors; use the project's generated and platform types. |
45
+ | `as unknown as T` to force a platform type match | Hides incompatibilities; fix the underlying contract. |
46
+ | `implements` used in place of extending a platform base class | Does not inherit runtime behavior, `this.ctx`, or `this.env`; use the appropriate base class. |
47
+ | Unbound `env.X` in a platform class method | Bindings are available through `this.env.X`; see [binding access patterns](references/platform-apis.md#binding-access--the-most-common-error). |
48
+ | Applying one serialization rule across Queues, Workflow steps, storage, and WebSockets | Can reject valid payloads or accept unsupported ones; check the [specific API and encoding](references/platform-apis.md#serialization-boundaries). |
49
+
50
+ ## Validation
51
+
52
+ Use the project's existing checks for affected Workers behavior: type-check binding or handler contract changes, and run relevant runtime tests for behavior changes. Preserve required repository checks; a narrow edit does not require a full Workers audit.
113
53
 
114
54
  ## Scope
115
55
 
@@ -118,10 +58,3 @@ This skill covers Workers-specific best practices and code review. For related t
118
58
  - **Durable Objects**: load the `durable-objects` skill
119
59
  - **Workflows**: see [Rules of Workflows](https://developers.cloudflare.com/workflows/build/rules-of-workflows/)
120
60
  - **Wrangler CLI commands**: load the `wrangler` skill
121
-
122
- ## Principles
123
-
124
- - **Be certain.** Retrieve before flagging. If unsure about an API, config field, or pattern, fetch the docs first.
125
- - **Provide evidence.** Reference line numbers, tool output, or docs links.
126
- - **Focus on what developers will copy.** Workers code in examples and docs gets pasted into production.
127
- - **Correctness over completeness.** A concise example that works beats a comprehensive one with errors.
@@ -0,0 +1,139 @@
1
+ # Workers Configuration and Observability
2
+
3
+ Use the project's Wrangler configuration and installed `node_modules/wrangler/config-schema.json` to check fields and binding declarations. Consult current product docs when a field or compatibility requirement needs verification. Doc paths below are relative to `https://developers.cloudflare.com`.
4
+
5
+ - [Configuration](#configuration): compatibility dates, Node.js compatibility, generated types, secrets, and config format
6
+ - [Binding consistency](#binding-code-consistency): configuration and code agree
7
+ - [Observability](#observability): enable logs and traces, configure sampling, and emit structured logs
8
+
9
+ ## Configuration
10
+
11
+ ### Keep compatibility_date current
12
+
13
+ Set `compatibility_date` to today on new projects. Encourage periodic updates on existing projects to adopt new runtime behavior and fixes. Review the intervening compatibility changes and run relevant tests when advancing the date.
14
+
15
+ **Check**: `compatibility_date` exists and supports the affected feature with the configured flags. Recommend updates as maintenance; flag a compatibility defect when the configured date or flags do not support the required behavior.
16
+
17
+ ```jsonc
18
+ // wrangler.jsonc
19
+ {
20
+ "compatibility_date": "$today", // Replace with today's date (YYYY-MM-DD)
21
+ "compatibility_flags": ["nodejs_compat"]
22
+ }
23
+ ```
24
+
25
+ **Retrieve**: current compatibility dates at `/workers/configuration/compatibility-dates/`.
26
+
27
+ ### Enable nodejs_compat
28
+
29
+ The `nodejs_compat` flag enables Node.js built-in modules (`node:crypto`, `node:buffer`, `node:stream`). Many libraries require it. Missing this flag causes cryptic import errors at runtime.
30
+
31
+ **Check**: `compatibility_flags` includes `"nodejs_compat"`.
32
+
33
+ ```jsonc
34
+ {
35
+ "compatibility_flags": ["nodejs_compat"]
36
+ }
37
+ ```
38
+
39
+ ### Generate binding types with wrangler types
40
+
41
+ Never hand-write the `Env` interface. Run `wrangler types` to generate it from the wrangler config. Re-run after adding or renaming any binding.
42
+
43
+ **Check**: no manually defined `Env` or `interface Env` that duplicates wrangler config bindings. Look for `satisfies ExportedHandler<Env>` pattern on the default export.
44
+
45
+ ```ts
46
+ // Generated by wrangler types — always matches actual config
47
+ export default {
48
+ async fetch(request: Request, env: Env): Promise<Response> {
49
+ const value = await env.MY_KV.get("key");
50
+ return new Response(value);
51
+ },
52
+ } satisfies ExportedHandler<Env>;
53
+ ```
54
+
55
+ Anti-pattern:
56
+ ```ts
57
+ // Hand-written Env that drifts from actual bindings
58
+ interface Env {
59
+ MY_KV: KVNamespace; // What if the binding name changed?
60
+ }
61
+ ```
62
+
63
+ ### Store secrets with wrangler secret
64
+
65
+ Secrets must never appear in wrangler config or source code. Use `wrangler secret put` and access via `env` at runtime. Non-secret config goes in `vars`.
66
+
67
+ **Check**: no string literals that look like API keys, tokens, or credentials. Verify `.env` is in `.gitignore` for local dev.
68
+
69
+ ```jsonc
70
+ {
71
+ "vars": {
72
+ "API_BASE_URL": "https://api.example.com" // Non-secret: OK in config
73
+ }
74
+ // Secrets set via: wrangler secret put API_KEY
75
+ }
76
+ ```
77
+
78
+ Anti-pattern:
79
+ ```jsonc
80
+ {
81
+ "vars": {
82
+ "API_KEY": "sk-live-abc123..." // Secret in version control
83
+ }
84
+ }
85
+ ```
86
+
87
+ ### Use wrangler.jsonc for config
88
+
89
+ Prefer `wrangler.jsonc` over `wrangler.toml`. Newer features are JSON-only. JSONC supports comments for documenting config decisions.
90
+
91
+ **Check**: project uses `wrangler.jsonc` (or `wrangler.json`). Flag `wrangler.toml` in new projects.
92
+
93
+ ---
94
+
95
+ ### Binding-code consistency
96
+
97
+ For executable Worker examples, verify `name`, `compatibility_date`, and `main` against the target Wrangler schema.
98
+
99
+ 1. Every `env.X` reference in code has a corresponding binding declaration in config
100
+ 2. Names match exactly (case-sensitive)
101
+ 3. For Durable Objects: `class_name` matches the exported class name
102
+
103
+ An unused binding alone is not a finding; establish a concrete configuration or runtime consequence before recommending a change.
104
+
105
+ For a new Durable Object class, verify its migration entry and exported class name against the target Wrangler schema.
106
+
107
+ ## Observability
108
+
109
+ ### Enable Workers Logs and Traces
110
+
111
+ Enable Workers Logs and Traces in Wrangler config before deploying to production. Set `observability.enabled` and `observability.traces.enabled` to `true`; the top-level setting alone does not enable traces. Use `head_sampling_rate` to control volume and cost. Use structured JSON logging — `console.log(JSON.stringify({...}))` — so logs are searchable. Use `console.error` for errors (appears at error severity in the dashboard).
112
+
113
+ **Check**: logs and traces are enabled in the target deployment environment, with neither disabled by an environment override. Check `observability.enabled`, `observability.logs.enabled`, and `observability.traces.enabled`, accounting for their defaults. Logging uses structured JSON, not string concatenation.
114
+
115
+ ```jsonc
116
+ {
117
+ "observability": {
118
+ "enabled": true,
119
+ "logs": { "enabled": true, "head_sampling_rate": 1 },
120
+ "traces": { "enabled": true, "head_sampling_rate": 0.01 }
121
+ }
122
+ }
123
+ ```
124
+
125
+ ```ts
126
+ // Structured JSON — searchable and filterable
127
+ console.log(JSON.stringify({ message: "incoming request", method: request.method, path: url.pathname }));
128
+
129
+ // Error severity
130
+ console.error(JSON.stringify({ message: "request failed", error: e instanceof Error ? e.message : String(e) }));
131
+ ```
132
+
133
+ Anti-pattern:
134
+ ```ts
135
+ // Unstructured string logs — hard to query
136
+ console.log("Got a request to " + url.pathname);
137
+ ```
138
+
139
+ **Retrieve**: [Workers Logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/) and [Traces](https://developers.cloudflare.com/workers/observability/traces/) for current config options.
@@ -0,0 +1,51 @@
1
+ # Workers Platform API Checks
2
+
3
+ Use the project's installed and generated types to check affected handlers and bindings. Consult current Cloudflare docs when API or runtime compatibility remains uncertain.
4
+
5
+ - [Type validation](#type-validation): binding types, handler signatures, and platform classes
6
+ - [Serialization boundaries](#serialization-boundaries): encoding and supported values for each API
7
+
8
+ ## Type Validation
9
+
10
+ ### Env interface
11
+
12
+ - Every binding must have a specific type. Flag `any`, `unknown`, `object`, or `Record<string, unknown>` on bindings.
13
+ - Binding types that accept generic parameters (Durable Object namespaces, Queues, Service bindings for RPC) must include them. Read the type definition to confirm which types are generic.
14
+ - Use the project's generated binding types; see [configuration guidance](configuration.md#generate-binding-types-with-wrangler-types).
15
+
16
+ ### Handler and class signatures
17
+
18
+ Verify affected signatures against the project's target type definitions; consult current docs if runtime support or compatibility remains uncertain.
19
+
20
+ - Correct import path (most Workers platform classes import from `"cloudflare:workers"`)
21
+ - Generic type parameter on base classes (e.g., `DurableObject<Env>`)
22
+ - `ExecutionContext` as the third param in module export handlers (needed for `ctx.waitUntil()`)
23
+ - `fetch()` handlers must return `Promise<Response>`
24
+
25
+ ### Binding access — the most common error
26
+
27
+ - **Module export handlers** (`fetch`, `scheduled`, `queue`, `email`): bindings via `env.X` parameter
28
+ - **Platform base classes** (`WorkerEntrypoint`, `DurableObject`, `Workflow`, `Agent`): bindings via `this.env.X`
29
+
30
+ Flag `env.X` inside a class extending a platform base class. Flag `this.env.X` inside a module export handler.
31
+
32
+ ### Stale class patterns
33
+
34
+ Old patterns survive in codebases long after APIs change.
35
+
36
+ - **`extends` vs `implements`**: platform classes use `extends`, not `implements`. The `implements` pattern is legacy and loses `this.ctx`, `this.env`.
37
+ - **Import paths**: verify module specifiers match what types actually export. Common mistake: wrong path for `"cloudflare:workers"` vs `"cloudflare:workflows"`.
38
+ - **Renamed properties**: e.g., `this.state` to `this.ctx` in Durable Objects. Search types to confirm.
39
+ - **Constructor signatures**: base class constructors change. Verify expected parameters.
40
+
41
+ ## Serialization Boundaries
42
+
43
+ Check the API and encoding at each boundary. Structured clone support does not imply JSON compatibility or SQL parameter support.
44
+
45
+ | Boundary | What to check |
46
+ |----------|---------------|
47
+ | [Queue messages](https://developers.cloudflare.com/queues/configuration/javascript-apis/#queuescontenttype) | Match the body to `contentType`: `json` requires JSON-compatible data, `text` a string, `bytes` an `ArrayBuffer`, and `v8` supports structured-clone values such as `Map` and `Date`. Check the configured compatibility date when relying on the default encoding. |
48
+ | [Workflow step results](https://developers.cloudflare.com/workflows/build/workers-api/) | Verify the step result against the documented serialization contract and the project's Workflow types before flagging a value. |
49
+ | [Durable Object KV storage](https://developers.cloudflare.com/durable-objects/api/sqlite-storage-api/#put-1) | `storage.put()` supports structured-clone values; do not apply a blanket ban on `Map` or `Set`. |
50
+ | [Durable Object SQL](https://developers.cloudflare.com/durable-objects/api/sqlite-storage-api/#exec) | Check bound parameters against the SQL API's supported types. Encode objects explicitly for the intended column representation. |
51
+ | [WebSocket messages](https://developers.cloudflare.com/workers/runtime-apis/websockets/#send) | Use `send()` with a string, `ArrayBuffer`, or `ArrayBufferView`; encode objects, for example with `JSON.stringify()`. |