agents/skills/cf-socka-realtime/SKILL.md
Socka + Durable Object WebSockets—defineSocka, SockaWebSocketDO, useSockaSession, SSR-safe ws URLs, web worker forwarding, live-draft vs commit, canvas/whiteboard acceptance, and pre-merge checks. Use for realtime features, /api/ws, or @firtoz/socka.
npx skillsauth add firtoz/cf-multiworker-starter-kit cf-socka-realtimeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Rule of thumb: Prefer @firtoz/socka and a shared contract package; do not hand-roll { t: "…" } JSON protocols unless the user explicitly wants raw WebSockets. See cf-realtime-websockets.mdc.
| Piece | Where |
| ----- | ----- |
| defineSocka contract (calls + pushes) | packages/chat-contract/src/contract.ts |
| DO extending SockaWebSocketDO | durable-objects/chatroom-do/workers/chatroom-do.ts |
| Web worker: upgrade → DO /websocket | apps/web/workers/app.ts |
| Client useSockaSession + URL from current host | apps/web/app/components/chat/ChatClient.tsx |
| Route-safe wss:// / ws:// builder | apps/web/app/lib/chat-ws-url.ts |
After bunx turbo gen durable-object: the default template is Hono + optional WebSocket forwarding; for Socka + DO SQLite, copy the chatroom pattern (chatroom-do + @internal/chat-contract) and renames described in project-init/SKILL.md for forks. A dedicated Socka codegen path may be added later.
window, window.location, or build wss:// in loaders, actions, or component render on paths that run under SSR.const url = new URL(window.location.href);
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
url.pathname = "/api/your/prefix/room-id";
// …search params as needed
Do not use fake fallbacks like ws://127.0.0.1/... to satisfy a hook. If a hook needs a URL immediately, mount a child component only after the client has a real URL, or show a loading shell until then.
Match exactly the path prefix handled in apps/web/workers/app.ts before React Router (and do not break Vite HMR upgrades).
For drawing apps, separate:
sendDraft / push draftUpdated (in-progress stroke, uncommitted).applyOp / push opApplied after commit (persisted, undo stack, etc.).Optionally batch or throttle cursor/presence on its own channel so it does not fight stroke traffic. This avoids “nothing appears until mouseup” for remote users.
For interactive canvas features, expect (unless scoped otherwise):
Testing: fetch and unit tests do not catch pointer bugs. Prefer browser automation (e.g. Cursor cursor-ide-browser MCP or Playwright): pointer down / move / up on the canvas, then assert visual or DOM/canvas state. See multiworker-workflow/SKILL.md for when typecheck is not enough.
Socka send.* returns promises. In hot paths (pointer move, requestAnimationFrame, intervals), handle rejections so browser tests and users do not see uncaught promise errors:
void send.sendCursor(...).catch(() => undefined);
defineSocka); no ad-hoc JSON wire protocol unless justified.window / document in SSR render paths for WebSocket URLs.localhost / 127.0.0.1 / placeholder WebSocket URLs as runtime fallbacks.bun run typegen (if routes/bindings changed), bun run typecheck, bun run lint from repo root per multiworker-workflow/SKILL.md.development
Repo-root commands, typegen and typecheck cadence, lint, deploy, adding packages with bun, and Alchemy app layout. Use at the start of a task, before PR, or when choosing turbo/typegen commands.
development
Fork and template gotchas (env import, routes, typegen, forms, D1, Turbo, HMR, new DO packages). Use when working on apps/web or durable-objects, or when behavior diverges from this stack’s conventions.
testing
Turborepo task configuration patterns for monorepo management. Use when configuring turbo.json tasks, setting up task dependencies, managing cache inputs/outputs, or working with cross-package dependencies in the monorepo.
development
React Router v7 routing patterns and environment variable configuration. Use whenever you touch React Router–related code (routes, links, params, loaders, actions, route config, or env in route context).