AGENT SKILL

React 组件组合模式设计

vercel-composition-patterns

可规模化的 React 组件组合模式。适用于重构存在布尔属性泛滥的组件、构建灵活的组件库或设计可复用的 API。在涉及复合组件、渲染属性(render props)、上下文提供器(Context Provider)或组件架构的任务时触发。包含 React 19 API 变更。

License 许可
MIT
所属仓库
gambitph/Cimo
最近更新
2026-10-15
Stars
★ 2
Forks
0

01 前言 Front Matter

name
vercel-composition-patterns
license
MIT
metadata
{ "author": "vercel", "version": "1.0.0" }
description
React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.

02 资源文件 13

03 SKILL.md 正文

React Composition Patterns

Composition patterns for building flexible, maintainable React components. Avoid boolean prop proliferation by using compound components, lifting state, and composing internals. These patterns make codebases easier for both humans and AI agents to work with as they scale.

When to Apply

Reference these guidelines when:

  • Refactoring components with many boolean props
  • Building reusable component libraries
  • Designing flexible component APIs
  • Reviewing component architecture
  • Working with compound components or context providers

Rule Categories by Priority

Priority Category Impact Prefix
1 Component Architecture HIGH architecture-
2 State Management MEDIUM state-
3 Implementation Patterns MEDIUM patterns-
4 React 19 APIs MEDIUM react19-

Quick Reference

1. Component Architecture (HIGH)

  • architecture-avoid-boolean-props - Don't add boolean props to customize behavior; use composition
  • architecture-compound-components - Structure complex components with shared context

2. State Management (MEDIUM)

  • state-decouple-implementation - Provider is the only place that knows how state is managed
  • state-context-interface - Define generic interface with state, actions, meta for dependency injection
  • state-lift-state - Move state into provider components for sibling access

3. Implementation Patterns (MEDIUM)

  • patterns-explicit-variants - Create explicit variant components instead of boolean modes
  • patterns-children-over-render-props - Use children for composition instead of renderX props

4. React 19 APIs (MEDIUM)

⚠️ React 19+ only. Skip this section if using React 18 or earlier.

  • react19-no-forwardref - Don't use forwardRef; use use() instead of useContext()

How to Use

Read individual rule files for detailed explanations and code examples:

rules/architecture-avoid-boolean-props.md
rules/state-context-interface.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

gambitph
gambitph/Cimo

智能体技能文档编写

writing-for-agents

为智能体编写文档。在创建或编辑技能(skills),或修改 AGENTS.md 或 CLAUDE.md 时使用。

AI 工程师智能体开发
★ 2
gambitph
gambitph/Cimo

WordPress REST API 开发

wp-rest-api

用于构建、扩展或调试 WordPress REST API 端点/路由:register_rest_route、WP_REST_Controller/控制器类、schema/参数校验、permission_callback/身份验证、响应构造、register_rest_field/register_meta,或通过 show_in_rest 暴露 CPT/分类法。

软件开发工程师内容管理系统开发
★ 2
gambitph
gambitph/Cimo

WordPress 项目诊断

wp-project-triage

当你需要对 WordPress 仓库(插件/主题/区块主题/WP 核心/Gutenberg/完整站点)进行确定性检查,包括工具链/测试/版本提示,并生成结构化 JSON 报告以指导工作流和防护栏时使用。

软件开发工程师内容管理系统开发
★ 2
gambitph
gambitph/Cimo

WordPress插件目录合规审查

wp-plugin-directory-guidelines

审查 WordPress 插件的 GPL 合规性、检查许可证头或兼容性、评估追加销售/免费增值/试用版(upsell/freemium/trialware)模式、验证插件命名或商标规则、检查插件 slug、理解某个插件为何被 WordPress.org 拒绝,或回答有关 18 条 WordPress.org 插件目录指南的任何问题——即使用户没有明确提到『指南』。

质量合规审核员开源许可证合规审计
★ 2
gambitph
gambitph/Cimo

WordPress插件开发

wp-plugin-development

开发 WordPress 插件时使用:架构与钩子、激活/停用/卸载、管理界面与 Settings API、数据存储、定时任务、安全(nonce/权限/清理/转义)以及发布打包。

软件开发工程师内容管理系统开发
★ 2
gambitph
gambitph/Cimo

WordPress 性能剖析与优化

wp-performance

在排查或改进 WordPress 性能时使用(仅限后端代理):性能剖析与测量(WP-CLI profile/doctor、Server-Timing、通过 REST 请求头使用 Query Monitor)、数据库/查询优化、自动加载选项(autoloaded options)、对象缓存、定时任务(cron)、HTTP API 调用,以及安全验证。

软件开发工程师性能剖析与优化
★ 2