vercel-composition-patterns

Refactor React 19+ components from boolean props to compound component patterns.

46.2k|5.7k|Updated Mar 29, 2026
One-click install
npx skills add https://github.com/calesthio/OpenMontage --skill vercel-composition-patterns-calesthio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/calesthio/OpenMontage/tree/main/.agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/calesthio/OpenMontage --skill vercel-composition-patterns-calesthio

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Many React codebases accumulate boolean props that create combinatorial complexity, fragile conditionals, and unmaintainable component variants. This Skill provides concrete composition patterns—compound components, provider boundaries, generic context interfaces, and explicit variants—to simplify APIs, improve testability, and make components easier for engineers and AI agents to generate and refactor.

Core Features & Use Cases

  • Composition patterns: Use compound components and children composition to eliminate boolean-driven conditional logic.
  • State & dependency injection: Lift state into providers and define a generic state/actions/meta interface so the same UI works with different implementations.
  • Explicit variants & readability: Replace boolean-mode components with explicit variants (e.g., ThreadComposer, EditComposer) for self-documenting code.
  • React 19 guidance: Advise on React 19 API changes (use() over useContext, ref as a prop) for modern codebases.
  • Use cases: Refactoring legacy Composer-like components, building reusable component libraries, performing code reviews, or guiding agent-driven code generation.

Quick Start

Apply vercel-composition-patterns to refactor a Composer component that uses multiple boolean flags into an explicit Provider with Composer.Frame, Composer.Input, and Composer.Footer subcomponents.

Frequently Asked Questions about vercel-composition-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor React components to remove boolean props and reduce conditional complexity?

The best way to replace boolean-driven React components is using compound component patterns. By defining explicit variants and lifting state into providers, you eliminate fragile conditionals and create APIs that are easier to test and refactor.

What is the compound component pattern in React and when should I use it?

The compound component pattern in React uses composable subcomponents to share implicit state without boolean props. Use it when multiple boolean flags create combinatorial complexity and make your component APIs brittle.

How do I lift state into a provider and define a generic context interface for React components?

Lift state into a provider by defining generic state, actions, and meta context interfaces. This dependency injection pattern allows the same UI composition to work with different implementations, improving component testability and flexibility.

Does this React refactoring approach support React 19 API changes for refs and context?

Yes, this refactoring approach supports React 19 by advising on modern API changes. It guides using the use() hook over useContext and passing ref as a prop instead of using forwardRef for modern codebases.

When should I use explicit variants instead of render props in React component libraries?

Use explicit variants instead of render props when you need self-documenting code. Replacing boolean-mode components with explicit variants like ThreadComposer and EditComposer simplifies component APIs and prevents combinatorial complexity.