[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CCJ60RVN3KM91CGGZXQ446":3,"skill-same:01M7CCJ60RVN3KM91CGGZXQ446":61},{"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":33,"commitSha":34,"skillDirectory":35,"forksCount":36,"repositoryHtmlUrl":37,"repositoryHomepageUrl":6,"ownerHtmlUrl":38,"ownerBlogUrl":6,"ownerDescription":39,"updatedAt":40,"install":41,"resources":54},"01M7CCJ60RVN3KM91CGGZXQ446","websocket-engineer",null,"Use when building real-time communication systems with WebSockets or Socket.IO. Invoke for bidirectional messaging, horizontal scaling with Redis, presence tracking, room management.","om-scogo\u002Fskillsh-scraper","om-scogo","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F160466840?v=4","01M79AWB6DFVCQ7RK70CS34B96","Om Achrekar","01M79AWB6ZM9SKR8KDH1WSSM22",0,"MIT","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fjeffallan-claude-skills\u002Fwebsocket-engineer\u002FSkill.md",[],[],"2026-11-15 14:19:17",false,"---\nname: websocket-engineer\ndescription: Use when building real-time communication systems with WebSockets or Socket.IO. Invoke for bidirectional messaging, horizontal scaling with Redis, presence tracking, room management.\nlicense: MIT\nmetadata:\n  author: https:\u002F\u002Fgithub.com\u002FJeffallan\n  version: \"1.1.0\"\n  domain: api-architecture\n  triggers: WebSocket, Socket.IO, real-time communication, bidirectional messaging, pub\u002Fsub, server push, live updates, chat systems, presence tracking\n  role: specialist\n  scope: implementation\n  output-format: code\n  related-skills: fastapi-expert, nestjs-expert, devops-engineer, monitoring-expert, security-reviewer\n---\n\n# WebSocket Engineer\n\n## Core Workflow\n\n1. **Analyze requirements** — Identify connection scale, message volume, latency needs\n2. **Design architecture** — Plan clustering, pub\u002Fsub, state management, failover\n3. **Implement** — Build WebSocket server with authentication, rooms, events\n4. **Validate locally** — Test connection handling, auth, and room behavior before scaling (e.g., `npx wscat -c ws:\u002F\u002Flocalhost:3000`); confirm auth rejection on missing\u002Finvalid tokens, room join\u002Fleave events, and message delivery\n5. **Scale** — Verify Redis connection and pub\u002Fsub round-trip before enabling the adapter; configure sticky sessions and confirm with test connections across multiple instances; set up load balancing\n6. **Monitor** — Track connections, latency, throughput, error rates; add alerts for connection-count spikes and error-rate thresholds\n\n## Reference Guide\n\nLoad detailed guidance based on context:\n\n| Topic | Reference | Load When |\n|-------|-----------|-----------|\n| Protocol | `references\u002Fprotocol.md` | WebSocket handshake, frames, ping\u002Fpong, close codes |\n| Scaling | `references\u002Fscaling.md` | Horizontal scaling, Redis pub\u002Fsub, sticky sessions |\n| Patterns | `references\u002Fpatterns.md` | Rooms, namespaces, broadcasting, acknowledgments |\n| Security | `references\u002Fsecurity.md` | Authentication, authorization, rate limiting, CORS |\n| Alternatives | `references\u002Falternatives.md` | SSE, long polling, when to choose WebSockets |\n\n## Code Examples\n\n### Server Setup (Socket.IO with Auth and Room Management)\n\n```js\nimport { createServer } from \"http\";\nimport { Server } from \"socket.io\";\nimport { createAdapter } from \"@socket.io\u002Fredis-adapter\";\nimport { createClient } from \"redis\";\nimport jwt from \"jsonwebtoken\";\n\nconst httpServer = createServer();\nconst io = new Server(httpServer, {\n  cors: { origin: process.env.ALLOWED_ORIGIN, credentials: true },\n  pingTimeout: 20000,\n  pingInterval: 25000,\n});\n\n\u002F\u002F Authentication middleware — runs before connection is established\nio.use((socket, next) => {\n  const token = socket.handshake.auth.token;\n  if (!token) return next(new Error(\"Authentication required\"));\n  try {\n    socket.data.user = jwt.verify(token, process.env.JWT_SECRET);\n    next();\n  } catch {\n    next(new Error(\"Invalid token\"));\n  }\n});\n\n\u002F\u002F Redis adapter for horizontal scaling\nconst pubClient = createClient({ url: process.env.REDIS_URL });\nconst subClient = pubClient.duplicate();\nawait Promise.all([pubClient.connect(), subClient.connect()]);\nio.adapter(createAdapter(pubClient, subClient));\n\nio.on(\"connection\", (socket) => {\n  const { userId } = socket.data.user;\n  console.log(`connected: ${userId} (${socket.id})`);\n\n  \u002F\u002F Presence: mark user online\n  pubClient.hSet(\"presence\", userId, socket.id);\n\n  socket.on(\"join-room\", (roomId) => {\n    socket.join(roomId);\n    socket.to(roomId).emit(\"user-joined\", { userId });\n  });\n\n  socket.on(\"message\", ({ roomId, text }) => {\n    io.to(roomId).emit(\"message\", { userId, text, ts: Date.now() });\n  });\n\n  socket.on(\"disconnect\", () => {\n    pubClient.hDel(\"presence\", userId);\n    console.log(`disconnected: ${userId}`);\n  });\n});\n\nhttpServer.listen(3000);\n```\n\n### Client-Side Reconnection with Exponential Backoff\n\n```js\nimport { io } from \"socket.io-client\";\n\nconst socket = io(\"wss:\u002F\u002Fapi.example.com\", {\n  auth: { token: getAuthToken() },\n  reconnection: true,\n  reconnectionAttempts: 10,\n  reconnectionDelay: 1000,       \u002F\u002F initial delay (ms)\n  reconnectionDelayMax: 30000,   \u002F\u002F cap at 30 s\n  randomizationFactor: 0.5,      \u002F\u002F jitter to avoid thundering herd\n});\n\n\u002F\u002F Queue messages while disconnected\nlet messageQueue = [];\n\nsocket.on(\"connect\", () => {\n  console.log(\"connected:\", socket.id);\n  \u002F\u002F Flush queued messages\n  messageQueue.forEach((msg) => socket.emit(\"message\", msg));\n  messageQueue = [];\n});\n\nsocket.on(\"disconnect\", (reason) => {\n  console.warn(\"disconnected:\", reason);\n  if (reason === \"io server disconnect\") socket.connect(); \u002F\u002F manual reconnect\n});\n\nsocket.on(\"connect_error\", (err) => {\n  console.error(\"connection error:\", err.message);\n});\n\nfunction sendMessage(roomId, text) {\n  const msg = { roomId, text };\n  if (socket.connected) {\n    socket.emit(\"message\", msg);\n  } else {\n    messageQueue.push(msg); \u002F\u002F buffer until reconnected\n  }\n}\n```\n\n## Constraints\n\n### MUST DO\n- Use sticky sessions for load balancing (WebSocket connections are stateful — requests must route to the same server instance)\n- Implement heartbeat\u002Fping-pong to detect dead connections (TCP keepalive alone is insufficient)\n- Use rooms\u002Fnamespaces for message scoping rather than filtering in application logic\n- Queue messages during disconnection windows to avoid silent data loss\n- Plan connection limits per instance before scaling horizontally\n\n### MUST NOT DO\n- Store large state in memory without a clustering strategy (use Redis or an external store)\n- Mix WebSocket and HTTP on the same port without explicit upgrade handling\n- Forget to handle connection cleanup (presence records, room membership, in-flight timers)\n- Skip load testing before production — connection-count spikes behave differently from HTTP traffic spikes\n\n## Output Templates\n\nWhen implementing WebSocket features, provide:\n1. Server setup (Socket.IO\u002Fws configuration)\n2. Event handlers (connection, message, disconnect)\n3. Client library (connection, events, reconnection)\n4. Brief explanation of scaling strategy\n\n## Knowledge Reference\n\nSocket.IO, ws, uWebSockets.js, Redis adapter, sticky sessions, nginx WebSocket proxy, JWT over WebSocket, rooms\u002Fnamespaces, acknowledgments, binary data, compression, heartbeat, backpressure, horizontal pod autoscaling\n\n[Documentation](https:\u002F\u002Fjeffallan.github.io\u002Fclaude-skills\u002Fskills\u002Fapi-architecture\u002Fwebsocket-engineer\u002F)\n","# WebSocket Engineer\n\n## Core Workflow\n\n1. **Analyze requirements** — Identify connection scale, message volume, latency needs\n2. **Design architecture** — Plan clustering, pub\u002Fsub, state management, failover\n3. **Implement** — Build WebSocket server with authentication, rooms, events\n4. **Validate locally** — Test connection handling, auth, and room behavior before scaling (e.g., `npx wscat -c ws:\u002F\u002Flocalhost:3000`); confirm auth rejection on missing\u002Finvalid tokens, room join\u002Fleave events, and message delivery\n5. **Scale** — Verify Redis connection and pub\u002Fsub round-trip before enabling the adapter; configure sticky sessions and confirm with test connections across multiple instances; set up load balancing\n6. **Monitor** — Track connections, latency, throughput, error rates; add alerts for connection-count spikes and error-rate thresholds\n\n## Reference Guide\n\nLoad detailed guidance based on context:\n\n| Topic | Reference | Load When |\n|-------|-----------|-----------|\n| Protocol | `references\u002Fprotocol.md` | WebSocket handshake, frames, ping\u002Fpong, close codes |\n| Scaling | `references\u002Fscaling.md` | Horizontal scaling, Redis pub\u002Fsub, sticky sessions |\n| Patterns | `references\u002Fpatterns.md` | Rooms, namespaces, broadcasting, acknowledgments |\n| Security | `references\u002Fsecurity.md` | Authentication, authorization, rate limiting, CORS |\n| Alternatives | `references\u002Falternatives.md` | SSE, long polling, when to choose WebSockets |\n\n## Code Examples\n\n### Server Setup (Socket.IO with Auth and Room Management)\n\n```js\nimport { createServer } from \"http\";\nimport { Server } from \"socket.io\";\nimport { createAdapter } from \"@socket.io\u002Fredis-adapter\";\nimport { createClient } from \"redis\";\nimport jwt from \"jsonwebtoken\";\n\nconst httpServer = createServer();\nconst io = new Server(httpServer, {\n  cors: { origin: process.env.ALLOWED_ORIGIN, credentials: true },\n  pingTimeout: 20000,\n  pingInterval: 25000,\n});\n\n\u002F\u002F Authentication middleware — runs before connection is established\nio.use((socket, next) => {\n  const token = socket.handshake.auth.token;\n  if (!token) return next(new Error(\"Authentication required\"));\n  try {\n    socket.data.user = jwt.verify(token, process.env.JWT_SECRET);\n    next();\n  } catch {\n    next(new Error(\"Invalid token\"));\n  }\n});\n\n\u002F\u002F Redis adapter for horizontal scaling\nconst pubClient = createClient({ url: process.env.REDIS_URL });\nconst subClient = pubClient.duplicate();\nawait Promise.all([pubClient.connect(), subClient.connect()]);\nio.adapter(createAdapter(pubClient, subClient));\n\nio.on(\"connection\", (socket) => {\n  const { userId } = socket.data.user;\n  console.log(`connected: ${userId} (${socket.id})`);\n\n  \u002F\u002F Presence: mark user online\n  pubClient.hSet(\"presence\", userId, socket.id);\n\n  socket.on(\"join-room\", (roomId) => {\n    socket.join(roomId);\n    socket.to(roomId).emit(\"user-joined\", { userId });\n  });\n\n  socket.on(\"message\", ({ roomId, text }) => {\n    io.to(roomId).emit(\"message\", { userId, text, ts: Date.now() });\n  });\n\n  socket.on(\"disconnect\", () => {\n    pubClient.hDel(\"presence\", userId);\n    console.log(`disconnected: ${userId}`);\n  });\n});\n\nhttpServer.listen(3000);\n```\n\n### Client-Side Reconnection with Exponential Backoff\n\n```js\nimport { io } from \"socket.io-client\";\n\nconst socket = io(\"wss:\u002F\u002Fapi.example.com\", {\n  auth: { token: getAuthToken() },\n  reconnection: true,\n  reconnectionAttempts: 10,\n  reconnectionDelay: 1000,       \u002F\u002F initial delay (ms)\n  reconnectionDelayMax: 30000,   \u002F\u002F cap at 30 s\n  randomizationFactor: 0.5,      \u002F\u002F jitter to avoid thundering herd\n});\n\n\u002F\u002F Queue messages while disconnected\nlet messageQueue = [];\n\nsocket.on(\"connect\", () => {\n  console.log(\"connected:\", socket.id);\n  \u002F\u002F Flush queued messages\n  messageQueue.forEach((msg) => socket.emit(\"message\", msg));\n  messageQueue = [];\n});\n\nsocket.on(\"disconnect\", (reason) => {\n  console.warn(\"disconnected:\", reason);\n  if (reason === \"io server disconnect\") socket.connect(); \u002F\u002F manual reconnect\n});\n\nsocket.on(\"connect_error\", (err) => {\n  console.error(\"connection error:\", err.message);\n});\n\nfunction sendMessage(roomId, text) {\n  const msg = { roomId, text };\n  if (socket.connected) {\n    socket.emit(\"message\", msg);\n  } else {\n    messageQueue.push(msg); \u002F\u002F buffer until reconnected\n  }\n}\n```\n\n## Constraints\n\n### MUST DO\n- Use sticky sessions for load balancing (WebSocket connections are stateful — requests must route to the same server instance)\n- Implement heartbeat\u002Fping-pong to detect dead connections (TCP keepalive alone is insufficient)\n- Use rooms\u002Fnamespaces for message scoping rather than filtering in application logic\n- Queue messages during disconnection windows to avoid silent data loss\n- Plan connection limits per instance before scaling horizontally\n\n### MUST NOT DO\n- Store large state in memory without a clustering strategy (use Redis or an external store)\n- Mix WebSocket and HTTP on the same port without explicit upgrade handling\n- Forget to handle connection cleanup (presence records, room membership, in-flight timers)\n- Skip load testing before production — connection-count spikes behave differently from HTTP traffic spikes\n\n## Output Templates\n\nWhen implementing WebSocket features, provide:\n1. Server setup (Socket.IO\u002Fws configuration)\n2. Event handlers (connection, message, disconnect)\n3. Client library (connection, events, reconnection)\n4. Brief explanation of scaling strategy\n\n## Knowledge Reference\n\nSocket.IO, ws, uWebSockets.js, Redis adapter, sticky sessions, nginx WebSocket proxy, JWT over WebSocket, rooms\u002Fnamespaces, acknowledgments, binary data, compression, heartbeat, backpressure, horizontal pod autoscaling\n\n[Documentation](https:\u002F\u002Fjeffallan.github.io\u002Fclaude-skills\u002Fskills\u002Fapi-architecture\u002Fwebsocket-engineer\u002F)\n",{"name":5,"license":15,"metadata":24,"description":7},{"role":25,"scope":26,"author":27,"domain":28,"version":29,"triggers":30,"output-format":31,"related-skills":32},"specialist","implementation","https:\u002F\u002Fgithub.com\u002FJeffallan","api-architecture","1.1.0","WebSocket, Socket.IO, real-time communication, bidirectional messaging, pub\u002Fsub, server push, live updates, chat systems, presence tracking","code","fastapi-expert, nestjs-expert, devops-engineer, monitoring-expert, security-reviewer","main","8859218955d9504cd18b59e7892100718039d3b4","data\u002Fskills\u002Fjeffallan-claude-skills\u002Fwebsocket-engineer",1,"https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper","https:\u002F\u002Fgithub.com\u002Fom-scogo","SDE-1 @ Scogo ","2026-07-18 12:22:46",{"source":8,"skillName":5,"commands":42,"prompt":52,"zipAvailable":53},[43,46,49],{"tool":44,"command":45},"npx","npx skills add om-scogo\u002Fskillsh-scraper --skill websocket-engineer",{"tool":47,"command":48},"bunx","bunx skills add om-scogo\u002Fskillsh-scraper --skill websocket-engineer",{"tool":50,"command":51},"pnpm","pnpm dlx skills add om-scogo\u002Fskillsh-scraper --skill websocket-engineer","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fjeffallan-claude-skills\u002Fwebsocket-engineer\u002FSkill.md",true,[55],{"path":56,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":59,"sourceHtmlUrl":60},"metadata.json","REFERENCE","参考文档",472,"https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fjeffallan-claude-skills\u002Fwebsocket-engineer\u002Fmetadata.json",[62,69,74,81,86,93],{"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},"01M7D6MC9FAAEV4CMNYX8W7JTG","arxiv-search","Search arXiv physics, math, and computer science preprints using natural language queries. Powered by Valyu semantic search.","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fyorkeccak-scientific-skills\u002Farxiv-search\u002Fskills\u002Farxiv-search\u002FSKILL.md",[],[],{"skillNo":70,"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":71,"categories":72,"keywords":73,"publishedAt":19},"01M7D6M85CKKN87TA98VCQV4H7","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fyorkeccak-scientific-skills\u002Farxiv-search\u002FSkill.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M7D4ZTCS4DR3CE4JY06X84T2","working-with-legacy-code","Safely change and test untested codebases using Feathers' \"Working Effectively with Legacy Code\". Use when the user mentions \"legacy code\", \"no tests\", \"untested codebase\", \"how do I test this\", \"seams\", \"characterization tests\", \"golden master\", \"sprout method\", \"afraid to change this code\", \"monster method\", \"dependency breaking\", or \"inherited a messy codebase\". Also trigger when changing code without tests safely, getting a class under test when constructors, statics, or singletons block it, adding features to tangled modules, or planning incremental test coverage for an old codebase. Covers the legacy-code change algorithm, seams, characterization tests, sprout\u002Fwrap, and dependency-breaking techniques. For refactoring code that already has tests, see refactoring-patterns. For day-to-day code quality, see clean-code.","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fworking-with-legacy-code\u002Fworking-with-legacy-code\u002FSKILL.md",[],[],{"skillNo":82,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M7D4ZHZKJD2RSNGAF63V14P4","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fworking-with-legacy-code\u002FSkill.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M7D4ZB4CJBFW5JE67CPH2QRV","web-typography","Select, pair, and implement typefaces for web projects. Use when the user mentions \"font pairing\", \"which typeface\", \"line height\", \"responsive typography\", \"web font loading\", \"type hierarchy\", \"variable fonts\", \"FOUT\u002FFOIT\", \"typographic scale\", or \"the text is hard to read\". Also trigger when choosing between system fonts and web fonts, optimizing font-loading performance, or designing readable long-form content. Covers readability evaluation, CSS implementation, and performance optimization. For overall UI design systems, see refactoring-ui. For dramatic typographic experiences, see top-design.","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fweb-typography\u002Fweb-typography\u002FSKILL.md",[],[],{"skillNo":94,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M7D4Z4MVYVY3NMJ18BNV6WNA","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fweb-typography\u002FSkill.md",[],[]]