Set up Storybook with an agent
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 builder, so it isn't available for every framework. See supported frameworks to check yours.
Set up Storybook
Copy this prompt into your agent's chat:
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 preciselyThe agent runs storybook init, which adds Storybook and installs 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:
- Studies your app: reads your entry file, providers, global CSS, data fetching, and portals.
- Configures the preview: adds your providers as decorators and imports your global styles.
- Adds portal roots: if your components render into portals, it adds the root elements in a decorator.
- Mocks only what stories need: it adds MSW only if a story makes network requests, and MockDate only if a story depends on the current date.
- Writes stories: 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.
- Adds play functions where they prove something: interactions, async data, portals, and accessibility. Stories that only show a variant get no play function.
- Tests the stories: runs Vitest on all new stories and fixes the failures, then runs your type checker.
- Cleans up: removes debug code and the example stories that
storybook initadded.
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 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 and look at the new stories.
- Check the main and preview configuration files.
- Remove the
ai-generatedtag 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. - Follow the best practices 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 yourself. To see which frameworks the other skills support, see Connect your agent.
More AI resources
