vercel-composition-patterns — Claude Code skill: React composition
A rule set that pushes your agent away from boolean props and toward compound components, shared context and state lifted into providers.
npx skills add vercel-labs/agent-skills --skill vercel-composition-patterns -a claude-code
npx skills add vercel-labs/agent-skills --skill composition-patterns -a claude-codeWhat vercel-composition-patterns does
The skill hands the agent four categories of rules for React component work, ordered by priority and tagged with prefixes: architecture-, state-, patterns-, react19-. Architecture comes first because boolean prop proliferation is what usually starts the mess.
Each rule is its own file under rules/ — rules/architecture-avoid-boolean-props.md, rules/state-context-interface.md and so on. A file shows the wrong version, explains the damage, then shows the fixed one. A compiled AGENTS.md carries the whole guide, which is the easier thing to pass to an agent that would rather read one document than open every rule separately.
The react19- category is React 19 and up only: it drops forwardRef and swaps useContext() for use(). Skip it on React 18. Worth installing once components have grown flags like isCompact, withHeader and hideFooter and the API keeps getting patched for each new case. A project with a couple of static forms can do without it.
What it helps with
- break a component with too many boolean props into compound parts
- build a compound
SelectorModalon shared context - lift state into a provider so sibling components read it
- replace render props with children in an existing API
- drop
forwardRefafter the move to React 19
Example prompts for the agent
- Refactor `Modal` — it has seven boolean props now, split it into compound components
- Audit `src/components/ui` and remove `forwardRef`, we're on React 19
- Design the `Tabs` API so state lives in the provider
How to install vercel-composition-patterns
1Skills CLI (Vercel)
npx skills add vercel-labs/agent-skills --skill vercel-composition-patterns -a claude-codenpx skills add vercel-labs/agent-skills --skill composition-patterns -a claude-code2Manually: put the files in place
~/.claude/skills/composition-patterns/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/composition-patterns/
1Skills CLI (Vercel)
npx skills add vercel-labs/agent-skills --skill composition-patterns -a codex2Manually: put the files in place
.agents/skills/composition-patterns/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add vercel-labs/agent-skills --skill composition-patterns -a cursor2Manually: put the files in place
.cursor/skills/composition-patterns/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install vercel-labs/agent-skills composition-patterns2Manually: put the files in place
.github/skills/composition-patterns/SKILL.md1Skills CLI (Vercel)
npx skills add vercel-labs/agent-skills --skill composition-patterns -a gemini-cli2Platform CLI
gemini skills install https://github.com/vercel-labs/agent-skills --path skills/composition-patternsManually: put the files in place
.devin/skills/composition-patterns/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add vercel-labs/agent-skills --skill composition-patterns -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
From the same set6
The whole set →Similar
Questions about vercel-composition-patterns
How do I install vercel-composition-patterns in Claude Code?
Run npx skills add vercel-labs/agent-skills --skill composition-patterns -a claude-code. The skill lands at ~/.claude/skills/composition-patterns/SKILL.md; swap the -a value for codex, cursor, gemini-cli or opencode.
What does vercel-composition-patterns do?
It gives the agent rules for React component architecture: avoiding boolean props, building compound components on shared context, keeping state in providers, using explicit variants instead of mode flags.
Does it need React 19?
Only the react19- category does, with the rules on forwardRef and use(). The other three categories apply to earlier React versions as well.
Source text
SKILL.md · MIT
--- 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`
© vercel · MIT · vercel-labs/agent-skills