New to Claude Skills? Learn how to install them →

supabase on GitHub

React Composition Patterns

OfficialFree

Streamline your React component architecture with proven patterns.

by supabase107.8k stars on supabase/supabase
4 views
Updated Aug 10, 2026
Get this skill

Free · Opens the source repo

What React Composition Patterns does

React Composition Patterns provides a structured approach to building flexible and maintainable React components. It addresses common pitfalls, such as the overuse of boolean props, by promoting effective composition techniques. This skill is particularly useful for developers looking to refactor existing components or design new ones that are both reusable and scalable. By employing these patterns, you can enhance the readability and maintainability of your codebase, making it easier for both humans and AI agents to navigate.

The skill includes a set of guidelines organized into four main categories: Component Architecture, State Management, Implementation Patterns, and React 19 APIs. Each category contains specific rules that offer insights into best practices for structuring your components. For instance, the architecture-avoid-boolean-props rule advises against using boolean props for customization, advocating instead for a composition-based approach that leads to clearer and more intuitive code.

This skill is ideal for developers and designers involved in building component libraries or working on complex applications that require a robust architecture. It serves as a reference guide during the design and review process, ensuring that your components adhere to established best practices. The rules are designed to be straightforward and actionable, with each rule file providing explanations, incorrect and correct code examples, and additional context to aid understanding.

Overall, React Composition Patterns is a valuable resource for anyone looking to improve their React component design, particularly in the context of modern development practices. By integrating these patterns into your workflow, you can create components that are not only easier to maintain but also more adaptable to future changes in your application.

When to use it

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

When not to use it

This skill may not be suitable for projects using React 18 or earlier, as some patterns are specific to React 19.

What you can build with it

Refactoring Legacy Components

When working with older React components that rely heavily on boolean props, use this skill to apply composition patterns for a cleaner architecture.

Designing a Component Library

If you're building a library of reusable components, these patterns will help you create a flexible and maintainable API for other developers.

Reviewing Component Architecture

Use this skill as a reference during code reviews to ensure that components follow best practices and are structured for scalability.

How to install React Composition Patterns

View source

1. Install with the skills CLI

npx skills add supabase/supabase/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 supabase

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.

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 these patterns if you're on 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