> **Version 11 (RC)** — **React** / **TypeScript**
> Also available:
- `?codeOnly=true` for code snippets only
- other versions: Version 10.6 (latest) (`/docs/ai/skills/setup.md`), Version 9 (`/docs/9/ai/skills/setup.md`), Version 8 (`/docs/8/ai/skills/setup.md`)

# Set up Storybook with an agent

The setup skill lets your agent configure Storybook for your project and write the first stories. It isn't available for your framework yet.

Your agent can add Storybook to your project, configure it to render your components, and write the first stories. Configuring Storybook for an existing app is repetitive, project-specific work, and agents do it well.

The setup skill needs the [Vite](https://storybook.js.org/docs/11/builders/vite.md) builder, so it isn't available for every framework. See [supported frameworks](#supported-frameworks) to check yours.

## Set up Storybook

Copy this prompt into your agent's chat:

```shell
Set up Storybook for me with npm create storybook@latest (or pnpm --allow-build=esbuild create storybook@latest if this project uses pnpm, or yarn create storybook@latest if it uses yarn) and follow its instructions precisely
```

The agent runs [`storybook init`](https://storybook.js.org/docs/11/api/cli-options.md#init), which adds Storybook and [installs the skills](https://storybook.js.org/docs/11/ai/connect.md#install-the-skills). Then the agent follows the instructions from the `/storybook-setup` skill to configure Storybook for your project.

If Storybook is already installed, ask your agent to "Use the /storybook-setup skill". If your project uses a version of Storybook older than 11, the agent asks you before it upgrades.

## What the agent does

The setup skill gives your agent instructions for your framework, renderer, language, and package manager. The agent:

1. **Studies your app:** reads your entry file, providers, global CSS, data fetching, and portals.
2. **Configures the [preview](https://storybook.js.org/docs/11/configure/story-rendering.md):** adds your providers as [decorators](https://storybook.js.org/docs/11/writing-stories/decorators.md) and imports your [global styles](https://storybook.js.org/docs/11/configure/styling-and-css.md).
3. **Adds portal roots:** if your components render into portals, it adds the root elements in a decorator.
4. **Mocks only what stories need:** it adds [MSW](https://storybook.js.org/docs/11/writing-stories/mocking-data-and-modules/mocking-network-requests.md) only if a story makes network requests, and MockDate only if a story depends on the current date.
5. **Writes [stories](https://storybook.js.org/docs/11/writing-stories.md):** up to 10 story files, from simple components to pages. It adds a story to an existing story file instead of writing a second one.
6. **Adds [play functions](https://storybook.js.org/docs/11/writing-stories/play-function.md) where they prove something:** interactions, async data, portals, and accessibility. Stories that only show a variant get no play function.
7. **Tests the stories:** runs [Vitest](https://storybook.js.org/docs/11/writing-tests/integrations/vitest-addon.md) on all new stories and fixes the failures, then runs your type checker.
8. **Cleans up:** removes debug code and the example stories that `storybook init` added.

The agent changes your existing stories, components, and configuration only to add to them. It doesn't delete or rewrite them.

## Check the result

The agent [tags](https://storybook.js.org/docs/11/writing-stories/tags.md) each story file it writes:

- `ai-generated`: the agent wrote this file.
- `needs-work`: the agent couldn't make the stories in this file pass. Fix them yourself or ask your agent to try again.

The agent also adds one `CssCheck` story. Its play function checks a computed style from your components, which proves that the preview loads your styles.

Then:

- [Run Storybook](https://storybook.js.org/docs/11/get-started/install.md#start-storybook) and look at the new stories.
- Check the [main](https://storybook.js.org/docs/11/configure/index.md#configure-your-storybook-project) and [preview](https://storybook.js.org/docs/11/configure/index.md#configure-story-rendering) configuration files.
- Remove the `ai-generated` tag from each story file after you review it.

## Next steps

- Ask your agent to change some UI. It follows the [Storybook section in `AGENTS.md`](https://storybook.js.org/docs/11/ai/agents-md.md).
- Follow the [best practices](https://storybook.js.org/docs/11/ai/best-practices.md) to make your stories and docs more useful to people and agents.

## Supported frameworks

The setup skill is available for these frameworks:

| Renderer | Frameworks                                    |
| -------- | --------------------------------------------- |
| React    | `react-vite`, `nextjs-vite`, `tanstack-react` |
| Vue 3    | `vue3-vite`                                   |
| Angular  | `angular-vite`                                |

For other frameworks, [install Storybook](https://storybook.js.org/docs/11/get-started/install.md) yourself. To see which frameworks the other skills support, see [Connect your agent](https://storybook.js.org/docs/11/ai/connect.md#supported-frameworks).

**More AI resources**

- [Connect your agent](https://storybook.js.org/docs/11/ai/connect.md)
- [The AGENTS.md section](https://storybook.js.org/docs/11/ai/agents-md.md)
- [Component docs](https://storybook.js.org/docs/11/ai/skills/component-docs.md)
- [Write stories](https://storybook.js.org/docs/11/ai/skills/write-stories.md)
- [Test stories](https://storybook.js.org/docs/11/ai/skills/test-stories.md)
- [UI review](https://storybook.js.org/docs/11/ai/skills/ui-review.md)
- [Best practices for using Storybook with AI](https://storybook.js.org/docs/11/ai/best-practices.md)