React composition patterns

Applies eight Vercel rules that replace boolean props with compound components, provider-held state and explicit variants, plus React 19 ref and use() changes. Use when a component has too many flags or when designing a component library.

CodingPack: Vercel skillslinkcomposition-patterns
Author
Source
vercel-labs/agent-skills/skills/composition-patterns @ 1a2c79d
License
MIT

About this skill

What it does

The skill targets one recurring problem in React code: a component that grows a boolean prop for every case until nobody knows which combinations work. Its eight rules replace configuration with composition.

Component architecture is rated highest: no boolean props to change behaviour, and complex components built as compound components sharing a context. State management: only the provider knows how state is stored; the context exposes a generic interface of state, actions and meta, so the same UI can run on different state implementations; state is lifted into the provider so siblings can reach it. Two implementation patterns: explicit variant components instead of modes (the README's example is ThreadComposer and EditComposer rather than Composer with isThread), and children instead of renderX props. The last section is React 19 only, skipped on React 18: ref as a plain prop instead of forwardRef, and use() instead of useContext().

SKILL.md is the index. Each rule has a file in rules/ with the reason and a wrong and a right example; AGENTS.md (about 22 KB) holds them all.

When to use it, and when not

Use it when a component has collected flags like isEditing or showActions, when you build a component library or design system, and in architecture reviews.

It says nothing about styling, accessibility or performance. A component with one or two props does not need compound parts and a provider; the rules pay off once there are real variants.

How to run it

We do not copy this skill: its frontmatter says MIT, but the repository ships no licence text to put beside a copy. Install it from Vercel's repository with the button to the source; its README uses the skills.sh installer, npx skills add vercel-labs/agent-skills, and --skill vercel-composition-patterns limits it to this one. The skill's name is vercel-composition-patterns:

  • Claude Code: /vercel-composition-patterns, or ask for the skill by name.
  • Codex: $vercel-composition-patterns.
  • Cursor: type / in the Agent chat and pick vercel-composition-patterns.

Example: /vercel-composition-patterns Our Modal has nine boolean props. Propose a compound component API and migrate the three call sites.

How it differs from similar skills

Frontend UI engineering states the same principle in one line among rules on state, design and accessibility; this skill works it out in code. Deep module design covers module interfaces in any language, not React. API and interface design treats props as one contract among many. React Native best practices applies compound components to design-system buttons.

Install

This skill is not copied to the catalog: the author's repository has no licence text. Install it from there.

Open the source

Connect through AnyModel API

This skill runs on whatever model your agent uses. Point Claude Code, Codex or Cursor at AnyModel to run it on Claude, GPT, Gemini and more with one key — pay per token, no subscription.

More from the pack Vercel skills

React and Next.js performance rules

Gives the agent Vercel's 70 React and Next.js performance rules, ranked by impact: request waterfalls, bundle size, server work, re-renders, rendering. Use when writing, refactoring or reviewing React or Next.js code for speed.

React Native best practices

Applies Vercel's React Native and Expo rules: virtualized lists, transform and opacity animations, native navigators, expo-image, state, monorepo setup. Use when building or speeding up a mobile app or reviewing React Native code.

React view transitions

Implements animations with React's View Transition API: shared element morphs, Suspense reveals, list reorder and directional route slides, with CSS recipes and Next.js integration. Use when adding page or state transitions to a React or Next.js app.

Deploy to Vercel, Vercel Labs

Deploys a project to Vercel as a preview, choosing git push, CLI deploy, linking first or a temporary deploy without an account by the project's state, and returns the URL. Use when asked to deploy an app and get a link.

Vercel CLI with tokens

Runs the Vercel CLI from an access token instead of a browser login: finds the token, deploys previews, manages env vars, logs and domains, keeps the token out of command flags. Use when working with Vercel from a non-interactive shell.

Vercel cost and performance tuning

Audits a deployed Vercel project for cost and performance: collects metrics first, picks candidates by fixed thresholds, inspects only flagged routes and returns verified, cited recommendations. Use when cutting a Vercel bill or fixing slow routes.

Web Interface Guidelines review

Reviews UI code against Vercel's Web Interface Guidelines, fetched fresh on each run, and lists findings as file:line: accessibility, focus, forms, animation, typography, images, performance. Use when checking components or pages before a pull request.

Writing Guidelines review

Reviews docs and prose against Vercel's writing handbook, fetched fresh on each run, and lists findings as file:line: voice, structure, headings, code samples, units, typography. Use when checking English docs before publishing.