copilotkit-react-patterns
CopilotKit React best practices for agentic applications. Use when writing, reviewing, or refactoring React code that uses CopilotKit hooks (useAgent, useFrontendTool, useRenderTool, useCopilotAction, useCopilotReadable), providers (CopilotKit), or chat UI components (CopilotChat, CopilotSidebar, CopilotPopup). Triggers on tasks involving agent integration, tool rendering, shared state, or generative UI in React.
- License 许可
- MIT
- 最近更新
- 2026-06-07
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- copilotkit-react-patterns
- license
- MIT
- metadata
- { "author": "copilotkit", "version": "2.0.0" }
- description
- CopilotKit React best practices for agentic applications. Use when writing, reviewing, or refactoring React code that uses CopilotKit hooks (useAgent, useFrontendTool, useRenderTool, useCopilotAction, useCopilotReadable), providers (CopilotKit), or chat UI components (CopilotChat, CopilotSidebar, CopilotPopup). Triggers on tasks involving agent integration, tool rendering, shared state, or generative UI in React.
03 SKILL.md 正文
CopilotKit React Patterns
Best practices for building agentic React applications with CopilotKit. Contains 25 rules across 6 categories, prioritized by impact to guide code generation and refactoring. Covers both v1 (@copilotkit/react-core) and v2 (@copilotkit/react-core/v2) APIs.
When to Apply
Reference these guidelines when:
- Setting up
CopilotKitprovider in a React application - Using agent hooks (useAgent, useFrontendTool, useCopilotAction)
- Rendering tool calls or custom messages from agents
- Managing shared state between UI and agents via useCopilotReadable or useCoAgent
- Building chat interfaces with CopilotChat, CopilotSidebar, or CopilotPopup
- Configuring suggestions for proactive agent assistance
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Provider Setup | CRITICAL | provider- |
| 2 | Agent Hooks | HIGH | agent- |
| 3 | Tool Rendering | HIGH | tool- |
| 4 | Context & State | MEDIUM | state- |
| 5 | Chat UI | MEDIUM | ui- |
| 6 | Suggestions | LOW | suggestions- |
Quick Reference
1. Provider Setup (CRITICAL)
provider-runtime-url- Always configure runtimeUrl to connect to your agent backendprovider-single-endpoint- Configure the agent prop for CoAgent routingprovider-nested-providers- Scope agent configurations with nested CopilotKit providersprovider-tool-registration- Register tools via hooks inside provider, not as props when possible
2. Agent Hooks (HIGH)
agent-use-agent-updates- Specify update subscriptions to avoid unnecessary re-rendersagent-agent-id- Always pass agentId when running multiple agentsagent-context-description- Write descriptive context values for useCopilotReadableagent-frontend-tool-deps- Declare dependency arrays for useFrontendToolagent-stable-tool-handlers- Use useCallback for tool handler functions
3. Tool Rendering (HIGH)
tool-typed-args- Define Zod schemas for useRenderTool parameters (v2)tool-status-handling- Handle all three tool call statuses (inProgress, executing, complete)tool-wildcard-fallback- Register a wildcard renderer as fallback for unknown toolstool-render-vs-frontend- Use useRenderTool for display-only, useFrontendTool for side effectstool-component-hook- Use useFrontendTool render prop for simple component rendering
4. Context & State (MEDIUM)
state-minimal-context- Provide only relevant context to agents, not entire app statestate-structured-values- Use structured objects in useCopilotReadable, not serialized stringsstate-context-granularity- Split context into multiple useCopilotReadable calls by domainstate-avoid-stale-closures- Use functional state updates in tool handlers
5. Chat UI (MEDIUM)
ui-chat-layout- Choose CopilotSidebar for persistent chat, CopilotPopup for on-demandui-custom-labels- Always customize labels for your domain instead of defaultsui-welcome-screen- Provide a welcome screen with suggested promptsui-input-mode- Use appropriate inputMode for your use case
6. Suggestions (LOW)
suggestions-configure- Use useConfigureSuggestions (v2) or useCopilotChatSuggestions (v1)suggestions-context-driven- Provide rich context so suggestions are relevantsuggestions-loading-state- Handle suggestion loading states via useSuggestions (v2)
How to Use
Read individual rule files for detailed explanations and code examples:
rules/provider-runtime-url.md
rules/agent-use-agent-updates.md
rules/tool-typed-args.md
Each rule file contains:
- Brief explanation of why it matters
- Incorrect code example with explanation
- Correct code example with explanation
- Additional context and references
Full Compiled Document
For the complete guide with all rules expanded: AGENTS.md
04 同仓库更多 Skills
crowd-prompting
A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.
ceaser
Interact with the Ceaser privacy protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- shield, unshield, note management, and protocol queries. All ceaser tool calls use CLI subcommands (npx -y ceaser-mcp <subcommand>). Ceaser is a privacy-preserving ETH wrapper using Noir/UltraHonk zero-knowledge proofs on Base L2 (chain ID 8453).
ceaser-send
Fully automated private ETH transfer via Ceaser Protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- all ceaser tool calls use CLI subcommands (npx -y ceaser-mcp <subcommand>). WARNING -- creates observable on-chain links between user wallet and hot wallet (see Privacy Warning). Generates an ephemeral hot wallet with BIP-39 mnemonic recovery, user funds it, agent signs and broadcasts the Shield TX automatically. Exactly one manual step required (funding the hot wallet with ETH). Uses Noir/UltraHonk zero-knowledge proofs.
dilemm-ai
Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).
moldium
Post and manage content on the Moldium blog platform. Triggered by "post to Moldium", "write a blog post", "publish an article", etc.
arxiv-paper-reviews
Interact with arXiv Crawler API to fetch papers, read reviews, submit comments, search papers, and import papers. Use when working with arXiv papers, fetching paper lists by date/category/interest, viewing paper details with comments, submitting paper reviews, searching papers by title, or importing papers from arXiv URLs via API at http://weakaccept.top:8000/.