Agent Skill
React composition patterns (Vercel)
Vercel's rules for refactoring React components away from boolean-prop sprawl toward compound components, explicit variants and the React 19 APIs.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkInstall
Commands are pinned to commit 1a2c79d, the version we read, wherever the install method supports it.
npx skills
npx skills add vercel-labs/agent-skills@1a2c79d4e6c4a2283dc2c614b6538cbe1ed5ca62 --skill vercel-composition-patterns -a claude-codeCopies the skill into .claude/skills/ in this project, pinned to the reviewed commit.
npx skills
npx skills add vercel-labs/agent-skills@1a2c79d4e6c4a2283dc2c614b6538cbe1ed5ca62 --skill vercel-composition-patterns -a codexInstalls to .agents/skills/, which Codex scans from the working directory up to the repo root.
npx skills
npx skills add vercel-labs/agent-skills@1a2c79d4e6c4a2283dc2c614b6538cbe1ed5ca62 --skill vercel-composition-patterns -a cursorInstalls to .agents/skills/, one of the folders Cursor reads skills from.
gh skill
gh skill install vercel-labs/agent-skills skills/composition-patterns --pin 1a2c79d4e6c4a2283dc2c614b6538cbe1ed5ca62 --agent github-copilotNeeds GitHub CLI 2.90.0 or later. Use --scope user to install for every repository.
npx skills
npx skills add vercel-labs/agent-skills@1a2c79d4e6c4a2283dc2c614b6538cbe1ed5ca62 --skill vercel-composition-patternsPinned to the commit we reviewed. The CLI asks which agents to install for; add -g to install for your user instead of this project.
What it does
A rule set for component architecture in React, packaged the same way as Vercel’s React performance rules. The SKILL.md is an index of rules by priority, and each rule lives in its own file in rules/ with a bad and a good example. The high-priority category is architecture: stop adding boolean props for every variant and use compound components instead. Medium-priority rules cover state (a context interface with state, actions and meta), implementation patterns (children over render props, explicit variant components) and React 19 changes, such as dropping forwardRef now that ref is a regular prop. An AGENTS.md in the folder compiles every rule into one document for agents that prefer a single file.
When to use it
Refactoring a component that has grown props like isCompact, showHeader, hideFooter and variant, designing a component library’s public API, or moving a codebase to React 19 idioms.
When to skip it
Performance problems such as re-renders, waterfalls and bundle size: use Vercel React best practices instead. Very small apps also do not need compound components; a couple of props is fine.
Try it
Refactor components/Modal.tsx using the composition patterns skill. It has
nine boolean props. Propose a compound component API first, show a before
and after usage example, then migrate the three call sites.
What it can touch
- Bundles scripts
- No
- Pre-approved tools
- None declared
- Needs
- Nothing beyond the agent
- Client-specific fields
- None, spec fields only
Its instructions steer what your agent does, and it may have changed since the commit we read. How to check a skill.
Instructions and Markdown rule files only. It edits your components when asked. No scripts, no allowed-tools. The folder is named composition-patterns while the skill’s name is vercel-composition-patterns; the spec says they should match, and some clients will warn.
At commit 1a2c79d the SKILL.md is 89 lines long. Alongside it:
rules/(10 entries)AGENTS.mdmetadata.jsonREADME.md
Alternatives
shadcn when your components come from shadcn/ui, and web design guidelines for reviewing the interface itself rather than its code structure.
SKILL.md
The file exactly as published at the reviewed commit, reproduced under its MIT licence.
---
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
| 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 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`Related skills
React best practices (Vercel)
Vercel's React and Next.js performance rules as a skill, ranked by impact: waterfalls, bundle size, server performance, data fetching and re-renders.
shadcn/ui
Official shadcn/ui skill: adds, searches, fixes and styles components using the CLI and your components.json, with rules for forms, icons and composition.
Web design guidelines (Vercel)
Reviews UI files against Vercel's Web Interface Guidelines, which the agent downloads fresh from GitHub before each review. Reports file:line findings.
Guides and recipes that use React composition patterns (Vercel)
- Cursor skills: folders, /create-skill and Cloud Agents
Which folders Cursor reads skills from, how to attach a skill to a message or Custom Mode, the built-in /create-skill, and which skills reach Cloud Agents.
- Skill recipe: your design system
A worked skill that teaches coding agents your tokens, components and do and don't rules, with detail in reference files so it loads only when needed.
- Skill recipe: a framework migration
A worked Agent Skill recipe for framework and API upgrades: codemods, before/after replacements, banned legacy patterns and verification checks.