composition-patterns_skill

This skill helps you refactor React components by applying scalable composition patterns to reduce boolean props and clarify APIs.
  • Python

33

GitHub Stars

4

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill trsoliu/mini-wiki --skill composition-patterns

  • AGENTS.md20.8 KB
  • metadata.json530 B
  • README.md2.1 KB
  • SKILL.md2.5 KB

Overview

This skill provides a concise guide to React composition patterns that scale. It focuses on avoiding boolean prop proliferation and designing flexible, maintainable component APIs for component libraries and applications. Use it to refactor complex components, introduce compound components, or standardize provider-based state management.

How this skill works

The skill inspects tasks involving component architecture, state management, and implementation patterns, and recommends concrete alternatives such as compound components, lifted state in providers, and explicit variant components. It maps issues to prioritized rule categories (architecture, state, patterns) and points to focused rule files that include incorrect/correct examples and implementation notes. Apply the rules to refactor boolean-heavy props, define context interfaces, and convert render-prop patterns into clearer composition.

When to use it

  • Refactoring components that rely on many boolean props or mode flags
  • Designing or expanding a reusable component library with clear APIs
  • Implementing compound components that share context and behavior
  • Lifting state into providers so siblings can access and coordinate state
  • Reviewing component architecture for scalability and clarity

Best practices

  • Avoid boolean props; prefer explicit variant components or subcomponents
  • Centralize state logic inside provider components and expose a clear interface
  • Use context with a documented state/actions/meta shape for dependency injection
  • Prefer children composition over scattered render props when possible
  • Create small, focused rule files with incorrect and corrected examples for onboarding

Example use cases

  • Refactor a Modal that has isOpen, isClosable, and destructiveMode booleans into a Modal provider and explicit Modal.Close and Modal.Action components
  • Build a Tabs library using compound components where TabList, Tab, and TabPanel share context and avoid prop drilling
  • Convert a Button component with many mode flags into distinct PrimaryButton, GhostButton, and IconButton components
  • Lift form state into a Form provider so nested inputs and controls can access validation and submission actions
  • Replace ad-hoc render props with children-based composition for clearer markup and predictable lifecycles

FAQ

Prefer compound components when multiple related elements must coordinate behavior or share state; they scale better than adding more boolean props.

How do I expose provider state safely?

Define a minimal public interface (state, actions, meta) and keep implementation details private to allow future refactors without breaking consumers.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational