vercel-composition-patterns

Refactor React components with boolean props into explicit compound composition patterns.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps eliminate boolean prop proliferation, tangled conditional rendering, and tightly coupled state in React components by replacing monolithic APIs with explicit composition patterns.

Core Features & Use Cases

  • Compound component design: Break complex UI into reusable parts that share state through context instead of prop drilling.
  • State lifting and dependency injection: Move state into providers so sibling components, previews, and action buttons can access the same data and actions.
  • Explicit variant APIs: Create clear component variants for thread, edit, and forward flows instead of one component with many boolean modes.
  • React 19 guidance: Apply modern ref and context patterns for codebases that need updated React APIs.
  • Use case: Refactor an overloaded composer, dialog, or form into a maintainable set of provider-backed subcomponents with clearer behavior and fewer impossible states.

Quick Start

Refactor the provided React component into explicit compound components with lifted provider state, shared context, and children-based composition.

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 and conditional rendering?

Refactor React components by replacing boolean props and conditional rendering with explicit composition patterns. Break monolithic APIs into compound components that share state through context providers, eliminating impossible states and reducing prop bloat.

What is the best way to manage shared state in compound components without prop drilling?

Manage shared state in compound components by lifting it into context providers. This grants sibling subcomponents, previews, and action buttons direct access to shared data and actions without prop drilling, enforcing clear context contracts.

How do I replace boolean mode flags with explicit variants in React?

Replace boolean mode flags with explicit variants by creating distinct components for thread, edit, and forward flows instead of one component with many modes. This eliminates tangled conditional logic and prevents invalid configuration combinations.

Does this composition pattern approach work with React 19 context and ref APIs?

This approach works with React 19 by applying modern context and ref patterns. It guides codebases through React 19 migration tasks, ensuring compound components and context providers align with updated framework APIs.

When should I use compound components over render props in React?

Use compound components over render props when you need explicit, composable APIs. This pattern favors children-based composition over render props, lifting state into providers to create flexible React APIs without prop bloat.