tryboy869/dojutsu-for-ai/websockets

Claude Code and agent skill by tryboy869/dojutsu-for-ai

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Apply when building real-time features with WebSockets: chat, live updates, notifications, collaborative tools, dashboards. Covers: FastAPI WebSocket, connection management, broadcast, reconnection. Trigger for: WebSocket, real-time, live, chat, push, SSE.

Install

npx vskill@latest install tryboy869/dojutsu-for-ai/websockets

SKILL.md

The same SKILL.md was published earlier as tryboy869/dojutsu-for-ai/websockets.

WEBSOCKETS — Real-Time Production Patterns

Connection Manager

python
from fastapi import WebSocket
from typing import dict
class ConnectionManager:
def __init__(self):
# room_id → set of connected clients
self.rooms: dict[str, set[WebSocket]] = {}
async def connect(self, ws: WebSocket, room_id: str):
await ws.accept()
self.rooms.setdefault(room_id, set()).add(ws)
async def disconnect(self, ws: WebSocket, room_id: str):
self.rooms.get(room_id, set()).discard(ws)
async def broadcast(self, room_id: str, message: dict):
dead = set()
for ws in self.rooms.get(room_id, set()):
try:
await ws.send_json(message)
except Exception:
dead.add(ws)
self.rooms[room_id] -= dead # clean disconnected clients
manager = ConnectionManager()

FastAPI Endpoint

python
@app.websocket("/ws/{room_id}")
async def websocket_endpoint(ws: WebSocket, room_id: str,
token: str = Query(...)):
# Auth before accepting
try:
user = verify_token(token)
except HTTPException:
await ws.close(code=1008) # Policy violation
return
await manager.connect(ws, room_id)
try:
while True:
data = await asyncio.wait_for(ws.receive_json(), timeout=60)
# Validate message
message = ChatMessage.model_validate(data)
await manager.broadcast(room_id, {
"user": user.id,
"content": message.content,
"ts": datetime.utcnow().isoformat()
})
except asyncio.TimeoutError:
await ws.send_json({"type": "ping"})
except WebSocketDisconnect:
manager.disconnect(ws, room_id)

Client Reconnection (JavaScript)

javascript
class ReconnectingWebSocket {
constructor(url) {
this.url = url;
this.attempts = 0;
this.connect();
}
connect() {
this.ws = new WebSocket(this.url);
this.ws.onclose = () => {
const delay = Math.min(1000 * 2 ** this.attempts, 30000);
setTimeout(() => { this.attempts++; this.connect(); }, delay);
};
this.ws.onopen = () => { this.attempts = 0; };
}
}

Forbidden

❌ No authentication on WebSocket endpoint ❌ No timeout/ping — zombie connections accumulate ❌ Storing connection objects in a database ❌ Sending large payloads (> 64KB) — use chunking ❌ No error handling on send() — crashes on disconnected client

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
4
7-day trend score
13

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/tryboy869/dojutsu-for-ai/websockets/badge)](https://verified-skill.com/skills/tryboy869/dojutsu-for-ai/websockets)

Something wrong with this skill or its page? Tell us.