React composition patterns
Applies eight Vercel rules that replace boolean props with compound components, provider-held state and explicit variants, plus React 19 ref and use() changes. Use when a component has too many flags or when designing a component library.
composition-patterns- Author
- Vercel
- Source
- vercel-labs/agent-skills/skills/composition-patterns @ 1a2c79d
- License
- MIT
About this skill
What it does
The skill targets one recurring problem in React code: a component that grows a boolean prop for every case until nobody knows which combinations work. Its eight rules replace configuration with composition.
Component architecture is rated highest: no boolean props to change behaviour, and complex components built as compound components sharing a context. State management: only the provider knows how state is stored; the context exposes a generic interface of state, actions and meta, so the same UI can run on different state implementations; state is lifted into the provider so siblings can reach it. Two implementation patterns: explicit variant components instead of modes (the README's example is ThreadComposer and EditComposer rather than Composer with isThread), and children instead of renderX props. The last section is React 19 only, skipped on React 18: ref as a plain prop instead of forwardRef, and use() instead of useContext().
SKILL.md is the index. Each rule has a file in rules/ with the reason and a wrong and a right example; AGENTS.md (about 22 KB) holds them all.
When to use it, and when not
Use it when a component has collected flags like isEditing or showActions, when you build a component library or design system, and in architecture reviews.
It says nothing about styling, accessibility or performance. A component with one or two props does not need compound parts and a provider; the rules pay off once there are real variants.
How to run it
We do not copy this skill: its frontmatter says MIT, but the repository ships no licence text to put beside a copy. Install it from Vercel's repository with the button to the source; its README uses the skills.sh installer, npx skills add vercel-labs/agent-skills, and --skill vercel-composition-patterns limits it to this one. The skill's name is vercel-composition-patterns:
- Claude Code:
/vercel-composition-patterns, or ask for the skill by name. - Codex:
$vercel-composition-patterns. - Cursor: type
/in the Agent chat and pickvercel-composition-patterns.
Example: /vercel-composition-patterns Our Modal has nine boolean props. Propose a compound component API and migrate the three call sites.
How it differs from similar skills
Frontend UI engineering states the same principle in one line among rules on state, design and accessibility; this skill works it out in code. Deep module design covers module interfaces in any language, not React. API and interface design treats props as one contract among many. React Native best practices applies compound components to design-system buttons.
Install
This skill is not copied to the catalog: the author's repository has no licence text. Install it from there.
Connect through AnyModel API
This skill runs on whatever model your agent uses. Point Claude Code, Codex or Cursor at AnyModel to run it on Claude, GPT, Gemini and more with one key — pay per token, no subscription.
AnyModel