vercel-composition-patterns

Refactor React component APIs into composable variant and compound component patterns.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/perimetre/ai-toolkit --skill vercel-composition-patterns-perimetre
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-composition-patterns
Source: https://github.com/perimetre/ai-toolkit/tree/main/plugins/perimetre-apps/skills/vercel-composition-patterns
Command: npx skills add https://github.com/perimetre/ai-toolkit --skill vercel-composition-patterns-perimetre

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

React component libraries often suffer from boolean prop proliferation and tightly coupled UI logic, making variants hard to maintain as projects scale.

Core Features & Use Cases

  • Use explicit component variants to replace boolean flags to improve readability and maintainability.
  • Build compound components with shared context to avoid prop drilling and enable flexible composition.
  • Provide dependency-injected state via providers to share UI state across a broader set of components.
  • Adapt to React 19 API changes (use() for context, regular ref props) for modern codebases.

Quick Start

Start by introducing explicit variant components (ThreadComposer, EditMessageComposer, ForwardMessageComposer) inside a shared Provider to begin composing UI with predictable state management.

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 avoid boolean prop proliferation?

Refactor React components by replacing boolean flags with explicit variant components like ThreadComposer or EditMessageComposer. This pattern improves readability and maintainability by decoupling tightly coupled UI logic as projects scale.

What is the compound components pattern in React and how does shared context work?

The compound components pattern in React groups related components together using shared context to manage state. This avoids prop drilling and enables flexible composition, allowing individual components to access shared data without explicit boolean prop passing.

How do I use the React 19 use() hook for context in provider-based state management?

React 19 introduces the use() hook for reading context directly in provider-based state management. This modern API replaces older context consumption methods, enabling dependency-injected state to be shared across UI components with regular ref props.

Does this React composition pattern work for building reusable UI library APIs?

Yes, this composition pattern is designed for building reusable UI library APIs. By enforcing explicit variants and provider-based state management, it audits frontend architecture and solves the complexity of scaling component libraries across React apps.

When should I not use boolean props for React component variants?

You should avoid boolean props for React component variants when your UI library scales and variants become hard to maintain. Boolean flags create tightly coupled logic, so switching to explicit variant components inside a shared Provider solves this complexity.