vercel-composition-patterns

React Composition Patterns

React Composition Patterns is Vercel's agent skill for React component APIs: compound components, lifted state and explicit variants instead of a growing list of boolean props.

Checked by CookiesForAI on : license and last change of the skill re-read from GitHub.

Written by

Install React Composition Patterns

Install this skill with the skills CLI

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

Or install every Vercel skill at once

Terminal
npx skills add vercel-labs/agent-skills

Or paste this into your coding agent: Install the agent skill vercel-composition-patterns from github.com/vercel-labs/agent-skills. Checked by CookiesForAI on : license and last change of the skill re-read from GitHub. A skill can include scripts that run on your computer, so read its source first.

What React Composition Patterns does

React Composition Patterns is Vercel's guide to building React components that stay flexible as a codebase grows. It loads when an agent refactors components that have piled up boolean props, builds a reusable component library, designs a component API, or works with compound components, render props or context providers. The guide says these patterns make a codebase easier for both people and AI agents to work with.

React Composition Patterns holds eight rules in four groups, ordered by impact. Component architecture comes first: replace boolean props with composition, and structure complex components as compound components that share context. The state rules keep the provider as the only place that knows how state is managed, define a generic context interface with state, actions and meta, and lift state into providers so sibling components can reach it.

Two implementation rules in React Composition Patterns prefer explicit variant components over boolean modes, and children over renderX props. A React 19 rule, skipped on React 18 or earlier, treats ref as a regular prop instead of wrapping components in forwardRef, and reads context with use() instead of useContext(). Each rule file shows incorrect and correct code, and AGENTS.md compiles every rule into one document.

When to use React Composition Patterns

  • You have a component with so many boolean props that every new case adds another flag.
  • You are building a component library and want APIs other developers can compose.
  • You are moving a codebase to React 19 and want forwardRef and useContext replaced.
  • You want an agent to review your component architecture before it grows further.

When to pick something else

  • Your problem is speed, such as request waterfalls or bundle size: use React Best Practices.

Which agents React Composition Patterns works in

Vercel documents React Composition Patterns for any AI coding agent that reads Agent Skills, installed with the skills CLI. The open skills CLI also installs it into 78 agents, including Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode (we listed it with the CLI on ). See where each agent looks for skills.

We also list this company's other pages: Vercel product page and Vercel MCP server.

React Composition Patterns license

React Composition Patterns is published under MIT. The SKILL.md frontmatter says license: MIT. The vercel-labs/agent-skills repository has no LICENSE file and GitHub reports no license; its README ends with "License: MIT" (checked ). MIT lets you use, change and share the skill if you keep the copyright notice.

More from Vercel

Lists that include vercel-composition-patterns