@devo-bmad-custom/agent-orchestration 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/package.json +4 -2
  2. package/src/.agents/skills/tmux-commands/SKILL.md +1 -1
  3. package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/vision-framework/SKILL.md +475 -0
  4. package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/vision-framework/references/vision-requests.md +736 -0
  5. package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/vision-framework/references/visionkit-scanner.md +738 -0
  6. package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/weatherkit/SKILL.md +410 -0
  7. package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/weatherkit/references/weatherkit-patterns.md +567 -0
  8. package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/widgetkit/SKILL.md +497 -0
  9. package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/widgetkit/references/widgetkit-advanced.md +871 -0
  10. package/src/.agents/skills/ui-ux-pro-custom/data/typography.csv +58 -0
  11. package/src/.agents/skills/ui-ux-pro-custom/data/ui-reasoning.csv +101 -0
  12. package/src/.agents/skills/ui-ux-pro-custom/data/ux-guidelines.csv +100 -0
  13. package/src/.agents/skills/ui-ux-pro-custom/data/web-interface.csv +31 -0
  14. package/src/.agents/skills/ui-ux-pro-custom/scripts/core.py +253 -0
  15. package/src/.agents/skills/ui-ux-pro-custom/scripts/design_system.py +1067 -0
  16. package/src/.agents/skills/ui-ux-pro-custom/scripts/search.py +114 -0
  17. package/src/.agents/skills/ux-audit/SKILL.md +151 -0
  18. package/src/.agents/skills/websocket-engineer/SKILL.md +168 -0
  19. package/src/.agents/skills/websocket-engineer/references/alternatives.md +391 -0
  20. package/src/.agents/skills/websocket-engineer/references/patterns.md +400 -0
  21. package/src/.agents/skills/websocket-engineer/references/protocol.md +195 -0
  22. package/src/.agents/skills/websocket-engineer/references/scaling.md +333 -0
  23. package/src/.agents/skills/websocket-engineer/references/security.md +474 -0
  24. package/src/.agents/skills/writing-skills/SKILL.md +655 -0
  25. package/src/.agents/skills/writing-skills/anthropic-best-practices.md +1150 -0
  26. package/src/.agents/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  27. package/src/.agents/skills/writing-skills/graphviz-conventions.dot +172 -0
  28. package/src/.agents/skills/writing-skills/persuasion-principles.md +187 -0
  29. package/src/.agents/skills/writing-skills/render-graphs.js +168 -0
  30. package/src/.agents/skills/writing-skills/testing-skills-with-subagents.md +384 -0
  31. package/src/.claude/commands/bmad-track-compact.md +19 -0
  32. package/src/.claude/commands/bmad-track-extended.md +19 -0
  33. package/src/.claude/commands/bmad-track-large.md +19 -0
  34. package/src/.claude/commands/bmad-track-medium.md +19 -0
  35. package/src/.claude/commands/bmad-track-nano.md +19 -0
  36. package/src/.claude/commands/bmad-track-rv.md +18 -0
  37. package/src/.claude/commands/bmad-track-small.md +19 -0
  38. package/src/.claude/commands/master-orchestrator.md +15 -0
  39. package/src/_memory/master-orchestrator-sidecar/docs-index.md +3 -0
  40. package/src/_memory/master-orchestrator-sidecar/instructions.md +2616 -0
  41. package/src/_memory/master-orchestrator-sidecar/memories.md +8 -0
  42. package/src/_memory/master-orchestrator-sidecar/session-state.md +15 -0
  43. package/src/_memory/master-orchestrator-sidecar/triage-history.md +3 -0
  44. package/src/_memory/master-orchestrator-sidecar/workflows-overview.html +1230 -0
  45. package/src/core/agents/master-orchestrator.md +54 -0
  46. package/src/docs/dev/tmux/actions_popup.py +291 -0
  47. package/src/docs/dev/tmux/actions_popup.sh +110 -0
  48. package/src/docs/dev/tmux/claude_usage.sh +15 -0
  49. package/src/docs/dev/tmux/colors.conf +26 -0
  50. package/src/docs/dev/tmux/cpu_usage.sh +7 -0
  51. package/src/docs/dev/tmux/dispatch.sh +10 -0
  52. package/src/docs/dev/tmux/float_init.sh +13 -0
  53. package/src/docs/dev/tmux/float_term.sh +23 -0
  54. package/src/docs/dev/tmux/open_clip.sh +14 -0
  55. package/src/docs/dev/tmux/paste_claude.sh +26 -0
  56. package/src/docs/dev/tmux/paste_clipboard.sh +13 -0
  57. package/src/docs/dev/tmux/paste_image_wrapper.sh +98 -0
  58. package/src/docs/dev/tmux/ram_usage.sh +3 -0
  59. package/src/docs/dev/tmux/title_sync.sh +54 -0
  60. package/src/docs/dev/tmux/tmux-setup.md +867 -0
  61. package/src/docs/dev/tmux/tmux-test.sh +255 -0
  62. package/src/docs/dev/tmux/tmux.conf +127 -0
  63. package/src/docs/dev/tmux/xclip +18 -0
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ UI/UX Pro Max Search - BM25 search engine for UI/UX style guides
5
+ Usage: python search.py "<query>" [--domain <domain>] [--stack <stack>] [--max-results 3]
6
+ python search.py "<query>" --design-system [-p "Project Name"]
7
+ python search.py "<query>" --design-system --persist [-p "Project Name"] [--page "dashboard"]
8
+
9
+ Domains: style, prompt, color, chart, landing, product, ux, typography
10
+ Stacks: html-tailwind, react, nextjs
11
+
12
+ Persistence (Master + Overrides pattern):
13
+ --persist Save design system to design-system/MASTER.md
14
+ --page Also create a page-specific override file in design-system/pages/
15
+ """
16
+
17
+ import argparse
18
+ import sys
19
+ import io
20
+ from core import CSV_CONFIG, AVAILABLE_STACKS, MAX_RESULTS, search, search_stack
21
+ from design_system import generate_design_system, persist_design_system
22
+
23
+ # Force UTF-8 for stdout/stderr to handle emojis on Windows (cp1252 default)
24
+ if sys.stdout.encoding and sys.stdout.encoding.lower() != 'utf-8':
25
+ sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
26
+ if sys.stderr.encoding and sys.stderr.encoding.lower() != 'utf-8':
27
+ sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8')
28
+
29
+
30
+ def format_output(result):
31
+ """Format results for Claude consumption (token-optimized)"""
32
+ if "error" in result:
33
+ return f"Error: {result['error']}"
34
+
35
+ output = []
36
+ if result.get("stack"):
37
+ output.append(f"## UI Pro Max Stack Guidelines")
38
+ output.append(f"**Stack:** {result['stack']} | **Query:** {result['query']}")
39
+ else:
40
+ output.append(f"## UI Pro Max Search Results")
41
+ output.append(f"**Domain:** {result['domain']} | **Query:** {result['query']}")
42
+ output.append(f"**Source:** {result['file']} | **Found:** {result['count']} results\n")
43
+
44
+ for i, row in enumerate(result['results'], 1):
45
+ output.append(f"### Result {i}")
46
+ for key, value in row.items():
47
+ value_str = str(value)
48
+ if len(value_str) > 300:
49
+ value_str = value_str[:300] + "..."
50
+ output.append(f"- **{key}:** {value_str}")
51
+ output.append("")
52
+
53
+ return "\n".join(output)
54
+
55
+
56
+ if __name__ == "__main__":
57
+ parser = argparse.ArgumentParser(description="UI Pro Max Search")
58
+ parser.add_argument("query", help="Search query")
59
+ parser.add_argument("--domain", "-d", choices=list(CSV_CONFIG.keys()), help="Search domain")
60
+ parser.add_argument("--stack", "-s", choices=AVAILABLE_STACKS, help="Stack-specific search (html-tailwind, react, nextjs)")
61
+ parser.add_argument("--max-results", "-n", type=int, default=MAX_RESULTS, help="Max results (default: 3)")
62
+ parser.add_argument("--json", action="store_true", help="Output as JSON")
63
+ # Design system generation
64
+ parser.add_argument("--design-system", "-ds", action="store_true", help="Generate complete design system recommendation")
65
+ parser.add_argument("--project-name", "-p", type=str, default=None, help="Project name for design system output")
66
+ parser.add_argument("--format", "-f", choices=["ascii", "markdown"], default="ascii", help="Output format for design system")
67
+ # Persistence (Master + Overrides pattern)
68
+ parser.add_argument("--persist", action="store_true", help="Save design system to design-system/MASTER.md (creates hierarchical structure)")
69
+ parser.add_argument("--page", type=str, default=None, help="Create page-specific override file in design-system/pages/")
70
+ parser.add_argument("--output-dir", "-o", type=str, default=None, help="Output directory for persisted files (default: current directory)")
71
+
72
+ args = parser.parse_args()
73
+
74
+ # Design system takes priority
75
+ if args.design_system:
76
+ result = generate_design_system(
77
+ args.query,
78
+ args.project_name,
79
+ args.format,
80
+ persist=args.persist,
81
+ page=args.page,
82
+ output_dir=args.output_dir
83
+ )
84
+ print(result)
85
+
86
+ # Print persistence confirmation
87
+ if args.persist:
88
+ project_slug = args.project_name.lower().replace(' ', '-') if args.project_name else "default"
89
+ print("\n" + "=" * 60)
90
+ print(f"✅ Design system persisted to design-system/{project_slug}/")
91
+ print(f" 📄 design-system/{project_slug}/MASTER.md (Global Source of Truth)")
92
+ if args.page:
93
+ page_filename = args.page.lower().replace(' ', '-')
94
+ print(f" 📄 design-system/{project_slug}/pages/{page_filename}.md (Page Overrides)")
95
+ print("")
96
+ print(f"📖 Usage: When building a page, check design-system/{project_slug}/pages/[page].md first.")
97
+ print(f" If exists, its rules override MASTER.md. Otherwise, use MASTER.md.")
98
+ print("=" * 60)
99
+ # Stack search
100
+ elif args.stack:
101
+ result = search_stack(args.query, args.stack, args.max_results)
102
+ if args.json:
103
+ import json
104
+ print(json.dumps(result, indent=2, ensure_ascii=False))
105
+ else:
106
+ print(format_output(result))
107
+ # Domain search
108
+ else:
109
+ result = search(args.query, args.domain, args.max_results)
110
+ if args.json:
111
+ import json
112
+ print(json.dumps(result, indent=2, ensure_ascii=False))
113
+ else:
114
+ print(format_output(result))
@@ -0,0 +1,151 @@
1
+ ---
2
+ name: ux-audit
3
+ description: Squidhub UI/UX audit skill — design token compliance, accessibility, component reuse, layout patterns, and interaction quality review
4
+ version: 1.0.0
5
+ author: bmad
6
+ tags: [ux, ui, accessibility, design-tokens, shadcn, review, audit]
7
+ ---
8
+
9
+ # UX Audit Skill
10
+
11
+ ## Overview
12
+
13
+ Load this skill when performing a UX/UI review on Squidhub frontend code. It defines the full audit methodology, checklist, finding format, and verdict rules for the `ux-designer-agent` running the UV (UI Review) lens.
14
+
15
+ Use alongside `excalidraw-dark-standard` when the audit target includes new UI components that need diagramming.
16
+
17
+ ---
18
+
19
+ ## Audit Scope
20
+
21
+ Target files: `.tsx`, `.jsx`, `.css` in `frontend/` (skip `dist/`, `.next/`, generated files).
22
+
23
+ Auto-pass for pure backend changes (no `.tsx`/`.jsx`/`.css` in the diff).
24
+
25
+ ---
26
+
27
+ ## Audit Checklist — 7 Categories
28
+
29
+ ### CAT-1: Design Token Compliance
30
+ - All colors use design tokens (`background`, `foreground`, `primary`, `secondary`, `muted`, `accent`, `border`, `muted-foreground`) — no hardcoded hex/RGB/Tailwind color classes
31
+ - Background variants: `bg-muted/50`, `bg-primary/10` — never `bg-orange-50` or similar
32
+ - Border: `border-muted`, `border-border` — never `border-orange-200`
33
+ - Icon colors: `text-muted-foreground`, `text-primary` — never `text-gray-400`
34
+
35
+ ### CAT-2: Component Reuse (ShadCN + Squidhub catalog)
36
+ - Check `frontend/components/ui/` for any reimplemented component
37
+ - Spinners, badges, data tables, buttons, dialogs — must import from `@/components/ui/*`
38
+ - New reusable components must be added to `docs/frontend/styling-standards.md`
39
+ - Page layout must use `PageHeader` / `PageBody` / `PageHeaderTab` from `frontend/components/layout/`
40
+
41
+ ### CAT-3: Dialog Pattern (WCAG 2.1)
42
+ All dialogs must use the flex-column pattern:
43
+ ```tsx
44
+ <DialogContent className="max-w-2xl max-h-[70vh] overflow-hidden flex flex-col gap-0 p-0">
45
+ <DialogHeader className="flex-shrink-0 px-6 pt-6 pb-4">...</DialogHeader>
46
+ <div className="flex-1 overflow-y-auto px-6 py-4">...</div>
47
+ <DialogFooter className="flex-shrink-0 px-6 py-4">...</DialogFooter>
48
+ </DialogContent>
49
+ ```
50
+ Flag: missing `overflow-hidden`, missing `flex-shrink-0` on header/footer, missing `flex-1 overflow-y-auto` on body.
51
+
52
+ ### CAT-4: Accessibility
53
+ - Interactive elements have `aria-label` or visible label text
54
+ - `<img>` and `<Image>` have descriptive `alt` attributes (not empty unless decorative)
55
+ - Tab order is logical — no `tabIndex` hacks
56
+ - Focus states visible on interactive elements
57
+ - Color contrast: text on background meets WCAG AA (4.5:1 normal, 3:1 large)
58
+ - Loading states communicated to screen readers (`aria-busy`, `aria-live`)
59
+
60
+ ### CAT-5: Interaction & Feedback Quality
61
+ - All async actions show loading state (spinner, disabled button, skeleton)
62
+ - Error states displayed with actionable messages (not raw API errors)
63
+ - Empty states have meaningful copy and a CTA where appropriate
64
+ - Destructive actions require confirmation (delete dialogs, irreversible operations)
65
+ - Forms validate on submit and show inline field-level errors
66
+
67
+ ### CAT-6: Layout & Responsiveness
68
+ - Pages work at `sm` (640px), `md` (768px), `lg` (1024px), `xl` (1280px)
69
+ - No content overflow without scroll handling
70
+ - Tables on small screens: horizontal scroll or card layout
71
+ - Grids use responsive Tailwind breakpoints (`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`)
72
+ - Modals do not overflow viewport on mobile
73
+
74
+ ### CAT-7: Typography & Visual Hierarchy
75
+ - Heading levels are semantic and sequential (h1 → h2 → h3)
76
+ - No font-size hardcoding outside of design system classes
77
+ - Visual hierarchy is clear: primary action stands out, secondary is muted
78
+ - Consistent spacing — uses Tailwind spacing scale, not arbitrary `px-7` or `mt-9`
79
+
80
+ ---
81
+
82
+ ## Severity Guide
83
+
84
+ | Severity | Condition |
85
+ |---|---|
86
+ | 🔴 Critical | WCAG 2.1 AA violation; hardcoded color that breaks theming; dialog without flex-column pattern (scroll breaks); blocking interaction bug |
87
+ | 🟡 Major | Missing loading/error state; reimplemented component; missing aria-label on important interactive element; layout broken at one breakpoint |
88
+ | 🟢 Minor | Naming inconsistency; minor spacing irregularity; non-blocking visual improvement |
89
+
90
+ ---
91
+
92
+ ## Finding Format
93
+
94
+ ```
95
+ ### [UV-001] {title}
96
+ File: {path}:{line}
97
+ Category: CAT-{N} — {category name}
98
+ Severity: 🔴 Critical | 🟡 Major | 🟢 Minor
99
+ Issue: {description — what is wrong and why it matters}
100
+ Fix: {specific fix with code snippet if helpful}
101
+ ```
102
+
103
+ ---
104
+
105
+ ## Output Format
106
+
107
+ Write findings to:
108
+ ```
109
+ _bmad-output/features/{feature-slug}/planning/uv-review-findings-{artifact_id}.md
110
+ ```
111
+
112
+ Return verdict:
113
+ ```yaml
114
+ uv_review_verdict:
115
+ target: {path or feature name}
116
+ actionable_count: {N}
117
+ critical: {count of 🔴}
118
+ major: {count of 🟡}
119
+ minor: {count of 🟢}
120
+ findings_path: _bmad-output/features/{feature-slug}/planning/uv-review-findings-{artifact_id}.md
121
+ status: passed | needs_fixes
122
+ ```
123
+
124
+ **Status rules:**
125
+ - `passed` — zero critical and ≤3 major findings
126
+ - `needs_fixes` — any critical OR 4+ major findings
127
+
128
+ ---
129
+
130
+ ## Auto-Pass Conditions
131
+
132
+ ```yaml
133
+ uv_review_verdict:
134
+ status: passed
135
+ note: "Pure backend change — no frontend files in diff."
136
+ ```
137
+
138
+ Trigger when: diff contains zero `.tsx`, `.jsx`, `.css` files.
139
+
140
+ ---
141
+
142
+ ## Reference Documents
143
+
144
+ Always read before auditing:
145
+ - `docs/frontend/styling-standards.md` — design tokens, component catalog, dialog patterns
146
+ - `docs/frontend/form-patterns.md` — React Hook Form, validation patterns
147
+ - `docs/frontend/page-layout-patterns.md` — PageHeader/PageBody, tabbed routing
148
+
149
+ ---
150
+
151
+ _v1.0 — 2026-03-14_
@@ -0,0 +1,168 @@
1
+ ---
2
+ name: websocket-engineer
3
+ description: Use when building real-time communication systems with WebSockets or Socket.IO. Invoke for bidirectional messaging, horizontal scaling with Redis, presence tracking, room management.
4
+ license: MIT
5
+ metadata:
6
+ author: https://github.com/Jeffallan
7
+ version: "1.1.0"
8
+ domain: api-architecture
9
+ triggers: WebSocket, Socket.IO, real-time communication, bidirectional messaging, pub/sub, server push, live updates, chat systems, presence tracking
10
+ role: specialist
11
+ scope: implementation
12
+ output-format: code
13
+ related-skills: fastapi-expert, nestjs-expert, devops-engineer, monitoring-expert, security-reviewer
14
+ ---
15
+
16
+ # WebSocket Engineer
17
+
18
+ ## Core Workflow
19
+
20
+ 1. **Analyze requirements** — Identify connection scale, message volume, latency needs
21
+ 2. **Design architecture** — Plan clustering, pub/sub, state management, failover
22
+ 3. **Implement** — Build WebSocket server with authentication, rooms, events
23
+ 4. **Validate locally** — Test connection handling, auth, and room behavior before scaling (e.g., `npx wscat -c ws://localhost:3000`); confirm auth rejection on missing/invalid tokens, room join/leave events, and message delivery
24
+ 5. **Scale** — Verify Redis connection and pub/sub round-trip before enabling the adapter; configure sticky sessions and confirm with test connections across multiple instances; set up load balancing
25
+ 6. **Monitor** — Track connections, latency, throughput, error rates; add alerts for connection-count spikes and error-rate thresholds
26
+
27
+ ## Reference Guide
28
+
29
+ Load detailed guidance based on context:
30
+
31
+ | Topic | Reference | Load When |
32
+ |-------|-----------|-----------|
33
+ | Protocol | `references/protocol.md` | WebSocket handshake, frames, ping/pong, close codes |
34
+ | Scaling | `references/scaling.md` | Horizontal scaling, Redis pub/sub, sticky sessions |
35
+ | Patterns | `references/patterns.md` | Rooms, namespaces, broadcasting, acknowledgments |
36
+ | Security | `references/security.md` | Authentication, authorization, rate limiting, CORS |
37
+ | Alternatives | `references/alternatives.md` | SSE, long polling, when to choose WebSockets |
38
+
39
+ ## Code Examples
40
+
41
+ ### Server Setup (Socket.IO with Auth and Room Management)
42
+
43
+ ```js
44
+ import { createServer } from "http";
45
+ import { Server } from "socket.io";
46
+ import { createAdapter } from "@socket.io/redis-adapter";
47
+ import { createClient } from "redis";
48
+ import jwt from "jsonwebtoken";
49
+
50
+ const httpServer = createServer();
51
+ const io = new Server(httpServer, {
52
+ cors: { origin: process.env.ALLOWED_ORIGIN, credentials: true },
53
+ pingTimeout: 20000,
54
+ pingInterval: 25000,
55
+ });
56
+
57
+ // Authentication middleware — runs before connection is established
58
+ io.use((socket, next) => {
59
+ const token = socket.handshake.auth.token;
60
+ if (!token) return next(new Error("Authentication required"));
61
+ try {
62
+ socket.data.user = jwt.verify(token, process.env.JWT_SECRET);
63
+ next();
64
+ } catch {
65
+ next(new Error("Invalid token"));
66
+ }
67
+ });
68
+
69
+ // Redis adapter for horizontal scaling
70
+ const pubClient = createClient({ url: process.env.REDIS_URL });
71
+ const subClient = pubClient.duplicate();
72
+ await Promise.all([pubClient.connect(), subClient.connect()]);
73
+ io.adapter(createAdapter(pubClient, subClient));
74
+
75
+ io.on("connection", (socket) => {
76
+ const { userId } = socket.data.user;
77
+ console.log(`connected: ${userId} (${socket.id})`);
78
+
79
+ // Presence: mark user online
80
+ pubClient.hSet("presence", userId, socket.id);
81
+
82
+ socket.on("join-room", (roomId) => {
83
+ socket.join(roomId);
84
+ socket.to(roomId).emit("user-joined", { userId });
85
+ });
86
+
87
+ socket.on("message", ({ roomId, text }) => {
88
+ io.to(roomId).emit("message", { userId, text, ts: Date.now() });
89
+ });
90
+
91
+ socket.on("disconnect", () => {
92
+ pubClient.hDel("presence", userId);
93
+ console.log(`disconnected: ${userId}`);
94
+ });
95
+ });
96
+
97
+ httpServer.listen(3000);
98
+ ```
99
+
100
+ ### Client-Side Reconnection with Exponential Backoff
101
+
102
+ ```js
103
+ import { io } from "socket.io-client";
104
+
105
+ const socket = io("wss://api.example.com", {
106
+ auth: { token: getAuthToken() },
107
+ reconnection: true,
108
+ reconnectionAttempts: 10,
109
+ reconnectionDelay: 1000, // initial delay (ms)
110
+ reconnectionDelayMax: 30000, // cap at 30 s
111
+ randomizationFactor: 0.5, // jitter to avoid thundering herd
112
+ });
113
+
114
+ // Queue messages while disconnected
115
+ let messageQueue = [];
116
+
117
+ socket.on("connect", () => {
118
+ console.log("connected:", socket.id);
119
+ // Flush queued messages
120
+ messageQueue.forEach((msg) => socket.emit("message", msg));
121
+ messageQueue = [];
122
+ });
123
+
124
+ socket.on("disconnect", (reason) => {
125
+ console.warn("disconnected:", reason);
126
+ if (reason === "io server disconnect") socket.connect(); // manual reconnect
127
+ });
128
+
129
+ socket.on("connect_error", (err) => {
130
+ console.error("connection error:", err.message);
131
+ });
132
+
133
+ function sendMessage(roomId, text) {
134
+ const msg = { roomId, text };
135
+ if (socket.connected) {
136
+ socket.emit("message", msg);
137
+ } else {
138
+ messageQueue.push(msg); // buffer until reconnected
139
+ }
140
+ }
141
+ ```
142
+
143
+ ## Constraints
144
+
145
+ ### MUST DO
146
+ - Use sticky sessions for load balancing (WebSocket connections are stateful — requests must route to the same server instance)
147
+ - Implement heartbeat/ping-pong to detect dead connections (TCP keepalive alone is insufficient)
148
+ - Use rooms/namespaces for message scoping rather than filtering in application logic
149
+ - Queue messages during disconnection windows to avoid silent data loss
150
+ - Plan connection limits per instance before scaling horizontally
151
+
152
+ ### MUST NOT DO
153
+ - Store large state in memory without a clustering strategy (use Redis or an external store)
154
+ - Mix WebSocket and HTTP on the same port without explicit upgrade handling
155
+ - Forget to handle connection cleanup (presence records, room membership, in-flight timers)
156
+ - Skip load testing before production — connection-count spikes behave differently from HTTP traffic spikes
157
+
158
+ ## Output Templates
159
+
160
+ When implementing WebSocket features, provide:
161
+ 1. Server setup (Socket.IO/ws configuration)
162
+ 2. Event handlers (connection, message, disconnect)
163
+ 3. Client library (connection, events, reconnection)
164
+ 4. Brief explanation of scaling strategy
165
+
166
+ ## Knowledge Reference
167
+
168
+ Socket.IO, ws, uWebSockets.js, Redis adapter, sticky sessions, nginx WebSocket proxy, JWT over WebSocket, rooms/namespaces, acknowledgments, binary data, compression, heartbeat, backpressure, horizontal pod autoscaling