Webページの移動やフォーム入力、クリックをエージェントに任せ、情報抽出や画面保存、操作前後の比較まで行います。ブラウザ作業の自動化やWebアプリの確認に使えるスキル。
- フォーム入力やクリックを自動化したいとき
- Webページのテキスト抽出
- ページのスクリーンショット・PDF保存
Reactコンポーネントのpropsを実際のアプリで使う状態に合わせて厳密にし、不要な省略指定や分岐を整理します。テストやStorybook側の修正も扱います。
narrow React component prop types to match live code paths
実行スコア 未検証
インストール方法を見るReactコンポーネントのprops(コンポーネントに渡す値)の型を、実際のアプリで使われる状態に合わせて見直します。呼び出し元を調べ、必須・省略可能・未使用に分類し、不要な省略指定や使われないpropsを整理します。常に表示されるボタンの処理を必須にしたり、不要になった代替値や条件分岐を削除したりする作業も扱います。
Storybookやテスト、モックの都合で型が緩くなり、実際には起きない状態まで扱っているコンポーネントの整理に向いています。共通の型を使う派生コンポーネントや子コンポーネントも、一緒に見直せます。
型を決める根拠は、テストやStorybook以外の呼び出し元です。値がnullになることと、props自体を省略できることを区別します。変更したパッケージと、それを利用するアプリやパッケージの型チェックで確認します。
この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。
インストールする前に、エージェントに与えられる指示の中身を確認できます。
Use this skill when a React component's props have been widened for stories, mocks, tests, or demos and now express states the live application does not enter.
The goal is to make component types describe the real live-code-path contract, then require stories/tests/mocks to adapt to that contract instead of weakening it.
Look for components with these signals:
onSelect?.(...) or onArchive?.(...).items ?? [], count ?? 0, or handler && ... around values live code likely always supplies.defaultFoo, alternate handler shapes, or display toggles not used by live code.Do not pick a target from a story or test alone. Use stories/tests only as supporting evidence that the type has been widened, not as evidence that a state is real.
Search for all imports/usages of the component, exported prop type, and shared child primitives.
Classify call sites by whether they are live code paths or support code:
Only live code paths should determine what the component API supports.
Read the live call sites and classify each prop:
Nullability and optionality are different. If live code always passes a prop but the value can be empty, prefer a required nullable prop such as focusedItem: FocusedItem | null over focusedItem?: FocusedItem | null.
Update exported prop types to match only the states observed in live code paths.
The looser and more optional a type is, the more possible states the component has to reason about. Every optional prop creates another branch the component must handle, test, and keep correct. Prefer strict types that prevent impossible states instead of broad types that require defensive render logic.
If the component always renders an interactive affordance, require the handler that makes it work. Do not allow inert states like a visible menu item that calls onRename?.(...).
Prefer deriving types from the live APIs instead of restating them manually:
Parameters<typeof fn>[0] for function argument types.ReturnType<typeof fn> for return types.Extract<Union, Shape> for narrowing a union to a real variant.React.Dispatch<React.SetStateAction<T>> for React state setters instead of approximating them as (value: T) => void.Prefer explicit state type parameters when inference would widen or obscure the intended state shape:
const [dialogState, setDialogState] = useState<DialogState>({
id: null,
isOpen: false,
})
Avoid relying on implicit useState(...) inference when it produces broad nullable object shapes, string literal widening, or callback types that later need hand-written approximations.
Do not stop at the exported component if it passes broad props into child primitives.
If row/menu/button child components receive optional handlers only because the parent props were broad, tighten those internal props too. Replace optional calls like this:
onRename?.(id, name)
with required calls:
onRename(id, name)
Once props are required, remove defensive fallbacks that only existed for widened types.
Examples:
new Set(expandedIds ?? defaultExpandedIds ?? [])
should become:
new Set(expandedIds)
items && items.length > 0
should become:
items.length > 0
If multiple components share the broad prop type, update them together so they all enforce the same live-code-path contract.
If a story or test breaks after narrowing props, fix it by providing realistic handlers and state. Do not make live-code-path props optional again to reduce test setup.
If the story/test setup feels verbose, create a test helper or fixture that satisfies the strict live-code-path contract. Keep the helper in support code; do not weaken the component API.
Run package-level typechecks for the changed package and each live app/package that consumes the changed component.
Use repository-specific validation commands when available. In this monorepo, prefer:
bun --bun run typecheck --filter <package>
useState<T>(...) is used where inference would otherwise widen or obscure the intended state.onAction?.(...).default* props for Storybook when live code is controlled.?? [] or ?? 0 to hide missing required live state.まだレビューはありません。使ってみた感想をお寄せください。
ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。
まだコメントはありません。最初のコメントを書いてみませんか。
Webページの移動やフォーム入力、クリックをエージェントに任せ、情報抽出や画面保存、操作前後の比較まで行います。ブラウザ作業の自動化やWebアプリの確認に使えるスキル。
曖昧で読みにくい英文を、語の意味をそろえた短い能動態の文へ書き直すスキル。指示文やツール説明を見直し、修正理由と変更前後を表で確認できます。
GitHubのPRの状態、レビューの会話、CI失敗のログを専用スクリプトで収集し、変更の確認状況や未解決の指摘、失敗したジョブとステップを調べるスキル。
リリース時に対象パッケージの基準バージョンを更新し、関連ファイルの同期と生成結果を検証して、コミットからPRブランチへのプッシュまで進めるスキル。
Git のコミット間や作業中のコードで、関数の呼び出し構造の違いを確認します。呼び出しツリーの表示や、指定した関数へ至る経路の調査にも使えます。
ターミナルからブラウザのクリックや入力、ページ移動を自動化し、通信やエラー、表示速度も調べられる、Chrome DevToolsのCLI操作を支援するスキル。