composition-patterns

Installation
SKILL.md

Composition Patterns

Part of Agent Skills™ by googleadsagent.ai™

Description

Composition Patterns teaches agents to build flexible, maintainable React components using compound components, state lifting, internal composition, and the elimination of boolean prop proliferation. These patterns replace rigid, prop-heavy APIs with composable interfaces that scale gracefully as requirements evolve.

The most common agent mistake in React is building monolithic components with dozens of boolean props: showHeader, showFooter, isCompact, isLoading, hasSearch, enableDarkMode. Each boolean doubles the component's state space, creating an exponential testing surface and making the component impossible to extend without modifying its internals. Composition patterns replace these booleans with structural composition, where the consumer assembles the component from smaller pieces.

This skill addresses four complementary patterns: compound components for related UI families, state lifting for shared cross-component state, internal composition for encapsulated sub-rendering, and render delegation for maximum consumer flexibility. Applied together, these patterns produce components that are simple to use, powerful to customize, and trivial to test.

Use When

  • A component has more than 3 boolean configuration props
  • Related components need to share implicit state (tabs, accordions, selects)
  • The consumer needs to control layout or ordering of sub-elements
  • A component needs to support use cases not anticipated at design time
  • Refactoring a "god component" into composable pieces
Related skills
Installs
9
GitHub Stars
8
First Seen
Apr 12, 2026