agentsclimarketplace

Devstone ui storybook standard

Skill k-rf/devstone/.agents/skills/devstone-ui-storybook-standard

UIコンポーネントおよびStorybookの作成と記述に関する標準。Storybookのメタ情報、satisfiesの使用、play関数内でのテスト実装規律を定義します。From its SKILL.md

Install
npx -y skills add k-rf/devstone --skill devstone-ui-storybook-standard

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 1 stars1 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

3.5 KB, as published. Nobody here has run it

Devstone UI Storybook 標準

このスキルは、UIコンポーネントのStory作成およびStorybookを用いた検証における記述ルールを定義し、一貫したフロントエンド開発を維持するためのものです。

1. 原則: UIテストのStorybookへの一元化

UIコンポーネントの単体テストやインタラクションテストは、個別のテストファイル(例: *.spec.tsx)を作らず、Storybookのplay関数内で完結させます。

  • vitest 等を用いた個別の *.spec.tsx の作成は原則禁止します。
  • @storybook/test から within, userEvent, expect などをインポートして、Storyの play 関数内でインタラクションとアサーションを記述します。

play関数の記述例

import { expect, userEvent, within } from "@storybook/test";

export const InteractionTest = {
  play: async ({ canvasElement }) => {
    const canvas = within(canvasElement);

    // 要素の取得と検証
    const button = canvas.getByRole("button", { name: "Click me" });
    await expect(button).toBeInTheDocument();

    // ユーザー操作のシミュレーション
    await userEvent.click(button);

    // 操作後の状態検証
    // ...
  },
} satisfies Story;

2. Storybook メタ情報の記述ルール

2.1. title 指定の廃止

  • Storybook上での表示構造は、ファイルの物理的なディレクトリ構造と自動的に一致させます。
  • ディレクトリ構造とStorybook上のツリーの乖離を防ぐため、メタ情報オブジェクト (meta) 内で title プロパティは指定しません。

2.2. autodocs のグローバル設定

  • すべての Story において自動ドキュメント生成 (autodocs) を有効にします。

  • そのため、各 Story ファイルの meta で tags: ["autodocs"] を指定することは禁止します。

  • グローバルの .storybook/preview.ts の tags に ["autodocs"] を指定してください。

    import type { Preview } from "@storybook/react";
    
    const preview: Preview = {
      // ...
      tags: ["autodocs"],
    };
    
    export default preview;
    

2.3. satisfies キーワードの徹底

  • 型安全性を向上させ、Story定義側でのプロパティ漏れや過不足を検出するため、明示的な型アノテーションではなく TypeScript の satisfies を使用します。

  • const MyStory: Story = ... のようにアノテーションすると、型が StoryObj に固定されて過剰に広い型になってしまいますが、satisfies を使うことで、Storyオブジェクトの具体的な値の型を保持したまま検証できるため、argsの過不足やプロパティの補完が正しく機能します。

  • Metaオブジェクトの定義:

    import { type Meta } from "@storybook/react";
    
    const meta = {
      component: MyComponent,
      // ...
    } satisfies Meta<typeof MyComponent>;
    
    export default meta;
    
  • Storyオブジェクトの定義:

    import { type StoryObj } from "@storybook/react";
    
    type Story = StoryObj<typeof MyComponent>;
    
    export const Default = {
      args: { ... },
    } satisfies Story;
    

Keep looking

Skills are one crate of 608,475. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.