← 返回 Skills 市场
generaljerel

CopilotKit React Best Practices

作者 Jerel · GitHub ↗ · v1.0.1
cross-platform ✓ 安全检测通过
721
总下载
1
收藏
1
当前安装
2
版本数
在 OpenClaw 中安装
/install copilotkit-react
功能描述
CopilotKit React best practices for agentic applications. Use when writing, reviewing, or refactoring React code that uses CopilotKit hooks (useAgent, useFro...
使用说明 (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 CopilotKit provider 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 backend
  • provider-single-endpoint - Configure the agent prop for CoAgent routing
  • provider-nested-providers - Scope agent configurations with nested CopilotKit providers
  • provider-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-renders
  • agent-agent-id - Always pass agentId when running multiple agents
  • agent-context-description - Write descriptive context values for useCopilotReadable
  • agent-frontend-tool-deps - Declare dependency arrays for useFrontendTool
  • agent-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 tools
  • tool-render-vs-frontend - Use useRenderTool for display-only, useFrontendTool for side effects
  • tool-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 state
  • state-structured-values - Use structured objects in useCopilotReadable, not serialized strings
  • state-context-granularity - Split context into multiple useCopilotReadable calls by domain
  • state-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-demand
  • ui-custom-labels - Always customize labels for your domain instead of defaults
  • ui-welcome-screen - Provide a welcome screen with suggested prompts
  • ui-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 relevant
  • suggestions-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

安全使用建议
This skill is documentation and examples for CopilotKit React usage and appears internally consistent. Before installing or using rules from it: 1) Verify the source or repository/trust of the author (metadata shows 'CopilotKit' but homepage/source is unknown). 2) When following the examples, ensure runtimeUrl/publicApiKey point to a trusted runtime/backend—do not paste production secrets into example snippets. 3) Be mindful that applying the guidance (e.g., sending app state via useCopilotReadable) may cause your app to transmit sensitive data to your agent backend; follow the skill's own advice to provide only relevant context. 4) If you need stronger assurance, obtain the original upstream docs/repo (links in metadata.json) and compare versions.
功能分析
Type: OpenClaw Skill Name: copilotkit-react Version: 1.0.1 This skill bundle is a collection of documentation and best practices for developing React applications with CopilotKit. All files are either metadata (JSON) or instructional markdown (`SKILL.md`, `AGENTS.md`, `rules/*.md`) containing code examples in React/TypeScript. There are no executable scripts, direct system commands, or network calls to suspicious domains. The instructions for the AI agent are focused on guiding code generation and refactoring, without any evidence of prompt injection for malicious purposes, data exfiltration, or unauthorized actions. All external references point to legitimate CopilotKit documentation and GitHub repositories.
能力评估
Purpose & Capability
The skill's name/description (CopilotKit React best practices) align with the included rule files, README, and AGENTS.md. All files are documentation and examples for CopilotKit hooks/components; there are no unrelated credentials, binaries, or install steps requested.
Instruction Scope
SKILL.md and rule files provide coding guidelines and code examples only. They do not instruct the agent to read arbitrary system files, access unrelated environment variables, or send data to hidden endpoints. Example usage includes runtimeUrl/publicApiKey placeholders, but those are documented examples for legitimate configuration rather than secret-exfiltration instructions.
Install Mechanism
This is an instruction-only skill with no install spec and no code to execute. No downloads, installers, or third-party package installs are defined in the manifest.
Credentials
The skill declares no required environment variables, binaries, or config paths. Example snippets reference runtimeUrl and publicApiKey as legitimate configuration options for CopilotKit, but the skill does not demand secrets or unrelated credentials.
Persistence & Privilege
Flags show always:false and normal autonomous invocation allowed. The skill does not request permanent presence or modify other skills or system-wide settings. Its scope is documentation and guidance.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install copilotkit-react
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /copilotkit-react 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
**CopilotKit React Patterns 2.0.0 – Major update for v2 API support** - Expanded guidance to cover both v1 (`@copilotkit/react-core`) and v2 (`@copilotkit/react-core/v2`) APIs. - Updated provider setup and rules for the new `CopilotKit` provider and `CoAgent` routing. - Revised agent/state rules to reflect new hooks (`useCopilotAction`, `useCopilotReadable`) and best practices. - Adjusted tool integration advice for v2 API patterns (including Zod schemas and new render prop usage). - Added version-specific suggestions handling and clarified API differences in recommendations.
v1.0.0
Initial release with comprehensive best practices and patterns for CopilotKit in React: - Introduces 25 best practice rules across 6 prioritized categories for agentic React applications. - Covers provider setup, agent hooks, tool rendering, context/state management, chat UI, and suggestions. - Details when and how to apply each pattern, with a structured quick reference and rule naming conventions. - Each rule includes rationale, incorrect/correct examples, and extra context. - Provides guidance for integrating CopilotKit hooks, providers, and chat components in advanced React projects.
元数据
Slug copilotkit-react
版本 1.0.1
许可证
累计安装 1
当前安装数 1
历史版本数 2
常见问题

CopilotKit React Best Practices 是什么?

CopilotKit React best practices for agentic applications. Use when writing, reviewing, or refactoring React code that uses CopilotKit hooks (useAgent, useFro... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 721 次。

如何安装 CopilotKit React Best Practices?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install copilotkit-react」即可一键安装,无需额外配置。

CopilotKit React Best Practices 是免费的吗?

是的,CopilotKit React Best Practices 完全免费(开源免费),可自由下载、安装和使用。

CopilotKit React Best Practices 支持哪些平台?

CopilotKit React Best Practices 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 CopilotKit React Best Practices?

由 Jerel(@generaljerel)开发并维护,当前版本 v1.0.1。

💬 留言讨论