Skip to content
React Composition Patterns

React Composition Patterns Skill

Vercel's official skill for React component architecture — replace boolean prop proliferation with compound components, lifted state and explicit variants. Includes React 19 APIs.

GitHub Docs

Install

Install with the skills CLI

One command for Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf and dozens of other agents. Needs Node.js; the skill is fetched straight from vercel-labs/agent-skills.

$ npx skills add vercel-labs/agent-skills --skill vercel-composition-patterns

Run it in a terminal. The CLI finds the agents installed on your machine, asks which ones to add the skill to, and whether to install it into the folder you ran it from or for all your projects.

Other ways to install

Copy the whole skill folder — SKILL.md and any scripts or references beside it — into ~/.claude/skills/vercel-composition-patterns/, where Claude Code picks it up in every project. Only git is needed.

tmp=$(mktemp -d) && \
  git clone --depth 1 --branch main https://github.com/vercel-labs/agent-skills.git "$tmp" && \
  mkdir -p ~/.claude/skills && \
  cp -R "$tmp"/skills/composition-patterns ~/.claude/skills/vercel-composition-patterns

No scripts or references next to it? Saving the SKILL.md alone as ~/.claude/skills/vercel-composition-patterns/SKILL.md works too.

Using another agent? Its personal skills folder
Codex
~/.agents/skills/
Cursor
~/.cursor/skills/
GitHub Copilot
~/.copilot/skills/
Gemini CLI
~/.gemini/skills/
Windsurf
~/.codeium/windsurf/skills/
OpenCode
~/.config/opencode/skills/

About

  • Rules ordered by impact across four categories
  • Compound components and context-sharing architecture
  • Replaces boolean prop proliferation with explicit variants
  • Provider-owned state and generic context interfaces
  • children over render props
  • React 19 guidance: no forwardRef, use() over useContext()
  • Per-rule reference files with correct and incorrect examples

React Composition Patterns is an official Vercel agent skill for the problem every component library eventually has: a component that started with two props and now takes eleven booleans, each one branching its render.

The skill organises its rules into four priority-ordered categories.

Component architecture (high impact). Do not add boolean props to customise behaviour — compose instead. Structure complex components as compound components sharing context, so consumers assemble the parts they need rather than toggling flags.

State management. Keep the provider as the only place that knows how state is managed, define a generic state/actions/meta context interface so implementations can be swapped by dependency injection, and lift state into provider components where siblings need to read it.

Implementation patterns. Prefer explicit variant components over boolean modes, and children over renderX render props.

React 19 APIs. A clearly gated section — skipped on React 18 and earlier — covering the removal of forwardRef and using use() in place of useContext().

Each rule carries a stable identifier such as architecture-avoid-boolean-props or state-context-interface, and expands to its own reference file with an explanation of why it matters, an incorrect example, a corrected example, and further context. A compiled AGENTS.md holds the whole guide for agents that prefer one document.

Who it is for. Engineers building design systems and shared component libraries, and anyone refactoring a component whose prop list has outgrown it. Vercel's stated rationale is that these patterns keep a codebase tractable for AI agents as well as for people — a component whose behaviour is visible in its composition is easier for a model to modify correctly than one hiding behaviour behind flags.

MIT-licensed, part of vercel-labs/agent-skills, installable with npx skills add vercel-labs/agent-skills.

SKILL.md

The instructions your agent loads, as published by Vercel.

SKILL.md
name
vercel-composition-patterns
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.
license
MIT
metadata
author: vercel version: '1.0.0'

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
PriorityCategoryImpactPrefix
1Component ArchitectureHIGHarchitecture-
2State ManagementMEDIUMstate-
3Implementation PatternsMEDIUMpatterns-
4React 19 APIsMEDIUMreact19-
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

Install
New

Addy Osmani's skill for building production-quality, accessible, responsive interfaces: component architecture, the simplest workable state, design-system adherence, a list of AI-aesthetic defaults to avoid, WCAG 2.1 AA and a verification checklist.

The official shadcn/ui skill: project-aware rules and CLI workflows for adding, composing, styling and updating shadcn components, applying presets, and turning a DESIGN.md into a themed design system.

Browse all skills →