All skills
vercel-labs avatar

/composition-patterns

@a5343bd official
by Vercel Labsvercel-labs/agent-skills32k stars
2,784

React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.

Use this Skill: https://skilld.dev/gh/vercel-labs/agent-skills/composition-patterns

This session only. Nothing lands on disk.

SKILL.md

≈83 tokens always: the name and description. ≈613 when used: this file. ≈12k more on demand in 13 files.

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

Priority Category Impact Prefix
1 Component Architecture HIGH architecture-
2 State Management MEDIUM state-
3 Implementation Patterns MEDIUM patterns-
4 React 19 APIs MEDIUM react19-

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

Source: SKILL.md on GitHub

No alerts27d3 checks · Risk SAFE
  • Gen Agent Trust Hub27d

    This skill provides React composition patterns and architectural guidelines for frontend development. No security considerations were identified as the skill consists entirely of instructional documentation.

  • Socket27d

    No alerts

  • Snyk27d

    Risk: LOW · No issues

Signed by skilld at a5343bd. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 8 months ago
metadata
{
  "author": "vercel",
  "version": "1.0.0"
}
  • React
  • Refactoring
  • composition
  • component-architecture
  • state-management
  • compound-components
  • react19
  • component-library

README badge

README badge for vercel-labs/agent-skills/composition-patterns

Teaches React composition patterns to avoid boolean prop proliferation and build flexible component libraries using compound components, context providers, and state lifting. Includes guidelines for refactoring component architecture and references React 19 API changes like removing forwardRef in favor of use().

Generated from the current SKILL.md.

Does this skill cover React 19 changes?
Yes. The skill includes a React 19 APIs section covering changes like removing forwardRef in favor of use() and useContext() updates, but those rules only apply if you're using React 19 or later.
What specific composition patterns does this skill teach?
The skill covers compound components, render props, context providers, state lifting, and explicit variants. It prioritizes avoiding boolean prop proliferation by composing components instead.
Is this skill for building my own components or refactoring existing ones?
Both. Use it when refactoring components with too many boolean props, designing new component libraries, or reviewing component architecture decisions.
Does this skill include code examples?
Yes. Individual rule files contain incorrect and correct code examples with explanations for each pattern.

Generated from the current SKILL.md. These answers refresh after source changes.