websocket-implementation
Implement real-time bidirectional communication with WebSockets including connection management, message routing, and scaling. Use when building real-time features, chat systems, live notifications, or collaborative applications.
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o websocket-implementation.zip https://jpskill.com/download/21568.zip && unzip -o websocket-implementation.zip && rm websocket-implementation.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/21568.zip -OutFile "$d\websocket-implementation.zip"; Expand-Archive "$d\websocket-implementation.zip" -DestinationPath $d -Force; ri "$d\websocket-implementation.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
websocket-implementation.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
websocket-implementationフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 7
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
WebSocketの実装
目次
概要
適切な接続管理、メッセージルーティング、エラー処理、水平スケーリングのサポートを備えた、リアルタイム通信のためのスケーラブルなWebSocketシステムを構築します。
使用する場面
- リアルタイムチャットやメッセージングの構築
- ライブ通知の実装
- 共同編集ツールの作成
- ライブデータ更新のブロードキャスト
- リアルタイムダッシュボードの構築
- クライアントへのイベントストリーミング
- ライブマルチプレイヤーゲーム
クイックスタート
最小限の動作例:
const express = require("express");
const http = require("http");
const socketIo = require("socket.io");
const redis = require("redis");
const app = express();
const server = http.createServer(app);
const io = socketIo(server, {
cors: { origin: "*" },
transports: ["websocket", "polling"],
reconnection: true,
reconnectionDelay: 1000,
reconnectionDelayMax: 5000,
reconnectionAttempts: 5,
});
// Redis adapter for horizontal scaling
const redisClient = redis.createClient();
const { createAdapter } = require("@socket.io/redis-adapter");
io.adapter(createAdapter(redisClient, redisClient.duplicate()));
// Connection management
const connectedUsers = new Map();
// ... (see reference guides for full implementation)
リファレンスガイド
references/ディレクトリにある詳細な実装:
| ガイド | 内容 |
|---|---|
| Node.js WebSocket Server (Socket.IO) | Node.js WebSocketサーバー (Socket.IO) |
| Browser WebSocket Client | ブラウザWebSocketクライアント |
| Python WebSocket Server (aiohttp) | Python WebSocketサーバー (aiohttp) |
| Message Types and Protocols | メッセージタイプとプロトコル |
| Scaling with Redis | Redisによるスケーリング |
ベストプラクティス
✅ 実施すべきこと
- 適切な認証を実装する
- 再接続を適切に処理する
- ルーム/チャンネルを効果的に管理する
- メッセージを適切に永続化する
- アクティブな接続を監視する
- プレゼンス機能を実装する
- スケーリングのためにRedisを使用する
- メッセージの確認応答を追加する
- レート制限を実装する
- エラーを適切に処理する
❌ 実施すべきでないこと
- 暗号化されていない機密データを送信する
- 無制限のメッセージ履歴をメモリに保持する
- 任意のルーム/チャンネル作成を許可する
- 切断された接続のクリーンアップを忘れる
- 大量のメッセージを頻繁に送信する
- ネットワーク障害を無視する
- パスワードをメッセージに保存する
- 認証/認可をスキップする
- 接続の無制限な増加を引き起こす
- 初日からスケーラビリティを無視する
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
WebSocket Implementation
Table of Contents
Overview
Build scalable WebSocket systems for real-time communication with proper connection management, message routing, error handling, and horizontal scaling support.
When to Use
- Building real-time chat and messaging
- Implementing live notifications
- Creating collaborative editing tools
- Broadcasting live data updates
- Building real-time dashboards
- Streaming events to clients
- Live multiplayer games
Quick Start
Minimal working example:
const express = require("express");
const http = require("http");
const socketIo = require("socket.io");
const redis = require("redis");
const app = express();
const server = http.createServer(app);
const io = socketIo(server, {
cors: { origin: "*" },
transports: ["websocket", "polling"],
reconnection: true,
reconnectionDelay: 1000,
reconnectionDelayMax: 5000,
reconnectionAttempts: 5,
});
// Redis adapter for horizontal scaling
const redisClient = redis.createClient();
const { createAdapter } = require("@socket.io/redis-adapter");
io.adapter(createAdapter(redisClient, redisClient.duplicate()));
// Connection management
const connectedUsers = new Map();
// ... (see reference guides for full implementation)
Reference Guides
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Node.js WebSocket Server (Socket.IO) | Node.js WebSocket Server (Socket.IO) |
| Browser WebSocket Client | Browser WebSocket Client |
| Python WebSocket Server (aiohttp) | Python WebSocket Server (aiohttp) |
| Message Types and Protocols | Message Types and Protocols |
| Scaling with Redis | Scaling with Redis |
Best Practices
✅ DO
- Implement proper authentication
- Handle reconnection gracefully
- Manage rooms/channels effectively
- Persist messages appropriately
- Monitor active connections
- Implement presence features
- Use Redis for scaling
- Add message acknowledgment
- Implement rate limiting
- Handle errors properly
❌ DON'T
- Send unencrypted sensitive data
- Keep unlimited message history in memory
- Allow arbitrary room/channel creation
- Forget to clean up disconnected connections
- Send large messages frequently
- Ignore network failures
- Store passwords in messages
- Skip authentication/authorization
- Create unbounded growth of connections
- Ignore scalability from day one
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (3,080 bytes)
- 📎 references/browser-websocket-client.md (2,833 bytes)
- 📎 references/message-types-and-protocols.md (580 bytes)
- 📎 references/nodejs-websocket-server-socketio.md (4,211 bytes)
- 📎 references/python-websocket-server-aiohttp.md (4,045 bytes)
- 📎 references/scaling-with-redis.md (666 bytes)
- 📎 scripts/validate-api.sh (440 bytes)