vercel-composition-patterns

Refactor React components with boolean props into compound components with provider-based state.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Many React components become hard to maintain when behavior is controlled by many boolean props, leading to exponential state combinations, fragile conditionals, and duplicated logic. This Skill provides a structured approach to replace boolean-driven configuration with explicit, composable variants and provider-backed state so components stay predictable and reusable.

Core Features & Use Cases

  • Compound Components: Design components as composable pieces that share a generic context, enabling consumers to assemble only what they need.
  • Provider-based State: Lift state into providers with a clear interface of state, actions, and meta so UI parts remain implementation-agnostic and reusable.
  • Explicit Variants & Composition: Create named variant components (e.g., ThreadComposer, EditComposer) and prefer children composition over render props for clarity and flexibility.
  • React 19 API Guidance: Recommendations for React 19 patterns, including using use() for context and treating ref as a regular prop when appropriate.
  • Use Case: Refactor a Composer component that uses multiple boolean flags into explicit provider-backed variants and produce before/after examples for code review.

Quick Start

Use the vercel-composition-patterns skill to refactor a component that relies on boolean props into compound components with a provider-based state interface and provide concise before-and-after examples.

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?

Lift state into context providers with a clear interface of state, actions, and meta. This keeps UI parts implementation-agnostic, allowing compound components to share a generic context and assemble only what they need.

What is the best way to use compound components for state management?

Lift state into context providers with a clear interface of state, actions, and meta. This keeps UI parts implementation-agnostic, allowing compound components to share state and consumers to assemble only what they need.

Does this composition pattern work with React 19 API updates?

Yes, the composition pattern supports React 19 API updates. It recommends replacing useContext with the use hook and treating ref as a regular prop when appropriate to align with React 19 component architecture.

Why should I use explicit variants instead of render props in React?

Explicit variants create named component instances like ThreadComposer or EditComposer, replacing boolean flags. Preferring children-based composition over render props provides better clarity and flexibility for component architecture.

When do I need to replace boolean flags with composable variants?

Replace boolean flags when components suffer from exponential state combinations, fragile conditionals, and duplicated logic. This happens when behavior is controlled by many boolean props, making React components hard to maintain and reuse.