AGENT SKILL

composition-patterns

React component composition patterns for flexible, maintainable component APIs, from Vercel Engineering. Use when refactoring a component that has grown many boolean props, building or reviewing a shared component library or design-system wrapper, choosing between compound components, context providers, render props or explicit variants, or moving to React 19 APIs. Applies to React code only, even if the user does not say "composition". For render-and-look design review use ux-review; for performance rules use react-best-practices.

License 许可
MIT
最近更新
2026-11-14
Stars
★ 0
Forks
0

01 前言 Front Matter

name
composition-patterns
license
MIT
metadata
{ "author": "vercel", "upstream": "https://github.com/vercel-labs/agent-skills/tree/main/skills/composition-patterns" }
description
React component composition patterns for flexible, maintainable component APIs, from Vercel Engineering. Use when refactoring a component that has grown many boolean props, building or reviewing a shared component library or design-system wrapper, choosing between compound components, context providers, render props or explicit variants, or moving to React 19 APIs. Applies to React code only, even if the user does not say "composition". For render-and-look design review use ux-review; for performance rules use react-best-practices.

02 资源文件 10

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 the rule files that match the task. Open only the rules that match the task:

${CLAUDE_SKILL_DIR}/rules/architecture-avoid-boolean-props.md
${CLAUDE_SKILL_DIR}/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

04 同仓库更多 Skills

DaisyGuti
DaisyGuti/claude-pack

web-design-guidelines

Reviews UI source code against Vercel's Web Interface Guidelines, fetched fresh at review time - accessibility attributes, focus states, forms, animation, typography, images, performance, navigation and URL state, touch, dark mode, i18n, hydration safety and common anti-patterns. Use when asked to review, audit or lint the code of a component, page or stylesheet for UI quality, "check my UI against best practices", "review this form", or "audit this markup", even if the user does not name the guidelines. Reads files and reports findings as file:line. Not for judging a screenshot or a running page (use ux-review), not for a WCAG conformance audit of a live site (use the accessibility plugin), and not for choosing a visual direction (use frontend-design).

★ 0
DaisyGuti
DaisyGuti/claude-pack

ux-review

Judges an existing design for usability, accessibility and visual craft, and says what to change. Use when asked to review or critique a UI, screenshot, mockup, prototype, flow or component, to "roast" or grade a design, to explain why a page looks generic or AI-made, to check contrast, keyboard or reading-order risks from a design, or to answer whether a screen works for its user. Gives a readiness verdict and a ranked list of fixes with concrete values (label text, px size, hex). Judges what is shown; it does not build new UI (use frontend-design), review framework source line by line (use web-design-guidelines), or run live-page accessibility tests (use the accessibility plugin). To render the page in a real browser and make the fixes, use the ui-ux agent.

★ 0
DaisyGuti
DaisyGuti/claude-pack

react-native-skills

React Native and Expo best practices for building performant mobile apps, from Vercel Engineering. Use when writing or reviewing React Native or Expo components, tuning list and scroll performance, building animations with Reanimated, handling images, safe areas, navigation, fonts or native modules, or structuring a monorepo with native dependencies. Applies to React Native code only, even if the user does not say "mobile". For web React performance use react-best-practices.

★ 0
DaisyGuti
DaisyGuti/claude-pack

react-best-practices

React and Next.js performance rules from Vercel Engineering, ranked by impact. Use when writing, reviewing or refactoring React or Next.js code for speed - data-fetching waterfalls, bundle size, server components, re-renders, hydration, rendering cost - or when a page feels slow, a bundle is large or a component re-renders too often. Applies to React and Next.js code only, even if the user does not say "performance". For visual or usability review use ux-review; for component API design use composition-patterns.

★ 0
DaisyGuti
DaisyGuti/claude-pack

eng

Slash entry for the engineering agent. Use when the user types /core:eng, or asks to "use eng", "run the engineering pass" or "have engineering do" a fix, feature, refactor or code review in the current repo, even if they do not name the agent. Hands the task to the core:eng agent in a fresh context and returns its report.

★ 0