AGENT SKILL

composition-patterns

Use when refactoring React components that mix state and UI concerns, accumulate boolean-mode props, or rely on render-prop-heavy APIs. Emphasizes compound components, explicit variants, provider-based state, and children-first composition.

License 许可
MIT
最近更新
2026-07-24
Stars
★ 0
Forks
0

01 前言 Front Matter

name
composition-patterns
source
https://github.com/vercel-labs/agent-skills/tree/main/skills/composition-patterns
license
MIT
description
Use when refactoring React components that mix state and UI concerns, accumulate boolean-mode props, or rely on render-prop-heavy APIs. Emphasizes compound components, explicit variants, provider-based state, and children-first composition.

02 资源文件 3

03 SKILL.md 正文

React Composition Patterns

Use this skill when a React component has started accumulating mode booleans, nested conditionals, duplicated state transitions, or tightly coupled UI and state logic.

Apply When

  • Refactoring components with boolean prop proliferation
  • Splitting state management from presentation logic
  • Building compound components backed by shared context
  • Creating explicit component variants instead of hidden modes
  • Replacing render-prop structure with children-based composition

Core Rules

  1. Avoid boolean prop proliferation.
  2. Prefer compound components for flexible composed UIs.
  3. Decouple state management from UI components.
  4. Define a stable context contract in terms of state, actions, and meta.
  5. Lift shared state into providers when siblings also need access.
  6. Prefer explicit variants over one component with many modes.
  7. Prefer composing children over render props for static structure.

React Version Note

The upstream skill includes React 19 guidance. This workspace is on React 18, so do not apply React 19-only advice like replacing forwardRef with plain ref props or using use() in place of useContext().

Usage

Read AGENTS.md for the expanded guidance. Use this skill as an architectural review aid, not as a mandate to over-abstract simple components.

04 同仓库更多 Skills

mistervaibhav
mistervaibhav/skills

webapp-testing

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

★ 0
mistervaibhav
mistervaibhav/skills

web-typography

Select, pair, and implement typefaces for web projects. Use when the user mentions "font pairing", "which typeface", "line height", "responsive typography", "web font loading", or "type hierarchy". Covers readability evaluation, CSS implementation, and performance optimization. For overall UI design systems, see refactoring-ui. For dramatic typographic experiences, see top-design.

★ 0
mistervaibhav
mistervaibhav/skills

web-haptics

Add haptic feedback to web apps using the web-haptics library. Use when building mobile-facing UIs that need tactile feedback on buttons, toggles, forms, pickers, and other interactive elements.

★ 0
mistervaibhav
mistervaibhav/skills

visual-novel

Build a visual novel: a branching script, character and background display, a text box with choices, save/load, backlog, and skip/auto. Use for a VN, dating sim, or branching story game.

★ 0
mistervaibhav
mistervaibhav/skills

ux-heuristics

Evaluate and improve interface usability using heuristic analysis. Use when the user mentions "usability audit", "UX review", "users are confused", "heuristic evaluation", "form usability", or "navigation problems". Covers Nielsen's 10 heuristics, severity ratings, and information architecture. For visual design fixes, see refactoring-ui. For conversion-focused audits, see cro-methodology.

★ 0
mistervaibhav
mistervaibhav/skills

unreal-packaging

Package and ship an Unreal Engine 5 project: the Platforms menu Package Project flow, build configurations (Development vs Shipping), cooking content, packaging settings and the Game Default Map, and command-line builds with RunUAT BuildCookRun. Use when packaging a build, making a shipping build, cooking content, configuring packaging settings, or when the user mentions package Unreal, cook content, shipping build, or BuildCookRun.

★ 0