vercel-composition-patterns

Refactor React components to replace boolean props with compound components and context contracts.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the maintainability collapse that happens when React components grow too many boolean props and hidden conditional branches, making APIs hard to reason about and refactor.

Core Features & Use Cases

  • Compound component architecture: Use Providers plus composed subcomponents (Frame/Input/Footer/Submit-style parts) so internals are shared via context instead of prop drilling.
  • Lifted state with dependency-injected context: Centralize state management in a provider boundary and expose a generic contract (state/actions/meta) that multiple providers can implement.
  • Explicit variants over boolean modes: Replace prop-driven “modes” with dedicated components (e.g., ThreadComposer, EditComposer) to eliminate impossible/undefined UI combinations.
  • React 19-focused correctness: Use React 19 guidance by treating ref as a normal prop and preferring use() over useContext().

Quick Start

Ask an AI to refactor your current React component by removing boolean props, introducing a compound component structure with lifted provider state, and splitting each boolean mode into explicit variant components.

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 with too many boolean props?

To refactor React components with too many boolean props, replace conditional rendering logic with explicit variant components like ThreadComposer or EditComposer, and share internal state via context providers instead of prop drilling to create a scalable composition structure.

What is the compound component pattern in React?

The compound component pattern in React uses a Provider boundary plus composed subcomponents like Frame, Input, and Footer so internals are shared via context, eliminating prop drilling and preventing impossible UI combinations caused by boolean mode flags.

How do I lift state with dependency-injected context in React?

To lift state with dependency-injected context in React, centralize state management in a provider boundary and expose a generic contract interface containing state, actions, and meta that multiple providers can implement for flexible UI composition.

Does this React composition pattern work with React 19?

Yes, this React composition pattern works with React 19 by applying specific API guidance such as treating ref as a regular prop and preferring the use() hook over useContext() for accessing context values within your compound component trees.

Why should I use explicit variant components instead of boolean props?

You should use explicit variant components instead of boolean props to eliminate impossible and undefined UI combinations, which solves the maintainability collapse that occurs when React components grow hidden conditional branches that are hard to reason about.