vercel-composition-patterns

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It prevents React component designs from becoming unmaintainable when behavior is controlled by many boolean props and hidden conditionals, and it improves long-term scalability for teams and AI-assisted code changes.

Core Features & Use Cases

  • Avoid Boolean Prop Proliferation: Replace combinatorial boolean modes with explicit composition-based variants.
  • Use Compound Components with Context: Build reusable component APIs where subcomponents consume shared state via a provider-backed context contract (state/actions/meta).
  • Lift State into Providers: Enable sibling UI (outside the main component tree) to read and act on shared state without prop drilling or awkward refs.
  • Prefer Children Over Render Props: Use children composition for clearer APIs unless render-prop data needs to be passed back.
  • React 19 API Guidance: Apply React 19+ practices by using use() (instead of useContext()) and treating ref as a regular prop rather than relying on forwardRef.

Quick Start

Use this skill when you are refactoring a React component that currently has many boolean props or complex conditional rendering, and ask the assistant to redesign it using compound components, lifted state providers, and explicit variant components following the included rule categories.

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

Refactor React components by replacing boolean-prop-driven combinatorial complexity with explicit composition-based variants. This approach uses compound component APIs and lifts state into context providers to improve maintainability and scalability.

What is the best way to share state across sibling React components without prop drilling?

Lift state into provider boundaries to share state across sibling React components without prop drilling. Inject state through a generic context interface defining state, actions, and meta contracts, allowing siblings to read and act on shared data.

How do compound components work with context in React 19?

Compound components in React 19 work by building reusable APIs where subcomponents consume shared state via a provider-backed context contract. They use the `use()` hook instead of `useContext()` and treat `ref` as a regular prop rather than relying on `forwardRef`.

Should I use children composition or render props for React component APIs?

Prefer children composition over render props for clearer React component APIs unless you need to pass render-prop data back to the parent. Using children composition reduces complexity and improves the maintainability of your component architecture.

Can I use React 19 ref as a prop without forwardRef?

Yes, React 19+ allows treating `ref` as a regular prop without relying on `forwardRef`. This skill applies React 19+ practices during refactoring, including using `use()` instead of `useContext()` for context consumption.

When should I avoid boolean props in React component design?

Avoid boolean props in React component design when behavior is controlled by many hidden conditionals, causing unmaintainable combinatorial complexity. Redesigning with explicit variants and compound components improves long-term scalability for teams and AI-assisted code changes.