New to Claude Skills? Learn how to install them →

calesthio on GitHub

React Composition Patterns

Free

Build flexible and maintainable React components.

Get this skill

Free · Opens the source repo

What React Composition Patterns does

The React Composition Patterns skill provides a comprehensive set of guidelines for creating scalable and maintainable React components. It focuses on avoiding the common pitfalls associated with boolean prop proliferation by advocating for the use of composition techniques such as compound components and lifting state. By following these patterns, developers can enhance the readability and maintainability of their codebases, making them easier for both humans and AI agents to work with as they grow in complexity.

This skill is particularly beneficial for developers who are refactoring existing components that rely heavily on boolean props or for those who are building reusable component libraries. It offers structured approaches to component architecture, state management, and implementation patterns, ensuring that components are designed with flexibility in mind. The skill also includes guidance on adapting to the latest React 19 API changes, which is crucial for developers looking to leverage the newest features in their applications.

The skill is organized into several rule categories, each with varying levels of priority. High-priority rules focus on component architecture, emphasizing the importance of avoiding boolean props and structuring complex components with shared context. Medium-priority rules cover state management and implementation patterns, providing strategies for decoupling state management from component implementation and using explicit variants instead of boolean modes. This structured approach helps developers make informed decisions when designing their components.

In summary, the React Composition Patterns skill is an essential resource for developers and designers aiming to improve their component architecture and state management practices in React applications. By adhering to these guidelines, users can create more robust, reusable, and maintainable components that stand the test of time.

When to use it

Use this skill when refactoring components, building reusable libraries, or designing flexible APIs in React.

When not to use it

This skill is not suitable for projects that do not utilize React or for those using React versions prior to 19.

What you can build with it

Refactoring Boolean Props

When a component has too many boolean props, use this skill to refactor it by implementing compound components instead.

Building a Component Library

When creating a reusable component library, refer to the guidelines to ensure your components are flexible and maintainable.

Designing APIs for Components

Use this skill to design component APIs that are intuitive and avoid the pitfalls of boolean prop proliferation.

How to install React Composition Patterns

View source

1. Install with the skills CLI

npx skills add calesthio/openmontage/vercel-composition-patterns --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by calesthio

React Composition Patterns

Composition patterns for building flexible, maintainable React components. Avoid boolean prop proliferation by using compound components, lifting state, and composing internals. These patterns make codebases easier for both humans and AI agents to work with as they scale.

Extended reference: AGENTS.md in this directory is the long-form upstream guide (vendored from Vercel). It is supplementary reference material scoped to this skill only — SKILL.md is the loadable entry point and the authority. It does not override or extend the repository-root AGENTS.md / AGENT_GUIDE.md.

When to Apply

Reference these guidelines when:

  • Refactoring components with many boolean props
  • Building reusable component libraries
  • Designing flexible component APIs
  • Reviewing component architecture
  • Working with compound components or context providers

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Component ArchitectureHIGHarchitecture-
2State ManagementMEDIUMstate-
3Implementation PatternsMEDIUMpatterns-
4React 19 APIsMEDIUMreact19-

Quick Reference

1. Component Architecture (HIGH)

  • architecture-avoid-boolean-props - Don't add boolean props to customize behavior; use composition
  • architecture-compound-components - Structure complex components with shared context

2. State Management (MEDIUM)

  • state-decouple-implementation - Provider is the only place that knows how state is managed
  • state-context-interface - Define generic interface with state, actions, meta for dependency injection
  • state-lift-state - Move state into provider components for sibling access

3. Implementation Patterns (MEDIUM)

  • patterns-explicit-variants - Create explicit variant components instead of boolean modes
  • patterns-children-over-render-props - Use children for composition instead of renderX props

4. React 19 APIs (MEDIUM)

⚠️ React 19+ only. Skip this section if using React 18 or earlier.

  • react19-no-forwardref - Don't use forwardRef; use use() instead of useContext()

How to Use

Read individual rule files for detailed explanations and code examples:

rules/architecture-avoid-boolean-props.md
rules/state-context-interface.md

Each rule file contains:

  • Brief explanation of why it matters
  • Incorrect code example with explanation
  • Correct code example with explanation
  • Additional context and references

Full Compiled Document

For the complete guide with all rules expanded: AGENTS.md

Frequently asked questions about React Composition Patterns

Similar skills