skills/chat-specialist/SKILL.md
# Chat Specialist ## Domain Expertise - Real-time messaging systems - SSE (Server-Sent Events) and WebSocket communication - Chat UI/UX patterns - Message parsing and rendering (markdown, syntax highlighting) - Event-driven chat architecture - Connection lifecycle management ## Responsibilities 1. **Implement Chat Interfaces** with real-time message flow 2. **Handle Real-time Communication** via SSE/WebSocket 3. **Parse and Render Messages** (markdown to HTML, code highlighting) 4. **Establi
npx skillsauth add rhettark/multi-agent-dev-team skills/chat-specialistInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Before implementing, ALWAYS:
kb/frontend-patterns.md for existing chat conventionskb/api-contracts.md for SSE/WebSocket endpoint schemasRead the design document:
Create ChatService or WebSocket client:
Create message rendering utilities:
Document the chat implementation:
kb/frontend-patterns.mdkb/api-contracts.mdAfter implementation, update:
You are a Chat Specialist implementing real-time messaging.
WORKFLOW:
1. PRE-FLIGHT CHECKS (REQUIRED):
- Read kb/frontend-patterns.md for existing chat patterns
- Read kb/api-contracts.md for SSE/WebSocket endpoint schemas
- Read work/*-design.md for chat requirements
2. IMPLEMENTATION:
- Choose SSE or WebSocket based on requirements
- Implement connection service with lifecycle management
- Parse and render messages (markdown to HTML)
- Handle reconnection with exponential backoff
- Add typing indicators, read receipts (if required)
3. KNOWLEDGE BASE UPDATES (REQUIRED):
- Update kb/frontend-patterns.md with chat patterns
- Update kb/api-contracts.md with endpoint schemas
- Log design decisions in workspace notes
CONSTRAINTS:
- ALWAYS read kb/frontend-patterns.md before implementing
- ALWAYS handle connection errors and reconnection
- ALWAYS parse markdown safely (no XSS vulnerabilities)
- ALWAYS update KB after implementation
Current task: {task_description}
Design document: {design_doc_path}
class ChatService {
constructor(endpoint) {
this.endpoint = endpoint;
this.eventSource = null;
this.reconnectAttempts = 0;
this.maxReconnectAttempts = 5;
}
connect() {
this.eventSource = new EventSource(this.endpoint);
this.eventSource.onmessage = (event) => {
const message = JSON.parse(event.data);
this.handleMessage(message);
this.reconnectAttempts = 0; // Reset on successful message
};
this.eventSource.onerror = () => {
console.error('SSE connection error');
this.eventSource.close();
this.reconnect();
};
this.eventSource.onopen = () => {
console.log('SSE connection established');
this.reconnectAttempts = 0;
};
}
reconnect() {
if (this.reconnectAttempts >= this.maxReconnectAttempts) {
console.error('Max reconnection attempts reached');
this.handleConnectionFailure();
return;
}
this.reconnectAttempts++;
const delay = Math.min(1000 * Math.pow(2, this.reconnectAttempts), 30000);
console.log(`Reconnecting in ${delay}ms (attempt ${this.reconnectAttempts})`);
setTimeout(() => {
this.connect();
}, delay);
}
disconnect() {
if (this.eventSource) {
this.eventSource.close();
this.eventSource = null;
}
}
handleMessage(message) {
// Emit event for UI to handle
document.dispatchEvent(new CustomEvent('chat:message', {
detail: message
}));
}
handleConnectionFailure() {
// Emit event for UI to show error
document.dispatchEvent(new CustomEvent('chat:connection-failed', {
detail: { attempts: this.reconnectAttempts }
}));
}
}
// Usage
const chatService = new ChatService('/api/chat/stream');
chatService.connect();
// Listen for messages
document.addEventListener('chat:message', (event) => {
const message = event.detail;
renderMessage(message);
});
// Listen for connection failures
document.addEventListener('chat:connection-failed', (event) => {
showErrorNotification('Connection lost. Please refresh.');
});
import { marked } from 'marked';
class MessageRenderer {
constructor() {
// Configure marked for safe rendering
marked.setOptions({
breaks: true,
gfm: true,
sanitize: false, // Use DOMPurify instead
highlight: (code, lang) => {
// Use highlight.js or similar
return hljs.highlightAuto(code, [lang]).value;
}
});
}
render(message) {
const container = document.createElement('div');
container.className = `message message-${message.role}`;
// Render timestamp
const timestamp = document.createElement('span');
timestamp.className = 'message-timestamp';
timestamp.textContent = this.formatTimestamp(message.timestamp);
// Render content
const content = document.createElement('div');
content.className = 'message-content';
// Parse markdown and sanitize
const html = marked.parse(message.content);
content.innerHTML = DOMPurify.sanitize(html);
container.appendChild(timestamp);
container.appendChild(content);
return container;
}
formatTimestamp(timestamp) {
const date = new Date(timestamp);
return date.toLocaleTimeString('en-US', {
hour: '2-digit',
minute: '2-digit'
});
}
}
// Usage
const renderer = new MessageRenderer();
document.addEventListener('chat:message', (event) => {
const messageElement = renderer.render(event.detail);
document.querySelector('.chat-messages').appendChild(messageElement);
// Auto-scroll to bottom
messageElement.scrollIntoView({ behavior: 'smooth' });
});
class WebSocketChatService {
constructor(endpoint) {
this.endpoint = endpoint;
this.ws = null;
this.reconnectAttempts = 0;
this.maxReconnectAttempts = 5;
}
connect() {
this.ws = new WebSocket(this.endpoint);
this.ws.onopen = () => {
console.log('WebSocket connection established');
this.reconnectAttempts = 0;
};
this.ws.onmessage = (event) => {
const message = JSON.parse(event.data);
this.handleMessage(message);
};
this.ws.onerror = (error) => {
console.error('WebSocket error:', error);
};
this.ws.onclose = () => {
console.log('WebSocket connection closed');
this.reconnect();
};
}
send(message) {
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
this.ws.send(JSON.stringify(message));
} else {
console.error('WebSocket not connected');
}
}
reconnect() {
if (this.reconnectAttempts >= this.maxReconnectAttempts) {
console.error('Max reconnection attempts reached');
this.handleConnectionFailure();
return;
}
this.reconnectAttempts++;
const delay = Math.min(1000 * Math.pow(2, this.reconnectAttempts), 30000);
console.log(`Reconnecting in ${delay}ms (attempt ${this.reconnectAttempts})`);
setTimeout(() => {
this.connect();
}, delay);
}
disconnect() {
if (this.ws) {
this.ws.close();
this.ws = null;
}
}
handleMessage(message) {
document.dispatchEvent(new CustomEvent('chat:message', {
detail: message
}));
}
handleConnectionFailure() {
document.dispatchEvent(new CustomEvent('chat:connection-failed', {
detail: { attempts: this.reconnectAttempts }
}));
}
}
## Chat Patterns
### SSE Connection
Use Server-Sent Events for one-way streaming from server to client:
- **Pattern**: EventSource API with exponential backoff reconnection
- **File**: `services/chat.js` - ChatService class
- **Reconnection**: Max 5 attempts with exponential backoff (1s, 2s, 4s, 8s, 16s, 30s)
- **Events**: `chat:message`, `chat:connection-failed`
### Message Rendering
Use marked.js for markdown parsing with DOMPurify sanitization:
- **Pattern**: MessageRenderer class with safe HTML rendering
- **File**: `utils/message-renderer.js`
- **Security**: Always sanitize HTML with DOMPurify before innerHTML
- **Syntax Highlighting**: Use highlight.js in marked options
## GET /api/chat/stream
Server-Sent Events endpoint for real-time chat messages.
**Headers:**
Authorization: Bearer <token>
**SSE Event Format:**
```json
{
"role": "assistant",
"content": "Hello! How can I help you?",
"timestamp": "2025-01-15T10:30:00Z"
}
Connection:
Implementation:
services/chat.js - ChatService classkb/frontend-patterns.md#chat-patternsdevelopment
# UI/UX Specialist **Domain Expertise:** - User interface design and implementation - Component design and styling - Accessibility (a11y) best practices - Responsive design and mobile-first approach - Visual hierarchy and UX patterns **Responsibilities:** 1. Design UI components and layouts 2. Implement designs with HTML/CSS/JS 3. Ensure accessibility compliance 4. Establish UI patterns and conventions 5. Update `kb/frontend-patterns.md` with UI patterns **Pre-flight Checks:** ```bash cat kb/
tools
# OpenAI Agents SDK Python Specialist **Domain Expertise:** - OpenAI Agents SDK (Python) internals - Agent creation, configuration, tool integration - Swarm patterns and multi-agent orchestration - Prompt optimization and response handling - Tool function decoration and schemas - Latency optimization and performance tuning **Responsibilities:** 1. Design and implement agents using OpenAI Agents SDK 2. Optimize agent configurations for performance and cost 3. Create and integrate function tools
development
# Matterport SDK Specialist ## Domain Expertise - Matterport SDK (Showcase SDK, Embed SDK) - Viewer integration and lifecycle management - 3D space data formats and structures (camera poses, mattertags, sweeps) - SDK event handling and subscriptions - Camera control and navigation - Scene graph manipulation ## Responsibilities 1. **Implement SDK Integrations** following established patterns 2. **Handle Viewer Lifecycle** (initialization, ready state, cleanup) 3. **Work with SDK Data Formats*
development
# JavaScript Specialist ## Domain Expertise - Modern JavaScript (ES6+) patterns - Async/await and promise handling - Module design and organization - Event handling and delegation - DOM manipulation and performance - ES6 modules and import/export - Error handling and debugging ## Responsibilities 1. **Implement JavaScript Logic** following modern patterns 2. **Optimize Async Operations** with async/await 3. **Design Modular Code** using ES6 modules 4. **Ensure Performance** through optimized