Build AI chat interfaces with custom backends, authentication, and context injection.
Use when integrating chat UI with AI agents, adding auth to chat, injecting user/page context,
or implementing httpOnly cookie proxies. Covers ChatKitServer, useChatKit, and MCP auth patterns.
NOT when building simple chatbots without persistence or custom agent integration.
Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.
Quelldateien prüfen
Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
Build AI chat interfaces with custom backends, authentication, and context injection.
Use when integrating chat UI with AI agents, adding auth to chat, injecting user/page context,
or implementing httpOnly cookie proxies. Covers ChatKitServer, useChatKit, and MCP auth patterns.
NOT when building simple chatbots without persistence or custom agent integration.
Building Chat Interfaces
Build production-grade AI chat interfaces with custom backend integration.
// app/layout.tsximportScriptfrom"next/script";
exportdefaultfunctionRootLayout({ children }: { children: React.ReactNode }) {
return (
<htmllang="en"><head>
{/* MUST be beforeInteractive for web components */}
<Scriptsrc="https://cdn.platform.openai.com/deployments/chatkit/chatkit.js"strategy="beforeInteractive"
/></head><body>{children}</body></html>
);
}
MCP Tool Authentication
MCP protocol doesn't forward auth headers. Pass credentials via system prompt:
SYSTEM_PROMPT = """You are Assistant.
## Authentication Context
- User ID: {user_id}
- Access Token: {access_token}
CRITICAL: When calling ANY MCP tool, include:
- user_id: "{user_id}"
- access_token: "{access_token}"
"""# Format with credentials
instructions = SYSTEM_PROMPT.format(
user_id=context.user_id,
access_token=context.metadata.get("access_token", ""),
)
Common Pitfalls
Issue
Symptom
Fix
History not in prompt
Agent doesn't remember conversation
Include history as string in system prompt
Context not transmitted
Agent missing user/page info
Add to request metadata, extract in backend
Script not loaded
Component fails to render
Detect script loading, wait before rendering
Auth headers missing
Backend rejects requests
Use custom fetch interceptor
httpOnly cookies
Can't read token from JS
Create server-side API route proxy
First request slow
7+ second delay
Pre-warm database connection pool
Verification
Run: python3 scripts/verify.py
Expected: ✓ building-chat-interfaces skill ready
If Verification Fails
Check: references/ folder has chatkit-integration-patterns.md