vercel-labs/agent-skills · skills/composition-patterns/SKILL.md
vercel-composition-patterns
“Tidy index of React composition rules; the real lessons live in rule files this review couldn't see”
What it does
A short index of eight React composition rules: avoid boolean props, use compound components, lift state into providers, and adopt React 19 APIs. Each rule is one line here. Explanations and code examples are said to be in rules/*.md and AGENTS.md.
- When the agent uses it
- When refactoring React components bloated with boolean props, building a component library, or designing APIs with compound components, render props or context.
- Who it is for
- For React teams designing or reviewing component APIs who will also get the rules/ folder. Not for non-React work, or if you only have SKILL.md, which is just a list.
- What it costs
- 65 lines, about 779 tokens once the agent loads it.
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.
What it tells the agent to do
- Apply when refactoring boolean-heavy components, building libraries, designing APIs or reviewing architecture
- Work through the rule categories by priority, starting with Component Architecture (HIGH)
- Use the one-line quick-reference rules to guide changes, such as composition over boolean props and state lifted into providers
- Skip the React 19 section if the project uses React 18 or earlier
- Open rules/<rule-name>.md for the explanation and incorrect/correct code examples
- Read AGENTS.md for the full guide with all rules expanded
Lines worth reading
Straight from the file, with why each one matters.
line 4Use when refactoring components with
The description names real symptoms (boolean prop proliferation) and pattern names, so it matches the words people actually type.
line 45Don't add boolean props to customize
The core thesis in one line, ranked HIGH. Every isPrimary, isCompact or hasIcon prop is a vote for this skill.
line 52Provider is the only place that knows how
A sharp rule. Consumers get an interface and never see the state mechanics. It is dependency injection, React-style.
line 69Don't use `forwardRef`; use `use()` instead of `useContext()`
Two unrelated React 19 changes share one line, and the line never says what replaces forwardRef (ref as a plain prop).
line 19These patterns make codebases easier for both humans and AI
A pitch aimed partly at the reader's agent: composition is sold as AI-friendly architecture.
Watch out for
Nothing risky that Kin could see in SKILL.md. Scripts beside it were not read.
The scorecard
- TriggerSays when to use it8/10
Clear uses and request words in the description; leads with a slogan, not the task.
- FocusOne clear job8/10
One job: React component API design. The React 19 rule is a small side trip.
- LeanLight to load9/10
About 65 lines, a priority table and links out. Ideal progressive disclosure.
- ConcreteSteps you can follow4/10
No code at all in SKILL.md. Examples are in rule files that could not be listed.
- SafeSafe to run10/10
Pure guidance: no commands, network calls or secrets.
What it does well
- Rules ranked by impact with stable prefixes, so the agent knows what to fix first and which file to open
- Explicit version gate: the React 19 rules are skipped for React 18 and earlier, which avoids bad upgrades
- Keeps SKILL.md tiny and pushes examples into per-rule files, which is how skills are meant to be built
How it could be better
Split and complete the React 19 rule
Line 69 bundles two changes and never says what replaces forwardRef, so the agent may delete it without passing ref.
Add- `react19-no-forwardref` - In React 19, accept `ref` as a regular prop instead of wrapping components in `forwardRef`; read context with `use(Context)` instead of `useContext(Context)`
Inline one before/after example
If the rules/ folder is missing, the agent has only slogans. One short example anchors the main rule.
Add### Example: boolean props → composition ```tsx // Before <Composer isThread isEditing hasAttachments /> // After <Composer.Provider> <Composer.Input /> <Composer.Attachments /> </Composer.Provider> ``` <adjust names to match rules/architecture-avoid-boolean-props.md>
Say what done looks like
There is no check for a finished refactor, so the agent cannot verify its work.
Add## Done when - No component takes boolean props that switch layout or behavior - Variants are separate components that compose shared internals - State lives in one provider; consumers use only its state/actions/meta interface
List every rule file path
Only two of eight rule files are shown, so the agent must guess the other paths from the prefixes.
AddRule files (open only the ones relevant to the task): - rules/architecture-avoid-boolean-props.md - rules/architecture-compound-components.md - rules/<rule-name>.md for each remaining rule above
Kin reviews against Anthropic’s Extend Claude with skills and agentskills.io’s the Agent Skills standard. It reads SKILL.md only, so a script beside it can still do things the file does not say.