Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

chatkit-integration

БесплатноБез исполняемых скриптовНе проверен

Foundation skill for integrating OpenAI ChatKit framework with custom backends. This skill should be used for initial ChatKit setup including server…

mjunaidcaот mjunaidca★ 27 звёзд на GitHub

Об этом скилле

ChatKit Integration Skill (Tier 1: Foundation)

Overview

This skill provides the foundation for ChatKit integration - getting the basic chat working end-to-end with your custom backend and agent. It covers:

  • Backend: ChatKitServer setup, database persistence, agent wiring
  • Frontend: useChatKit configuration, authentication, context injection
  • Infrastructure: Script loading, httpOnly cookie proxy (Next.js)

For advanced capabilities, see related skills:

  • chatkit-streaming (Tier 2): Response lifecycle, progress updates, client effects
  • chatkit-actions (Tier 3): Interactive widgets, entity tagging, composer tools

Persona

You are a full-stack engineer integrating OpenAI ChatKit framework with a custom backend and AI agents. You understand that ChatKit provides standardized conversation UI/UX, but requires custom integration to work with domain-specific agents and context.

Questions to Ask Before Implementing

  1. Backend Integration:

    • What agent framework are you using? (OpenAI Agents SDK, LangChain, custom)
    • What tools does your agent need? (RAG search, custom functions)
    • What context does your agent need? (user profile, page context, conversation history)
    • What database are you using? (PostgreSQL, MongoDB, Redis)
  2. Frontend Integration:

    • What frontend framework? (React, Next.js, Docusaurus)
    • How is authentication handled? (OAuth, JWT, session cookies, httpOnly cookies)
    • Are auth tokens stored in httpOnly cookies? (Requires server-side proxy)
    • What context can you extract client-side? (page URL, title, DOM content)
    • Do you need custom UI features? (text selection, personalization menu)
  3. Context Requirements:

    • What user information is available? (name, email, role, preferences)
    • What page context is needed? (URL, title, headings, content)
    • How should context be transmitted? (headers, metadata, query params)
    • Should context be included in every request or only when needed?
  4. Persistence Requirements:

    • Do conversations need to persist across sessions?
    • What's the expected conversation volume? (affects database choice)
    • Do you need multi-tenancy? (organization isolation)
    • What's the retention policy? (how long to keep conversations)

Principles

Backend Principles

  1. Extend ChatKit Server, Don't Replace

    • Inherit from ChatKitServer[RequestContext]
    • Override only respond() method for agent execution
    • Let base class handle read-only operations (threads.list, items.list)
    • Rationale: ChatKit handles protocol, you handle agent logic
  2. Context Injection in Prompt

    • Include conversation history as string in system prompt (CarFixer pattern)
    • Include user context (name, profile) in system prompt
    • Include page context (current page) in system prompt
    • Rationale: Agent SDK receives single prompt, history must be in prompt
  3. User Isolation via RequestContext

    • All operations scoped by user_id in RequestContext
    • Store operations filter by user_id automatically
    • Never expose data across users
    • Rationale: Multi-tenant safety, data privacy
  4. Graceful Degradation

    • System starts even if database unavailable (ChatKit disabled)
    • RAG search can fail without blocking ChatKit
    • Log warnings but don't crash
    • Rationale: Partial functionality better than no functionality
  5. Connection Pool Warmup

    • Pre-warm database connections on startup
    • Avoids 7+ second first-request delay
    • Test connections before use (pool_pre_ping=True)
    • Rationale: Production-ready performance

Frontend Principles

  1. Custom Fetch Interceptor

    • Provide custom fetch function to useChatKit config
    • Intercept all ChatKit requests
    • Add authentication headers (X-User-ID)
    • Add metadata (userInfo, pageContext) to request body
    • Rationale: ChatKit doesn't handle auth natively, you must inject it
  2. Script Loading Detection

    • Check for ChatKit custom element before rendering
    • Listen for script load events
    • Only render ChatKit component when script ready
    • Handle script load failures gracefully
    • Rationale: External script required, component fails without it
  3. Page Context Extraction

    • Extract client-side (DOM, window.location)
    • Include: URL, title, path, headings, meta description
    • Send with every message (in metadata)
    • Rationale: Agent needs to know what user is viewing
  4. Build-Time Configuration

    • Read env vars in docusaurus.config.ts (build-time)
    • Add to customFields for client-side access
    • Don't use process.env in browser code
    • Rationale: Static sites bake config at build time
  5. Authentication Gate

    • Require login before allowing chat access
    • Show login prompt if not authenticated
    • Redirect to OAuth flow
    • Rationale: User ID required for conversation persistence
Полный SKILL.md на GitHub

Установить chatkit-integration в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/nextjs-httponly-cookie-proxy.mdreferences/nextjs-script-loading.md

FAQ

Что делает скилл chatkit-integration?

Foundation skill for integrating OpenAI ChatKit framework with custom backends. This skill should be used for initial ChatKit setup including server implementation, React component integration, authentication, context injection, and database persistence. For streaming UI patterns use chatkit-streaming. For interactive widgets and actions use chatkit-actions.

Как установить скилл chatkit-integration?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл chatkit-integration запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить chatkit-integration с