--- name: building-ai-chat description: Builds AI chat interfaces and conversational UI with streaming responses, context management, and multi-modal support. Use when creating ChatGPT-style interfaces, AI assistants, code copilots, or conversational agents. Handles streaming text, token limits, regeneration, feedback loops, tool usage visualization, and AI-specific error patterns. Provides battle-tested components from leading AI products with accessibility and performance built in. --- # AI Chat Interface Components ## Purpose Define the emerging standards for AI/human conversational interfaces in the 2024-2025 AI integration boom. This skill leverages meta-knowledge from building WITH Claude to establish definitive patterns for streaming UX, context management, and multi-modal interactions. As the industry lacks established patterns, this provides the reference implementation others will follow. ## When to Use Activate this skill when: - Building ChatGPT-style conversational interfaces - Creating AI assistants, copilots, or chatbots - Implementing streaming text responses with markdown - Managing conversation context and token limits - Handling multi-modal inputs (text, images, files, voice) - Dealing with AI-specific errors (hallucinations, refusals, limits) - Adding feedback mechanisms (thumbs, regeneration, editing) - Implementing conversation branching or threading - Visualizing tool/function calling ## Quick Start Minimal AI chat interface in under 50 lines: ```tsx import { useChat } from 'ai/react'; export function MinimalAIChat() { const { messages, input, handleInputChange, handleSubmit, isLoading, stop } = useChat(); return (
{messages.map(m => (
{m.content}
))} {isLoading &&
AI is thinking...
}
{isLoading ? ( ) : ( )}
); } ``` For complete implementation with streaming markdown, see `examples/basic-chat.tsx`. ## Core Components ### Message Display Build user, AI, and system message bubbles with streaming support: ```tsx // User message
{message.content}
// AI message with streaming
{message.content} {message.isStreaming && }
// System message
{message.content}
``` For markdown rendering, code blocks, and formatting details, see `references/message-components.md`. ### Input Components Create rich input experiences with attachments and voice: ```tsx