From copilotkit
Builds AI-powered features with CopilotKit v2: chat interfaces, frontend tools, agent context, interrupts, and runtime setup.
How this skill is triggered — by the user, by Claude, or both
Slash command
/copilotkit:copilotkit-developThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
This plugin includes an MCP server (`copilotkit-docs`) that provides `search-docs` and `search-code` tools for querying live CopilotKit documentation and source code.
This plugin includes an MCP server (copilotkit-docs) that provides search-docs and search-code tools for querying live CopilotKit documentation and source code.
.mcp.json -- no setup needed.CopilotKit v2 is built on the AG-UI protocol (@ag-ui/client / @ag-ui/core). The stack has three layers:
@copilotkit/runtime, v2 symbols under @copilotkit/runtime/v2) -- Server-side. Hosts agents, handles SSE/Intelligence transport, middleware, transcription.@copilotkit/core) -- Shared state management, tool registry, suggestion engine. Not imported directly by apps.@copilotkit/react-core, v2 symbols under @copilotkit/react-core/v2) -- Provider, chat components, hooks. Re-exports everything from @ag-ui/client so apps need only one import.Create a CopilotRuntime (or the explicit CopilotSseRuntime / CopilotIntelligenceRuntime) and expose it via createCopilotHonoHandler (Hono) or createCopilotExpressHandler (Express).
import {
CopilotRuntime,
createCopilotHonoHandler,
} from "@copilotkit/runtime/v2";
import { LangGraphAgent } from "@copilotkit/runtime/langgraph";
import { handle } from "hono/vercel";
const runtime = new CopilotRuntime({
agents: {
myAgent: new LangGraphAgent({
/* ... */
}),
},
});
const app = createCopilotHonoHandler({
runtime,
basePath: "/api/copilotkit",
});
// Multi-route (the default): export every method the runtime serves.
// useThreads needs them all — rename via PATCH, delete via DELETE; archive
// uses the already-exported POST.
export const GET = handle(app);
export const POST = handle(app);
export const PATCH = handle(app);
export const DELETE = handle(app);
Use the CopilotKit provider (from @copilotkit/react-core/v2). It is the compatibility bridge across v1 and v2 and a strict superset of the legacy CopilotKitProvider -- all CopilotKitProvider props work on it.
import { CopilotKit } from "@copilotkit/react-core/v2";
function App() {
return (
// useSingleEndpoint={false} matches the multi-route backend above. The
// v1-compat CopilotKit bridge defaults it to true (single transport),
// which would 404 against a multi-route handler.
<CopilotKit runtimeUrl="/api/copilotkit" useSingleEndpoint={false}>
<YourApp />
</CopilotKit>
);
}
Use <CopilotChat>, <CopilotPopup>, or <CopilotSidebar>:
import { CopilotChat } from "@copilotkit/react-core/v2";
function ChatPage() {
return <CopilotChat agentId="myAgent" />;
}
Let the agent call functions in the browser:
import { useFrontendTool } from "@copilotkit/react-core/v2";
import { z } from "zod";
useFrontendTool({
name: "highlightCell",
description: "Highlight a spreadsheet cell",
parameters: z.object({ row: z.number(), col: z.number() }),
handler: async ({ row, col }) => {
highlightCell(row, col);
return "done";
},
});
Provide runtime data to the agent:
import { useAgentContext } from "@copilotkit/react-core/v2";
useAgentContext({
description: "The user's current shopping cart",
value: cart, // any JSON-serializable value
});
When an agent pauses for human input:
import { useInterrupt } from "@copilotkit/react-core/v2";
useInterrupt({
render: ({ event, resolve }) => (
<div>
<p>{event.value.question}</p>
<button onClick={() => resolve({ approved: true })}>Approve</button>
</div>
),
});
Show custom UI when tools execute:
import { useRenderTool } from "@copilotkit/react-core/v2";
import { z } from "zod";
useRenderTool(
{
name: "searchDocs",
parameters: z.object({ query: z.string() }),
render: ({ status, parameters, result }) => {
if (status === "executing")
return <Spinner>Searching {parameters.query}...</Spinner>;
if (status === "complete") return <Results data={result} />;
return <div>Preparing...</div>;
},
},
[],
);
| Hook | Purpose |
|---|---|
useFrontendTool | Register a tool the agent can call in the browser |
useComponent | Register a React component as a chat-rendered tool (convenience wrapper around useFrontendTool) |
useAgentContext | Share JSON-serializable application state with the agent |
useAgent | Get the AbstractAgent instance for an agent ID; subscribe to message/state/run-status changes |
useInterrupt | Handle on_interrupt events from agents with render + optional handler/enabled predicate |
useHumanInTheLoop | Register a tool that pauses execution until the user responds via a rendered UI |
useRenderTool | Register a renderer for tool calls (by name or wildcard "*") |
useDefaultRenderTool | Register a wildcard "*" renderer using the built-in expandable card UI |
useRenderToolCall | Internal hook returning a function to resolve the correct renderer for a given tool call |
useRenderActivityMessage | Internal hook for rendering activity messages by type |
useRenderCustomMessages | Internal hook for rendering custom message decorators |
useSuggestions | Read the current suggestion list and control reload/clear |
useConfigureSuggestions | Register static or dynamic (LLM-generated) suggestion configs |
useThreads | List, rename, archive, and delete Intelligence platform threads |
| Component | Purpose |
|---|---|
CopilotKit | Root provider (from @copilotkit/react-core/v2) -- configures runtime URL, headers, agents, error handler |
CopilotChat | Full chat interface connected to an agent (inline layout) |
CopilotPopup | Chat in a floating popup with toggle button |
CopilotSidebar | Chat in a collapsible sidebar with toggle button |
CopilotChatView | Headless chat view with slots for message view, input, scroll, suggestions |
CopilotChatInput | Chat input textarea with send/stop/transcribe controls |
CopilotChatMessageView | Renders the message list |
CopilotChatSuggestionView | Renders suggestion pills |
All v2 runtime symbols import from @copilotkit/runtime/v2 (createCopilotExpressHandler from @copilotkit/runtime/v2/express).
| Export | Purpose |
|---|---|
CopilotRuntime | Auto-detecting runtime (delegates to SSE or Intelligence) |
CopilotSseRuntime | Explicit SSE-mode runtime |
CopilotIntelligenceRuntime | Intelligence-mode runtime with durable threads |
createCopilotHonoHandler | Create a Hono app with all CopilotKit routes |
createCopilotExpressHandler | Create an Express router with all CopilotKit routes |
CopilotKitIntelligence | Intelligence platform client configuration |
npx claudepluginhub copilotkit/copilotkit --plugin copilotkitAdds CopilotKit to existing projects or bootstraps new ones. Detects framework, installs packages, wires runtime, and sets up first chat integration.
Provides expert guidance on Vercel AI SDK for building AI features like chat interfaces, text generation, structured output, tool calling, agents, streaming, embeddings, reranking, image generation, and LLM providers.
Provides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.