vercel-composition-patterns

Refactor React components to replace boolean props with composition and context providers.

Updated Feb 7, 2026
One-click install
npx skills add https://github.com/chathuraed/existing_project --skill vercel-composition-patterns-chathuraed
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/chathuraed/existing_project/tree/main/.agents/skills/vercel-composition-patterns
Command: npx skills add https://github.com/chathuraed/existing_project --skill vercel-composition-patterns-chathuraed

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a set of guidelines and patterns to scale React component libraries by avoiding boolean prop proliferation and embracing composition, compound components, and context providers.

Core Features & Use Cases

  • Explicit variant components: Create components like ThreadComposer, EditMessageComposer, and ForwardMessageComposer to replace boolean flags.
  • Compound components with shared context: Use a single provider that wires UI pieces via context to avoid prop drilling.
  • State decoupling and provider-driven UI: UI components consume a generic context interface while state management lives inside providers; supports multiple state implementations.
  • Migration and design-system guidance: Offers a path to refactor existing code into modular, reusable APIs for React 18+.

Quick Start

Refactor a complex React component by creating explicit variant components (e.g., ThreadComposer, EditMessageComposer, ForwardMessageComposer) and wiring them with a shared provider to replace boolean flags.

Frequently Asked Questions about vercel-composition-patterns

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

FAQPage Schema
How do I avoid boolean prop proliferation in React components?

To avoid boolean prop proliferation in React components, refactor them into explicit variant components and compound components wired with shared context providers. This replaces complex boolean flags with modular, reusable APIs.

What is the best way to build a React component library with explicit variants?

The best way to build a React component library with explicit variants is to create distinct components like ThreadComposer and EditMessageComposer. These explicit variants replace boolean flags and utilize a shared provider to wire UI pieces.

How does provider-based architecture decouple state in React UI components?

Provider-based architecture decouples state in React UI components by having UI components consume a generic context interface while state management lives inside providers. This separation supports multiple state implementations.

Can I use React 19 use() hook instead of useContext for composition patterns?

Yes, you can use the React 19 use() hook instead of useContext for composition patterns. The architecture enforces provider-based design with generic context interfaces and provides guidance for React 19 API usage, including refs as regular props.

How do I refactor an existing React UI to use compound components?

To refactor an existing React UI to use compound components, replace boolean flags with explicit variant components wired by a single shared context provider. This migration path avoids prop drilling and creates modular APIs for React 18+.

When should I not replace boolean flags with explicit variant components?

You should not replace boolean flags with explicit variant components when the UI variations are minimal and do not justify the overhead of a provider-based architecture. Compound components are best for scaling complex component libraries with multiple state implementations.