Officialコーディング&開発github.com

vercel-composition-patterns

スケーラブルなReactコンポジションパターン。コンポーネントのリファクタリング時に使用します。

vercel-composition-patterns とは?

このスキルは、Reactコンポーネントをより柔軟で保守しやすいものにするためのコンポジションパターンを提供します。Booleanプロップの乱用を避け、複合コンポーネント、状態のリフトアップ、内部のコンポジションを活用することで、コードベースがスケールしても人間とAIエージェントの両方が扱いやすくなります。主にClaude Code、Cursor、CodexなどのAIエージェントが、コンポーネントのリファクタリングやライブラリ設計時に参照するためのガイドラインとして機能します。各ルールは優先度に応じてカテゴリ分けされており、個別のルールファイルがコード例とともに詳細な説明を提供します。React 19の新APIに関する注意点も含まれています。

対応~Claude Code~Codex CLI~Cursor
Part ofReact
npx skills add https://github.com/vercel-labs/agent-skills/tree/main/skills/composition-patterns

Installed? Explore more コーディング&開発 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Reactコンポジションパターン

柔軟で保守性の高いReactコンポーネントを構築するためのコンポジションパターン。 Booleanプロップの乱用を避け、複合コンポーネント、状態のリフトアップ、内部のコンポジションを活用します。 これらのパターンにより、コードベースはスケールするにつれて人間とAIエージェントの両方にとって扱いやすくなります。

適用すべきタイミング

以下の場合にこれらのガイドラインを参照してください:

  • 多くのBooleanプロップを持つコンポーネントをリファクタリングする場合
  • 再利用可能なコンポーネントライブラリを構築する場合
  • 柔軟なコンポーネントAPIを設計する場合
  • コンポーネントアーキテクチャをレビューする場合
  • 複合コンポーネントやコンテキストプロバイダーを扱う場合

優先順位別ルールカテゴリ

優先順位カテゴリ影響度プレフィックス
1コンポーネントアーキテクチャ高architecture-
2状態管理中state-
3実装パターン中patterns-
4React 19 API中react19-

クイックリファレンス

1. コンポーネントアーキテクチャ(高)

  • architecture-avoid-boolean-props - 動作をカスタマイズするためにBooleanプロップを追加しないでください。代わりにコンポジションを使用します。
  • architecture-compound-components - 共有コンテキストで複雑なコンポーネントを構成します。

2. 状態管理(中)

  • state-decouple-implementation - プロバイダーのみが状態の管理方法を知っています。
  • state-context-interface - 依存性注入のために、状態、アクション、メタを備えた汎用インターフェースを定義します。
  • state-lift-state - 兄弟アクセスを可能にするために、状態をプロバイダーコンポーネントに移動します。

3. 実装パターン(中)

  • patterns-explicit-variants - Booleanモードの代わりに明示的なバリアントコンポーネントを作成します。
  • patterns-children-over-render-props - renderXプロップの代わりにchildrenを使用してコンポジションを行います。

4. React 19 API(中)

⚠️ React 19+ のみ。 React 18以前を使用している場合はこのセクションをスキップしてください。

  • react19-no-forwardref - forwardRefを使用しないでください。useContext()の代わりにuse()を使用します。

使い方

個別のルールファイルを読んで、詳細な説明とコード例を確認してください:

rules/architecture-avoid-boolean-props.md
rules/state-context-interface.md

各ルールファイルには以下が含まれています:

  • なぜそれが重要かの簡単な説明
  • 間違ったコード例とその説明
  • 正しいコード例とその説明
  • 追加のコンテキストと参考資料

完全なコンパイルドキュメント

すべてのルールを展開した完全なガイドについては: AGENTS.md

Individual skills in this repo

This repo contains 11 individual skills — each has its own dedicated page.

deploy-to-vercel

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

vercel-cli-with-tokens

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g.

vercel-labs/vercel-composition-patterns

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.

vercel-labs/vercel-react-best-practices

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

vercel-labs/vercel-react-native-skills

React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.

vercel-labs/vercel-react-view-transitions

Guide for implementing smooth, native-feeling animations using React's View Transition API (`<ViewTransition>` component, `addTransitionType`, and CSS view transition pseudo-elements). Use this skill whenever the user wants to add page transitions, animate route changes, create shared element animations, animate enter/exit of components, animate list reorder, implement directional (forward/back) navigation animations, or integrate view transitions in Next.js. Also use when the user mentions view transitions, `startViewTransition`, `ViewTransition`, transition types, or asks about animating between UI states in React without third-party animation libraries.

vercel-optimize

Use for Vercel cost and performance optimization on deployed projects, especially Next.js, SvelteKit, Nuxt, and limited Astro apps. Collect Vercel metrics, usage, project config, and code scan results first; investigate only metric-backed candidates; produce ranked recommendations grounded in verified files and version-aware Vercel/framework docs. Trigger for Vercel bill reduction, slow or expensive routes, caching opportunities, Function Invocations, Build Minutes, Fast Data Transfer, Core Web Vitals, Bot Management, Fluid compute, or cost breakdown requests.

vercel-react-best-practices

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

vercel-react-native-skills

React Native and Expo best practices for building performant mobile apps. Use

web-design-guidelines

Review UI code for Web Interface Guidelines compliance. Use when asked to

writing-guidelines

Review docs/prose for Writing Guidelines compliance. Use when asked to

関連スキル