React component conventions
Skill yend724/agent-skills/skills/react-component-conventions
React component design conventions focusing on Server/Client component boundaries, composition patterns, and data flow. Auto-triggers when writing or modifying React components to ensure correct RSC patterns and optimal component architecture.From its SKILL.md
npx -y skills add yend724/agent-skills --skill react-component-conventionsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
5.8 KB, ~1.7k tokens by cl100k_base, as published. Nobody here has run it
React Component Design Conventions
React コンポーネント設計の規約集。Server Components / Client Components の境界設計、Composition パターン、データフローに関するルールを定義する。
When to Apply
以下の作業時に自動で参照する:
- React コンポーネントの新規作成
- 既存コンポーネントのリファクタリング
"use client"ディレクティブの追加・削除判断- データ取得パターンの実装
- コンポーネント間のデータフロー設計
Compatibility
React 19+ / RSC対応フレームワーク
Rule Categories
| Category | Prefix |
|---|---|
| Server/Client 境界 | boundary- |
| データ取得 | fetching- |
| Composition パターン | composition- |
| Suspense/ErrorBoundary | suspense- |
| Hooks 設計 | hooks- |
| パフォーマンス | perf- |
| コーディング規約 | style- |
Quick Reference
Server/Client 境界
- boundary-minimize-use-client -
"use client"はコンポーネントツリーの末端に置く - boundary-leaf-interactivity - インタラクティブ要素のみを Client Component として切り出す
- boundary-no-premature-client - クライアント機能を使わないのに
"use client"を付けない - boundary-serialize-props - Server → Client に渡す props はシリアライズ可能にする
- boundary-context-provider-wrapper - Context Provider は専用の Client Component でラップする
データ取得
- fetching-server-first - データ取得は Server Component で行い、結果を props で渡す
- fetching-no-useeffect-fetch - 初期データ取得に useEffect を使わない
- fetching-colocate - データ取得はそれを使うコンポーネントにコロケーションする
- fetching-async-component - Server Component は async/await で直接データ取得する
Composition パターン
- composition-children-across-boundary - children を使って Server Component を Client Component 内に配置する
- composition-render-prop-for-server - 複雑なレイアウトでは render prop で Server Component を注入する
- composition-slots-pattern - 複数の Server Component を Client に渡すには名前付き slots を使う
- composition-avoid-prop-drilling - 深いprops受け渡しより Composition で解決する
Suspense / ErrorBoundary
- suspense-granular-boundaries - Suspense 境界は可能な限り細粒度に配置する
- suspense-avoid-single-wrapper - ページ全体を1つの Suspense で囲まない
- suspense-parallel-streaming - 独立したデータソースは別々の Suspense で並列ストリーミングする
- suspense-meaningful-fallback - fallback は意図を持って選択する
- errorboundary-isolation - 障害の影響範囲を限定するために ErrorBoundary を適切に配置する
Hooks 設計
- hooks-single-responsibility - 1つの custom hook は1つの関心事のみを扱う
- hooks-extract-logic - 計算ロジックは hook の外の pure function として抽出する
- hooks-stable-references - コールバックや依存値の参照安定性を意識する
- hooks-use-effect-discipline - useEffect は外部システムとの同期専用にする
パフォーマンス
- perf-no-premature-memo - useMemo / useCallback を計測なしに使わない
- perf-transition-heavy-update - 重い状態更新には useTransition を使う
- perf-deferred-slow-render - 遅いコンポーネントには useDeferredValue で入力のレスポンスを維持する
コーディング規約
- style-arrow-named-export - アロー関数 + named export でコンポーネントを定義する
- style-props-type - Props の型は type で定義し、React.FC で型付けする
- style-file-naming - ファイル名は kebab-case で統一する
- style-import-order - インポートはカテゴリ順に並べ、グループ間に空行を入れる
How to Use
個別ルールの詳細は rules/ ディレクトリ内のファイルを参照。上記 Quick Reference のリンクから各ルールにアクセスできる。
各ルールファイルには以下が含まれる:
- ルールの説明と根拠
- Bad: 間違ったコード例
- Good: 正しいコード例
- 判断に迷うケースのガイダンス
What ships with it: 29 files
63.1 KB alongside SKILL.md
rules/
- boundary-context-provider-wrapper.md1.9 KB
- boundary-leaf-interactivity.md1.9 KB
- boundary-minimize-use-client.md1.7 KB
- boundary-no-premature-client.md1.7 KB
- boundary-serialize-props.md2.0 KB
- composition-avoid-prop-drilling.md1.9 KB
- composition-children-across-boundary.md2.0 KB
- composition-render-prop-for-server.md2.2 KB
- composition-slots-pattern.md1.9 KB
- errorboundary-isolation.md2.6 KB
- fetching-async-component.md1.6 KB
- fetching-colocate.md2.2 KB
- fetching-no-useeffect-fetch.md1.9 KB
- fetching-server-first.md1.7 KB
- hooks-extract-logic.md2.7 KB
- hooks-single-responsibility.md2.3 KB
- hooks-stable-references.md2.5 KB
- hooks-use-effect-discipline.md5.5 KB
- perf-deferred-slow-render.md3.9 KB
- perf-no-premature-memo.md3.3 KB
- perf-transition-heavy-update.md3.4 KB
- style-arrow-named-export.md592 B
- style-file-naming.md466 B
- style-import-order.md1005 B
- style-props-type.md823 B
- suspense-avoid-single-wrapper.md2.4 KB
- suspense-granular-boundaries.md2.1 KB
- suspense-meaningful-fallback.md2.6 KB
- suspense-parallel-streaming.md2.4 KB