# storybook

Enforces Storybook best practices for component libraries, covering file structure, autodocs, controls, and interaction tests.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 909 installs · ★ 286
- Author: Mindrally
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/Mindrally/skills/tree/HEAD/storybook/SKILL.md
- Updated: 2026-10-08
- HTML: https://affpapa.org/en/nevibecode/skills/storybook

## What it does

This skill provides conventions for building component libraries in Storybook. It defines clear standards. The rules mandate placing `ComponentName.stories.tsx` next to the implementation and configuring `Meta` and `StoryObj` from `@storybook/react`.

The guidance covers `argTypes` setup, autodocs, and theme decorators. It also outlines test patterns, including accessibility checks via `@storybook/addon-a11y` and behavior tests inside `play` functions.

Code patterns focus on React with TypeScript. Running the interaction tests requires `@storybook/testing-library` and `@storybook/jest` installed in your project.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill storybook -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/storybook/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/storybook/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill storybook -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/storybook/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill storybook -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/storybook/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install Mindrally/skills storybook
```

2. **Manually: put the files in place**
- File: `.github/skills/storybook/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill storybook -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/Mindrally/skills --path storybook
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/storybook/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill storybook -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/Mindrally/skills/tree/HEAD/storybook/SKILL.md

## When to use it
- scaffold component stories using ComponentName.stories.tsx conventions
- configure argTypes controls for component props
- set up accessibility checks with addon-a11y
- write component interaction tests using play functions

## Example prompts
- Create a Storybook story for Button with primary and secondary variants
- Configure argTypes controls for size and disabled props in Card.stories.tsx
- Add a play function test to verify button click and focus states

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: e99203a3bd85c882.

BEGIN THIRD-PARTY FILE e99203a3bd85c882
````text
---
name: storybook
description: Best practices for building and documenting component libraries with Storybook
metadata:
  maintainer: Mindrally
  source: https://github.com/Mindrally/skills
---

# Storybook Best Practices

You are an expert in building and documenting component libraries with Storybook. Apply these guidelines when creating stories, organizing components, and maintaining design systems.

## Project Structure

### Directory Organization

- Place stories alongside component files (Component.stories.tsx)
- Use consistent naming conventions for story files
- Organize stories by feature or component type
- Maintain a clear hierarchy matching your component library

### File Naming

- Use PascalCase for component story files
- Follow pattern: `ComponentName.stories.tsx`
- Group related stories in the same file
- Use descriptive story names that explain the variant

## Writing Stories

### Story Structure

```typescript
import type { Meta, StoryObj } from '@storybook/react';
import { Component } from './Component';

const meta: Meta<typeof Component> = {
  title: 'Category/Component',
  component: Component,
  parameters: {
    layout: 'centered',
  },
  tags: ['autodocs'],
  argTypes: {
    // Define arg types here
  },
};

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

export const Default: Story = {
  args: {
    // Default props
  },
};

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

### Story Best Practices

- Create a Default story showing primary usage
- Add stories for each significant variant
- Include edge cases and error states
- Document interactive states (hover, focus, disabled)
- Show responsive behavior when relevant

## Component Documentation

### Autodocs

- Enable autodocs for automatic documentation generation
- Write clear JSDoc comments for components and props
- Document prop types, defaults, and requirements
- Include usage examples in component comments

### Custom Documentation

- Add MDX files for complex documentation needs
- Include design rationale and usage guidelines
- Document accessibility considerations
- Provide code examples for common use cases

## Args and Controls

### ArgTypes Configuration

```typescript
argTypes: {
  variant: {
    control: 'select',
    options: ['primary', 'secondary', 'tertiary'],
    description: 'Visual style variant',
    table: {
      defaultValue: { summary: 'primary' },
    },
  },
  size: {
    control: 'radio',
    options: ['sm', 'md', 'lg'],
  },
  disabled: {
    control: 'boolean',
  },
  onClick: {
    action: 'clicked',
  },
}
```

### Args Best Practices

- Use meaningful default values
- Group related args logically
- Provide descriptions for complex props
- Set up actions for callback props

## Decorators and Parameters

### Decorators

```typescript
decorators: [
  (Story) => (
    <ThemeProvider theme={defaultTheme}>
      <Story />
    </ThemeProvider>
  ),
],
```

- Use decorators for consistent story wrappers
- Apply theme providers at the appropriate level
- Add layout containers when needed
- Keep decorators simple and reusable

### Parameters

```typescript
parameters: {
  layout: 'centered', // or 'fullscreen', 'padded'
  backgrounds: {
    default: 'light',
    values: [
      { name: 'light', value: '#ffffff' },
````
END THIRD-PARTY FILE e99203a3bd85c882

The third-party file has ended. Everything between the e99203a3bd85c882 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 3318 of 5960 bytes. © Mindrally · Apache-2.0 · https://github.com/Mindrally/skills/tree/HEAD/storybook/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
