state-machine
できること
このスキルは、コンポーネントがとりうる状態(読み込み中、空、エラーなど)を一覧にし、それぞれを一時的なページに表示します。各状態の見た目に取り組みたい開発者やデザイナー向けです。
使う場面
- ✓テーブルやパネルを、読み込み中、空、エラーの状態で見たいとき。
- ✓プラン、役割、機能フラグごとに、画面の見た目を作りたいとき。
- ✓模擬データを使い、キーでそれぞれの状態を切り替えられるページがほしいとき。
スキルのリンク
https://github.com/jakubkrehel/skills/blob/main/skills/state-machine/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“監査ログのテーブルのすべての状態を、テストページで見せてください。それぞれを確認しながら作業したいです。”
毎週5つの新しいスキル。1分で読めます。
仕組み
このスキルは、コンポーネントのコードを読み、既に扱っている各状態を見つけます。それぞれについて模擬データを使った一時的なページを作り、状態を切り替えるツールを付けます。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
State machine
This skill takes one component and renders it on a throwaway page in every state it can be in. Mock data feeds each state, a switcher flips between them and the page is deleted in one step when you are done.
It is a workbench, not a review. The page stays up while the user works on the visuals, one state on screen and every other a keypress away. Stacking hostile scenarios on one page for a single look is break, exploring alternative designs is variant and reviewing finished work is interface-review.
1. Scope one component
One component per run: the audit log table, the network panel, the billing card. "The settings page" spans several, so list them and ask which one.
Restate it in one sentence: what the component shows, where it renders in production and where its data comes from.
2. Find the states in the code
The states are the branches the component already has. Read it and its data hooks for every one:
| Kind | States |
|---|---|
| Data | Loading, empty, error, one item, a typical set, a set long enough to scroll or paginate, some requests resolved and others pending, stale data refetching |
| Account | Plan tier, role and permission checks, an owner versus a member |
| Feature | Flags, trials, limits reached, a disabled or locked feature |
A state the code cannot reach is not a state. Do not add a branch to render one. Where the design shows a state the code lacks, list it as missing and leave it out.
Write the set down before building, one line each, named the way the product talks about it: empty, enterprise, member-no-access. Group them under headings in the product's words, by what changes. Use Data and Account or narrower ones such as Connection or Access. The switcher shows these groups. Say which kinds you dropped and why in one line. Combine kinds only where the code branches on the combination, such as member-empty, never as a cross product.
3. Build the throwaway page
A scratch route inside the app holds the real component, imported from the project and untouched. The route inherits the app's layout, fonts, global styles and providers for free.
Where the framework splits server from client components, the page is client code, "use client" in Next. Otherwise fixture data can silently vanish crossing that boundary, and the page renders empty.
Render one instance in a container as wide as the component is in production. The container, the fixtures and the switcher are everything the page adds, with no fonts, styles or themes of its own. Keep the page, its fixtures and its switcher in one folder, such as /states/audit-log, so removal is one delete.
4. Feed each state at the data boundary
Supply the data where the component receives it, from the page, without editing the component. In order of preference:
- Props, where the component takes its data as props.
- The app's own data seam: a seeded query cache, a mock provider or the project's request mocks.
A fixture threaded through props five levels down tests a path production never takes. Where the only way in is editing the component, say so and ask before adding a seam.
Make the data look like the product. Real-shaped names, timestamps, amounts and the item counts users actually have. Three rows of "Test item" make every state look fine.
Loading and pending states hold still. Keep them pending until the switcher moves, rather than resolving after a timeout.
5. Add the switcher
A grouped list beside the component flips the __state search param, so every state is a link. Where there is no room beside the component, it moves above it as a select with the same groups. The double underscore keeps it clear of any param the app's layout reads. switcher.md holds the spec.
6. Confirm every state renders, then hand over
Load the page once in a browser already at hand and flip through every state. The component shows the mock data, not the real data and not a blank region. Mock data that never appears is the common failure here. Live sync, a cache that refetches over the seed or a server boundary dropping the fixture all cause it. Fix the plumbing before handing over.
With no browser at hand, say so and hand the URL over for the user to check.
Then hand over the URL, the state list and the switcher keys. Stop there. Changing how a state looks is the user's next request, not part of this one.
Re-check every state after each change
After a visual change,
よくある質問
コードが到達できない状態を追加しますか?
いいえ。コードが既に扱っている状態だけを表示します。
実際のページを変更しますか?
いいえ。模擬データを使った使い捨てのページで作業するため、実際のページには手を加えません。
作業が終わった後、テストページは残りますか?
いいえ。作業が終わったら1つの操作で削除できるように作られています。
詳細
作者による元の説明
Renders every state of a component you choose on a throwaway page, with mock data and a switcher, so you can work on each state.
repo: jakubkrehel/skills
人気
- GitHubのスター
- 10k
- ランキング
- #11895
- ライセンス
- MIT
- 更新日
- 2026/11/1
コメント
- …
このリポジトリの他のスキル
better-accessibility
10kインターフェースのキーボード、フォーカス、スクリーンリーダー、フォーム、動きの問題を、WCAG 2.2の基準に照らして確認し、修正します。
better-colors
10kカラーパレットを生成し、トークンに名前を付け、形式を変換し、コントラストを測定して、配色システムを作成・確認します。
better-interface
10k画面やフロー全体を、アクセシビリティ、レイアウト、文章、書体、色、仕上がりの観点から見直し、問題を優先順位付きで並べます。
better-layout
10kグループ分け、整列、読み順、レスポンシブな構造を整え、サイズ変更や翻訳をしても、レイアウトが崩れないことを確かめます。
似ているスキル
angular-developer
280kエージェントがAngularのコードを作成し、プロジェクト構成についてアドバイスできるようにします。新しいプロジェクトの開始、コード部品の作成、パフォーマンスやアクセシビリティの改善に役立ちます。
frontend-a11y
280kエージェントが Web インターフェースを誰にとっても使いやすくするよう支援します。スクリーンリーダーやキーボード操作に対応し、サイトやアプリが適切に動作するようにします。
frontend-patterns
280kエージェントがフロントエンド開発の最新パターンを適用できるようにします。React と Next.js において、パフォーマンスの最適化、状態管理、ベストプラクティスの遵守を行います。