React Composition Patterns

React Composition Patterns

Teaches an agent React composition patterns such as compound components and context providers to avoid boolean prop sprawl and build flexible component APIs.

Skill files14 files

rules/

SKILL.md90 lines
1
---
2
name: vercel-composition-patterns
3
description:
4
React composition patterns that scale. Use when refactoring components with
5
boolean prop proliferation, building flexible component libraries, or
6
designing reusable APIs. Triggers on tasks involving compound components,
7
render props, context providers, or component architecture. Includes React 19
8
API changes.
9
license: MIT
10
metadata:
11
author: vercel
12
version: '1.0.0'
13
---
14
15
# React Composition Patterns
16
17
Composition patterns for building flexible, maintainable React components. Avoid
18
boolean prop proliferation by using compound components, lifting state, and
19
composing internals. These patterns make codebases easier for both humans and AI
20
agents to work with as they scale.
21
22
## When to Apply
23
24
Reference these guidelines when:
25
26
- Refactoring components with many boolean props
27
- Building reusable component libraries
28
- Designing flexible component APIs
29
- Reviewing component architecture
30
- Working with compound components or context providers
31
32
## Rule Categories by Priority
33
34
| Priority | Category | Impact | Prefix |
35
| -------- | ----------------------- | ------ | --------------- |
36
| 1 | Component Architecture | HIGH | `architecture-` |
37
| 2 | State Management | MEDIUM | `state-` |
38
| 3 | Implementation Patterns | MEDIUM | `patterns-` |
39
| 4 | React 19 APIs | MEDIUM | `react19-` |
40
41
## Quick Reference
42
43
### 1. Component Architecture (HIGH)
44
45
- `architecture-avoid-boolean-props` - Don't add boolean props to customize
46
behavior; use composition
47
- `architecture-compound-components` - Structure complex components with shared
48
context
49
50
### 2. State Management (MEDIUM)
51
52
- `state-decouple-implementation` - Provider is the only place that knows how
53
state is managed
54
- `state-context-interface` - Define generic interface with state, actions, meta
55
for dependency injection
56
- `state-lift-state` - Move state into provider components for sibling access
57
58
### 3. Implementation Patterns (MEDIUM)
59
60
- `patterns-explicit-variants` - Create explicit variant components instead of
61
boolean modes
62
- `patterns-children-over-render-props` - Use children for composition instead
63
of renderX props
64
65
### 4. React 19 APIs (MEDIUM)
66
67
> **⚠️ React 19+ only.** Skip this section if using React 18 or earlier.
68
69
- `react19-no-forwardref` - Don't use `forwardRef`; use `use()` instead of `useContext()`
70
71
## How to Use
72
73
Read individual rule files for detailed explanations and code examples:
74
75
```
76
rules/architecture-avoid-boolean-props.md
77
rules/state-context-interface.md
78
```
79
80
Each rule file contains:
81
82
- Brief explanation of why it matters
83
- Incorrect code example with explanation
84
- Correct code example with explanation
85
- Additional context and references
86
87
## Full Compiled Document
88
89
For the complete guide with all rules expanded: `AGENTS.md`
90

© vercel · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 6,373 prompts

More by @OpenSourceBuffGuy

See all
Website Clone Architect prompt image

Website Clone Architect

Reverse-engineers a website section by section, writes component specs, and hands them to parallel builder agents in git worktrees to rebuild it.

agent-skill, orchestrator, parallel-agents, multi-agent, plan-then-execute, web-development, frontend, codebase-analysis, scaffolding, css, html, nextjs, typescript, git, mcp, claude-code, for-developers, for-designers, long-form, advanced, technical-spec, task-decomposition, structured-output, design-systems, ui-ux, tool-use, checklist, report, vibe-coding

Italian Terrace Cafe Candid Portrait prompt image

Italian Terrace Cafe Candid Portrait

Generates a photorealistic candid shot of a woman in a white corset dress laughing at a sunny hotel terrace cafe, written as detailed JSON.

image-prompt, json-prompt, structured-output, photorealistic, portrait, woman, candid, fashion, cottagecore, natural-light, golden-hour, bokeh, summer, travel, cityscape, mountains, medium-shot, vibrant-colors, for-photographers, nano-banana, fashion-shoot, luxury

Night Street Photo With Leashed Cat prompt image

Night Street Photo With Leashed Cat

Generates a flash-lit night street photo of a blonde woman in a retro track jacket walking a hissing tabby cat on a leash.

image-prompt, json-prompt, nano-banana, structured-output, portrait, woman, animals, pet-portrait, night-scene, street-photography, candid, editorial, fashion, dramatic-lighting, photorealistic, vertical-format, medium-shot, graffiti, for-photographers, for-content-creators

1 view

Reviews

Loading reviews…

Discussion

Loading comments…