From gopilot
Add WebSocket support to the Go backend with typed message protocol and auto-generated frontend client. Use when adding real-time features like chat, notifications, or live updates.
npx claudepluginhub bishwas-py/gopilot --plugin gopilotThis skill uses the workspace's default tool permissions.
You are adding WebSocket support for real-time features. The backend manages a hub with rooms/subscriptions, and the frontend gets a typed client.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Guides MCP server integration in Claude Code plugins via .mcp.json or plugin.json configs for stdio, SSE, HTTP types, enabling external services as tools.
You are adding WebSocket support for real-time features. The backend manages a hub with rooms/subscriptions, and the frontend gets a typed client.
skills/_shared/go-patterns.md for conventionsbackend/internal/ws/Create backend/internal/ws/:
package ws
import "sync"
type Hub struct {
mu sync.RWMutex
clients map[string]*Client // connID -> client
rooms map[string]map[string]*Client // roomID -> connID -> client
}
func NewHub() *Hub { ... }
func (h *Hub) Register(client *Client) { ... }
func (h *Hub) Unregister(client *Client) { ... }
func (h *Hub) Subscribe(client *Client, room string) { ... }
func (h *Hub) Unsubscribe(client *Client, room string) { ... }
func (h *Hub) Broadcast(room string, msg []byte) { ... }
func (h *Hub) SendTo(connID string, msg []byte) { ... }
package ws
import "github.com/gorilla/websocket"
type Client struct {
ID string
UserID string
Conn *websocket.Conn
Hub *Hub
Send chan []byte
}
func (c *Client) ReadPump() { ... } // reads from WS, routes to handler
func (c *Client) WritePump() { ... } // writes from Send channel to WS
package ws
type MessageType string
const (
// Client → Server
MsgSubscribe MessageType = "subscribe"
MsgUnsubscribe MessageType = "unsubscribe"
// Add feature-specific message types here
)
type IncomingMessage struct {
Type MessageType `json:"type"`
Payload json.RawMessage `json:"payload"`
}
type OutgoingMessage struct {
Type MessageType `json:"type"`
Payload interface{} `json:"payload"`
}
In backend/internal/api/router.go, add:
hub := ws.NewHub()
r.Get("/ws", handleWebSocket(hub))
Tag WebSocket operations in Huma for OpenAPI generation so the SDK generator can create typed clients.
The SDK generator will handle this via /gopilot:sdk. The generated client will have:
send*() methods matching server message typeson*() handlers matching server broadcast types