composition-patterns

Optimize your codebase with reusable, decoupled React components.

14|2|Updated Jan 28, 2026
One-click install
npx skills add https://github.com/excatt/superclaude-plusplus --skill composition-patterns-excatt
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: composition-patterns
Source: https://github.com/excatt/superclaude-plusplus/tree/main/skills/composition-patterns
Command: npx skills add https://github.com/excatt/superclaude-plusplus --skill composition-patterns-excatt

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers avoid common pitfalls in React component design, such as excessive boolean props and tightly coupled state, leading to more maintainable and extensible codebases.

Core Features & Use Cases

  • Compound Components: Structure complex components using shared context for better organization.
  • State Separation: Decouple state management logic from UI components for cleaner architecture.
  • Explicit Variants: Replace boolean props with dedicated component variants for clarity.
  • Use Case: Refactor a large UserProfileCard component that uses many boolean flags (e.g., showAvatar, showBio, isEditable) into a compound component structure with distinct parts like UserProfileCard.Header, UserProfileCard.Body, and UserProfileCard.EditButton.

Quick Start

Refactor the Composer component to use compound patterns instead of boolean props.

Frequently Asked Questions about composition-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor React components to stop using boolean props for UI variations?

Refactor React components away from boolean props by implementing explicit component variants and compound components. This approach replaces complex boolean flags with distinct structural parts to create clearer and more maintainable component architectures.

What are compound components in React and when should I use them?

Compound components in React structure complex UIs by sharing context across separate sub-components. Use them to organize unwieldy components into distinct parts, enabling better state separation and flexible rendering without excessive boolean prop configurations.

How do I decouple state management logic from my React UI components?

Decouple state management from React UI components by lifting state and separating logic from rendering. This pattern ensures cleaner architecture by preventing tightly coupled state, making components more maintainable and extensible.

What is the best way to build a flexible React component library?

Build a flexible React component library using composition patterns like compound components and explicit variants. This method addresses state coupling and boolean prop abuse, yielding reusable structures that support diverse implementation needs.

Can I use composition patterns to break down a large React component with many flags?

Yes, you can use composition patterns to break down large React components. Refactor components with many flags into compound structures with distinct parts, replacing tightly coupled state and boolean props with organized, manageable sub-components.