Catalog
vercel-labs/vercel-composition-patterns

vercel-labs

vercel-composition-patterns

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.

globalMIT
author:vercel
version:1.0.0
0installs0uses~690
v1.1Saved Apr 20, 2026

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

Files13
13 files · 46.3 KB

Select a file to preview

Overall Score

88/100

Grade

A

Excellent

Safety

95

Quality

88

Clarity

86

Completeness

82

Summary

A comprehensive React composition patterns guide that teaches AI agents and developers how to structure scalable React components using compound components, context providers, and state lifting. It addresses boolean prop proliferation, context-based dependency injection, and React 19 API changes through detailed rule files with code examples.

Detected Capabilities

Component architecture guidanceState management patternsContext API instructionReact 19 API migration guidanceCode example provisionPattern anti-pattern comparison

Trigger Keywords

Phrases that MCP clients use to match this skill to user intent.

refactor boolean propscompound componentscontext injectionlift statecomponent architecturereact 19 migrationprovider patternscomponent library design

Risk Signals

INFO

Referenced domain example.com appears in template file

rules/_template.md:18
INFO

react.dev domain referenced for official React documentation

metadata.json:10-12

Referenced Domains

External domains referenced in skill content, detected by static analysis.

example.comreact.dev

Use Cases

  • Refactor components with excessive boolean props
  • Design reusable component libraries
  • Implement compound component patterns
  • Lift state into provider components
  • Review component architecture for scalability
  • Migrate to React 19 APIs

Quality Notes

  • Excellent documentation structure with clear rule files organized by impact priority (HIGH to MEDIUM)
  • Each rule includes before/after code examples with detailed explanations of why patterns matter
  • Strong adherence to agentskills.io specification with proper frontmatter and metadata
  • Comprehensive AGENTS.md compiled guide provides single source of truth for all patterns
  • Clear impact levels (CRITICAL/HIGH/MEDIUM) help agents prioritize which patterns to apply
  • React 19 API changes are explicitly documented with version warnings to prevent misapplication
  • Generic context interface pattern (state/actions/meta) is well-explained and enables dependency injection
  • Patterns are interconnected—each rule references and builds on others coherently
  • Rules include practical context on when each pattern is appropriate vs. when to use alternatives
  • File naming convention with prefixes (architecture-, state-, patterns-, react19-) makes discovery and organization clear
Model: claude-haiku-4-5-20251001Analyzed: Apr 20, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Version History

v1.1

Content updated

2026-04-20

Latest
v1.0

No changelog

2026-04-03

Add vercel-labs/vercel-composition-patterns to your library

Command Palette

Search for a command to run...