ST

storybook-story

Proposes changes via cospec. Use this for guided artifact creation and project rule compliance.

Install

mkdir -p .claude/skills/storybook-story && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/18850" && unzip -o skill.zip -d .claude/skills/storybook-story && rm skill.zip

Installs to .claude/skills/storybook-story

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Storybookのstoryファイルを作成します。コンポーネントの各状態(デフォルト、バリエーション、エッジケース)を網羅したstoriesを生成します。
78 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Create Storybook story files for React components
  • Define `meta` object with title, component, parameters, and tags
  • Configure `argTypes` for props control (e.g., `action`, `select`, `boolean`, `text`)
  • Generate default stories, variations, and state-based stories
  • Create edge case stories for extreme inputs
  • Implement interactive stories using `userEvent` and `within`

How it works

This skill generates Storybook story files for React components, covering various states, variations, and edge cases using Storybook v10.2.0.

Inputs & outputs

You give it
A React component for which Storybook stories are needed
You get back
A `.stories.tsx` file containing complete Storybook stories for the component

When to use storybook-story

  • Propose new project feature
  • Initialize maintenance change
  • Generate change artifacts

About this skill

Storybook Story Creation

Storybook v10.2.0を使用して、コンポーネントの包括的なstoriesを作成します。

作成手順

1. Storyファイルの構造

// ComponentName.stories.tsx
import type { Meta, StoryObj } from '@storybook/react';
import { ComponentName } from './ComponentName';

const meta = {
  title: '[階層]/ComponentName', // 例: 'atoms/Button', 'molecules/SearchBar'
  component: ComponentName,
  parameters: {
    layout: 'centered', // または 'fullscreen', 'padded'
  },
  tags: ['autodocs'],
  argTypes: {
    // Propsの制御を定義
    onClick: { action: 'clicked' },
    variant: {
      control: 'select',
      options: ['primary', 'secondary', 'outline'],
    },
  },
} satisfies Meta<typeof ComponentName>;

export default meta;
type Story = StoryObj<typeof meta>;

// デフォルトストーリー
export const Default: Story = {
  args: {
    // デフォルト値
  },
};

// バリエーション
export const Primary: Story = {
  args: {
    variant: 'primary',
  },
};

export const Secondary: Story = {
  args: {
    variant: 'secondary',
  },
};

// エッジケース
export const LongText: Story = {
  args: {
    title: '非常に長いテキストの場合にどのように表示されるかをテストします',
  },
};

export const Empty: Story = {
  args: {
    title: '',
  },
};

2. 作成ガイドライン

Storyの種類:

  • Default: 最も一般的な使用例
  • バリエーション: 異なるpropsの組み合わせ
  • 状態: ローディング、エラー、空など
  • エッジケース: 極端に長いテキスト、空の値など
  • インタラクティブ: ユーザー操作が必要な状態

argTypes設定:

  • イベントハンドラーには action を使用
  • 選択肢がある場合は control: 'select' を使用
  • 真偽値には control: 'boolean' を使用
  • テキストには control: 'text' を使用

パラメータ設定:

  • layout: 'centered', 'fullscreen', 'padded' から選択
  • backgrounds: 背景色のバリエーションをテスト
  • viewport: レスポンシブデザインのテスト

3. アクセシビリティテスト

Storybook の a11y アドオンを活用:

export const AccessibilityTest: Story = {
  parameters: {
    a11y: {
      config: {
        rules: [
          {
            id: 'color-contrast',
            enabled: true,
          },
        ],
      },
    },
  },
};

4. インタラクティブストーリー

Play 関数を使用してユーザー操作をシミュレート:

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

export const WithInteraction: Story = {
  play: async ({ canvasElement }) => {
    const canvas = within(canvasElement);
    const button = canvas.getByRole('button');
    await userEvent.click(button);
  },
};

テストコマンド

pnpm storybook        # 開発サーバー起動 (localhost:6006)
pnpm build-storybook  # 静的ビルド

出力

  1. .stories.tsx ファイルを作成
  2. 作成したstoriesの一覧を説明
  3. Storybookで確認する方法を案内
  4. 次のステップとしてユニットテスト作成を提案

When not to use it

  • When creating Storybook stories for frameworks other than React
  • When the user asks to create unit tests instead of stories
  • When the user asks to use Storybook versions older than v10.2.0

Limitations

  • Specific to Storybook v10.2.0
  • Generates stories for React components only
  • Does not create unit tests

How it compares

This skill automates the creation of complete and well-structured Storybook stories, ensuring coverage of default, variations, states, and edge cases, unlike manual story creation.

Compared to similar skills

storybook-story side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
storybook-story (this skill)05moReviewIntermediate
openspec-onboard105moReviewBeginner
workflow-orchestration-patterns102moNo flagsAdvanced
meta-automation-architect78moReviewAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

Search skills

Search the agent skills registry