From react-rules-plugin
Reactコンポーネント開発ルール。関数コンポーネント、Props API設計、条件付きレンダー、アクセシビリティ、テストの規約を定義。コンポーネント実装時に参照。
How this skill is triggered — by the user, by Claude, or both
Slash command
/react-rules-plugin:componentThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Reactコンポーネントの規約を定義するスキル。
Reactコンポーネントの規約を定義するスキル。
React.FC は使用しない)type Props として定義composition を優先し、意味のないラッパー要素を増やさないonClick / onChange のように onXxx で命名variant / size などは文字列unionで表現し、許可値を型で制限children は必要なときだけ明示的に受け取る(暗黙的に許可しない)ComponentPropsWithoutRef<"button"> などを活用し、標準属性を透過return で分ける&& を使う(長いJSXや複数分岐には使わない)if で明示分岐するPascalCasecamelCasearia-label を必ず付与label と関連付ける(htmlFor / id または aria-labelledby)alt を設定(装飾画像は空文字)button 要素は type を明示(button / submit)| パターン | 有効な場面 | 使いすぎ注意 |
|---|---|---|
Composition (children / slot props) | レイアウトの差分だけを差し替えたい。DOMの入れ子を減らしたい。 | propsが増えすぎるなら分割を検討 |
Compound Components (X.Root, X.Item) | 関連要素をセットで使い、構造の一貫性を保ちたい。 | Context依存が強すぎると追跡しづらい |
Render Props (children as function) | 振る舞いは共通、描画は画面ごとに変えたい。Headlessな再利用をしたい。 | 通常のhooksで十分な場合は不要 |
| Controlled/Uncontrolled | フォーム入力や開閉状態を、外部管理/内部管理で使い分けたい。 | 両対応する場合は優先順位を明記 |
div 追加は避ける(既存要素やsemantic要素を優先)React.memo は再描画コストが高い箇所かつ効果が計測で確認できる場合に限定memo 前提の子に関数propsを渡す場合は useCallback を検討useMemo でキャッシュし、依存配列を厳密に管理@testing-library/react でユーザー視点のクエリ(getByRole など)を優先npx claudepluginhub dio0550/d-market-react --plugin react-rules-pluginProvides React composition patterns for refactoring boolean prop-heavy components, building compound components, context providers, and scalable APIs.
Provides React best practices for function components, props interfaces, compound components, useState, useEffect hooks, and state management. Useful for optimizing React code architecture and performance.
Guides the design of props interfaces, composition models, and public APIs for reusable React/UI components using atomic design patterns and inversion of control. Helps avoid broken contracts and escape hatches.