CLI options
The Storybook command line interface (CLI) is the main tool you use to build and develop Storybook.
Storybook collects completely anonymous data to help us improve user experience. Participation is optional, and you may opt-out if you'd not like to share any information.
CLI commands
All of the following documentation is available in the CLI by running storybook --help.
Passing options to these commands works slightly differently if you're using npm instead of Yarn.
You must prefix all of your options with --. For example, npm run storybook build -- -o ./path/to/build --quiet.
dev
Compiles and serves a development build of your Storybook that reflects your source code changes in the browser in real-time. It should be run from the root of your project.
storybook dev [options]Options include:
| Option | Description |
|---|---|
--help | Output usage information.storybook dev --help |
-V, --version | Output the version number.storybook dev -V |
-p, --port [number] | Port to run Storybook.storybook dev -p 9009 |
--exact-port | Attempts to run Storybook on the exact port number specified. If the port is already in use, Storybook will exit with an error message. storybook dev -p 9009 --exact-port |
-h, --host [string] | Host to listen on. 127.0.0.1 by default. Setting this to 0.0.0.0 listens on all network interfaces and is insecure.Combine it with core.allowedHosts to restrict which hostnames can be used to reach your Storybook instance.In a container, use 0.0.0.0 with core.allowedHosts, and publish the port on the loopback address only, for example docker run -p 127.0.0.1:6006:6006.storybook dev -h my-host.com |
-c, --config-dir [dir-name] | Storybook configuration directory.storybook dev -c .storybook |
--loglevel [level] | Controls level of logging during build. Available options: trace, debug, info (default), warn, error, silentstorybook dev --loglevel warn |
--https | Serve Storybook over HTTPS. Note: You must provide your own certificate information.storybook dev --https |
--ssl-ca | Provide an SSL certificate authority. (Optional with --https, required if using a self-signed certificate)storybook dev --ssl-ca my-certificate |
--ssl-cert | Provide an SSL certificate. (Required with --https)storybook dev --ssl-cert my-ssl-certificate |
--ssl-key | Provide an SSL key. (Required with --https)storybook dev --ssl-key my-ssl-key |
--smoke-test | Exit after successful start.storybook dev --smoke-test |
--ci | CI mode (skip interactive prompts, don't open browser).storybook dev --ci |
--open | Open Storybook automatically in the browser.storybook dev --open |
--no-open | Deprecated and will be removed in next major version. Accepted for compatibility and ignored with a warning; the browser is not opened. Use --open to opt in. |
--quiet | Suppress verbose build output.storybook dev --quiet |
--debug | Outputs more logs in the CLI to assist debugging.storybook dev --debug |
--debug-webpack | Display final webpack configurations for debugging purposes.storybook dev --debug-webpack |
--stats-json [dir-name] | Write stats JSON to disk. Requires Webpack or Vite storybook dev --stats-json /tmp/stats |
--no-version-updates | Skips Storybook's update check.storybook dev --no-version-updates |
--docs | Starts Storybook in documentation mode. Learn more about it in here.storybook dev --docs |
--initial-path [path] | Configures the URL Storybook should open when it opens the browser for the first time.storybook dev --initial-path=/docs/getting-started--docs |
--disable-telemetry | Disables Storybook's telemetry. Learn more about it here.storybook dev --disable-telemetry |
--enable-crash-reports | Enables sending crash reports to Storybook's telemetry. Learn more about it here.storybook dev --enable-crash-reports |
--preview-only | Skips Storybook's manager from building and opens the app in "preview only" mode, which is designed to be used in unsupported browsers. storybook dev --preview-only |
With the release of Storybook 8, the -s CLI flag was removed. We recommend using the static
directory
instead if you need to serve static files.
build
Compiles your Storybook instance so it can be deployed. It should be run from the root of your project.
storybook build [options]Options include:
| Option | Description |
|---|---|
-h, --help | Output usage information.storybook build --help |
-V, --version | Output the version number.storybook build -V |
-o, --output-dir [dir-name] | Directory where to store built files.storybook build -o /my-deployed-storybook |
-c, --config-dir [dir-name] | Storybook configuration directory.storybook build -c .storybook |
--loglevel [level] | Controls level of logging during build. Available options: trace, debug, info (default), warn, error, silent.storybook build --loglevel warn |
--quiet | Suppress verbose build output.storybook build --quiet |
--debug | Outputs more logs in the CLI to assist debugging.storybook build --debug |
--debug-webpack | Display final webpack configurations for debugging purposes.storybook build --debug-webpack |
--stats-json [dir-name] | Write stats JSON to disk. Requires Webpack or Vite storybook build --stats-json /tmp/stats |
--docs | Builds Storybook in documentation mode. Learn more about it in here.storybook build --docs |
--test | Optimize Storybook's production build for performance and tests by removing unnecessary features with the test option. Learn more here.storybook build --test |
--disable-telemetry | Disables Storybook's telemetry. Learn more about it here.storybook build --disable-telemetry |
--enable-crash-reports | Enables sending crash reports to Storybook's telemetry. Learn more about it here.storybook build --enable-crash-reports |
--preview-only | Skips Storybook's manager from building and produces a "preview only" app, which is designed to be used in unsupported browsers. storybook build --preview-only |
init
We recommend create-storybook for new projects. The init command will
remain available for backwards compatibility.
Installs and initializes the specified version (e.g., @latest, @8, @next) of Storybook into your project. If no version is specified, the latest version is installed. Read more in the installation guide.
storybook[@version] init [options]For example, storybook@8.4 init will install Storybook 8.4 into your project.
Options include:
| Option | Description |
|---|---|
-h, --help | Output usage information.storybook init --help |
-b, --builder | Defines the builder to use for your Storybook instance.storybook init --builder webpack5 |
-f, --force | Forcefully installs Storybook into your project, prompting you to overwrite existing files.storybook init --force |
-s, --skip-install | Skips the dependency installation step. Used only when you need to configure Storybook manually.storybook init --skip-install |
--install-typescript | Adds typescript@^6 to devDependencies without asking, when the project has none. Storybook uses it to read component types for Controls and the Docs args table. Without the flag, init asks, or adds it with --yes, in CI and without a terminal.storybook init --install-typescript |
--no-install-typescript | Does not add or upgrade typescript, and does not ask.storybook init --no-install-typescript |
-t, --type | Defines the framework to use for your Storybook instance.storybook init --type solid |
-y, --yes | Skips interactive prompts and automatically installs Storybook per specified version, including all features.storybook init --yes |
--features [...values] | Use these features when installing, skipping the prompt: docs, test, a11y, and ai (agent skills, plus the setup prompt on Vite projects with React, Vue, or Angular), space separated.storybook init --features docs test a11y |
--package-manager | Sets the package manager to use when installing Storybook. Available package managers include npm, yarn, and pnpm.storybook init --package-manager pnpm |
--debug | Outputs more logs in the CLI to assist debugging.storybook init --debug |
--disable-telemetry | Disables Storybook's telemetry. Learn more about it here.storybook init --disable-telemetry |
--enable-crash-reports | Enables sending crash reports to Storybook's telemetry. Learn more about it here.storybook init --enable-crash-reports |
--loglevel <level> | Controls level of logging during initialization. Available options: trace, debug, info (default), warn, error, silentstorybook init --loglevel debug |
--logfile [path] | Write all debug logs to the specified file at the end of the run. Defaults to debug-storybook.log when [path] is not provided.storybook init --logfile /tmp/debug-storybook.log |
--no-dev | Complete the initialization of Storybook without running the Storybook dev server.storybook init --no-dev |
--agent | Forces agent mode when no AI agent is detected: skips prompts (like --yes), writes a debug log, and skips the dev server. If the ai setup prompt applies, tells the agent to run storybook skills setup.storybook init --agent |
--no-agent | Disables agent mode, even when Storybook detects an AI agent.storybook init --no-agent |
add
Installs a Storybook addon and configures your project for it. Read more in the addon installation guide.
storybook add [addon] [options]Options include:
| Option | Description |
|---|---|
-h, --help | Output usage information.storybook add --help |
-c, --config-dir [dir-name] | Storybook configuration directory.storybook add --config-dir .storybook |
--package-manager | Sets the package manager to use when installing the addon. Available package managers include npm, yarn, and pnpm.storybook add [addon] --package-manager pnpm |
-s, --skip-postinstall | Skips post-install configuration. Used only when you need to configure the addon yourself.storybook add [addon] --skip-postinstall |
--debug | Outputs more logs in the CLI to assist debugging.storybook add --debug |
--loglevel <level> | Controls level of logging during addon installation. Available options: trace, debug, info (default), warn, error, silentstorybook add [addon] --loglevel debug |
--logfile [path] | Write all debug logs to the specified file at the end of the run. Defaults to debug-storybook.log when [path] is not provided.storybook add [addon] --logfile /tmp/debug-storybook.log |
remove
Deletes a Storybook addon from your project. Read more in the addon installation guide.
storybook remove [addon] [options]Options include:
| Option | Description |
|---|---|
-h, --help | Output usage information.storybook remove --help |
--package-manager | Sets the package manager to use when removing the addon. Available package managers include npm, yarn, and pnpm.storybook remove [addon] --package-manager pnpm |
--debug | Outputs more logs in the CLI to assist debugging.storybook remove --debug |
--disable-telemetry | Disables Storybook's telemetry. Learn more about it here.storybook remove --disable-telemetry |
--enable-crash-reports | Enables sending crash reports to Storybook's telemetry. Learn more about it here.storybook remove --enable-crash-reports |
upgrade
Upgrades your Storybook instance to the specified version (e.g., @latest, @8, @next). Read more in the upgrade guide.
storybook[@version] upgrade [options]For example, storybook@latest upgrade --dry-run will perform a dry run (no actual changes) of upgrading your project to the latest version of Storybook.
Options include:
| Option | Description |
|---|---|
-h, --help | Output usage information.storybook upgrade --help |
-c, --config-dir <dir-name...> | Directory or directories to find Storybook configurationsstorybook upgrade --config-dir .storybook |
-n, --dry-run | Checks for version upgrades without installing them.storybook upgrade --dry-run |
-s, --skip-check | Skips the migration check step during the upgrade process.storybook upgrade --skip-check |
--skip-automigrations | Skips running automigrations entirely, only updating package versions and installing them.storybook upgrade --skip-automigrations |
-y, --yes | Skips interactive prompts and automatically upgrades Storybook to the latest version. Migrations that require a deliberate opt-in, such as framework migrations and experimental feature flags, are not run; use --features to include them.storybook upgrade --yes |
--features <list> | Preselects the automigrations that enable the listed experimental feature flags. Other detected automigrations are still offered as usual. Cannot be combined with --skip-automigrations.No experimental feature flag currently offers one. |
-f,--force | Force the upgrade, skipping autoblockers check.storybook upgrade --force |
--package-manager | Sets the package manager to use when upgrading Storybook. Available package managers include npm, yarn, and pnpm.storybook upgrade --package-manager pnpm |
--debug | Outputs more logs in the CLI to assist debugging.storybook upgrade --debug |
--disable-telemetry | Disables Storybook's telemetry. Learn more about it here.storybook upgrade --disable-telemetry |
--enable-crash-reports | Enables sending crash reports to Storybook's telemetry. Learn more about it here.storybook upgrade --enable-crash-reports |
--logfile [path] | Write all debug logs to the specified file at the end of the run. Defaults to debug-storybook.log when [path] is not provided.storybook upgrade --logfile /tmp/debug-storybook.log |
--loglevel <level> | Define log level: debug, error, info, silent, trace, or warn (default: info).storybook upgrade --loglevel debug |
migrate
Runs the provided codemod to ensure your Storybook project is compatible with the specified version. Read more in the migration guide.
storybook[@version] migrate [codemod] [options]The command requires the codemod name (e.g., csf-2-to-3) as an argument to apply the necessary
changes to your project. You can find the list of available codemods by running storybook migrate --list.
For example, storybook@latest migrate csf-2-to-3 --dry-run runs the codemod without writing any files, and reports how many files it would change.
Options include:
| Option | Description |
|---|---|
-h, --help | Output usage information.storybook migrate --help |
-c, --config-dir [dir-name] | Storybook configuration directory.storybook migrate --config-dir .storybook |
-n, --dry-run | Runs the codemod without writing files, and reports how many files it would change.storybook migrate --dry-run |
-l, --list | Shows a list of available codemods.storybook migrate --list |
-g, --glob | Glob for files upon which to apply the codemods.storybook migrate --glob src/**/*.stories.tsx |
-r, --rename [from-to] | Renames the files affected by the codemod to include the provided suffix.storybook migrate --rename ".js:.ts" |
--debug | Outputs more logs in the CLI to assist debugging.storybook migrate --debug |
automigrate
Perform standard configuration checks to determine if your Storybook project can be automatically migrated to the specified version. Read more in the migration guide.
storybook[@version] automigrate [fixId] [options]For example, storybook@latest automigrate --dry-run scans your project for potential migrations that can be applied automatically without making any changes.
Options include:
| Option | Description |
|---|---|
-h, --help | Output usage information.storybook automigrate --help |
-c, --config-dir [dir-name] | Storybook configuration directory.storybook automigrate --config-dir .storybook |
-n, --dry-run | Checks for available migrations without applying them.storybook automigrate --dry-run |
-s, --skip-install | Skip installing dependencies whenever applicable.storybook automigrate --skip-install |
-y, --yes | Applies available migrations automatically without prompting for confirmation.storybook automigrate --yes |
-l, --list | Shows a list of available automigrations.storybook automigrate --list |
--package-manager | Sets the package manager to use when running the auto migration. Available package managers include npm, yarn, and pnpm.storybook automigrate --package-manager pnpm |
--debug | Outputs more logs in the CLI to assist debugging.storybook automigrate --debug |
--disable-telemetry | Disables Storybook's telemetry. Learn more about it here.storybook automigrate --disable-telemetry |
--enable-crash-reports | Enables sending crash reports to Storybook's telemetry. Learn more about it here.storybook automigrate --enable-crash-reports |
doctor
Performs a health check on your Storybook project for common issues (e.g., duplicate dependencies, incompatible addons or mismatched versions) and provides suggestions on how to fix them. Applicable when upgrading Storybook versions.
storybook doctor [options]Options include:
| Option | Description |
|---|---|
-h, --help | Output usage information.storybook doctor --help |
-c, --config-dir [dir-name] | Storybook configuration directory.storybook doctor --config-dir .storybook |
--package-manager | Sets the package manager to use when running the health check. Available package managers include npm, yarn, and pnpm.storybook doctor --package-manager pnpm |
--debug | Outputs more logs in the CLI to assist debugging.storybook doctor --debug |
skills
This command is experimental. Its options and output may change in future releases.
Prints instructions for AI agents as Markdown, tailored to your Storybook configuration. This command is built for agents: the skills installed in your project run it and follow the result.
storybook skills [options] [id]Available skills:
| ID | Instructions for |
|---|---|
component-docs | Looking up components, with their props and usage, to reuse them or answer questions about them |
write-stories | Writing the stories of a component: imports, play functions, and mocks |
test-stories | Running the story tests, with their accessibility checks, and fixing what fails |
ui-review | Finding the stories a change affects and publishing a review of them |
setup | Configuring Storybook and writing the first stories. See skills setup |
Run storybook skills --help to list the available skills.
Options include:
| Option | Description |
|---|---|
-h, --help | Output usage information and the list of skills.storybook skills --help |
--cwd <path> | Project directory of the target Storybook.storybook skills ui-review --cwd packages/ui |
-c, --config-dir <dir-name> | Storybook configuration directory.storybook skills setup -c .storybook |
--all | Print every skill in full.storybook skills --all |
--mcp | Name the tools of the Storybook MCP server instead of CLI commands.storybook skills ui-review --mcp |
--disable-telemetry | Disables Storybook's telemetry. Learn more about it here.storybook skills setup --disable-telemetry |
--debug | Outputs more logs in the CLI to assist debugging.storybook skills setup --debug |
--loglevel <level> | Controls level of logging. Available options: trace, debug, info (default), warn, error, silent.storybook skills setup --loglevel warn |
--logfile [path] | Write all debug logs to the specified file at the end of the run. Defaults to debug-storybook.log when [path] is not provided.storybook skills setup --logfile /tmp/debug-storybook.log |
skills setup
Generates a detailed, project-aware Markdown prompt that instructs an AI agent to configure Storybook in your project and write initial stories for real components. The prompt is built from your detected Storybook configuration (framework, renderer, builder, language, addons) and covers analyzing the codebase, configuring the preview, mocking side effects, writing stories, and verifying them with Vitest.
storybook skills setup is currently only available for projects using the React, Angular, or Vue renderer with the Vite builder.
storybook skills setup [options]Run it from the directory where you start Storybook, so the running Storybook can tell that setup ran and complete the "Set up with AI" checklist item.
The generated prompt is printed to stdout. To hand it to an agent that doesn't have shell access, redirect it to a file, for example storybook skills setup > storybook-setup.md.
tools
This command is experimental. Its options and output may change in future releases.
Runs the tools that AI agents use to work with your Storybook: look up component docs, find stories, run tests, and publish reviews. This command is built for agents, and the skills tell them how to use it. It offers the same tools as the MCP server.
storybook tools [options] [toolset] [tool] [args...]Most tools load your Storybook configuration and run without a dev server. Tools marked "requires running Storybook" need a running dev server. Start it first.
| Command | Description | Runs |
|---|---|---|
docs list | Lists all components and docs entries, with their IDs. | Local |
docs show | Shows the props and usage examples of one component or docs entry. | Local |
docs show-story | Shows the code and documentation of one story. | Local |
stories changed | Lists the stories that are new, modified, or affected by uncommitted changes. | Local |
stories find-by-component | Lists the stories that render the given component files. | Local |
stories preview | Returns preview URLs for the given stories. | Requires running Storybook |
review create | Publishes an agentic review of the given stories. | Requires running Storybook |
test run | Runs story tests, with accessibility checks if set up. | Local |
Pass tool arguments as --key value flags, or all at once as a JSON object with --input. Run storybook tools <toolset> <tool> --help to see a tool's description, arguments, and --json output.
Options include:
| Option | Description |
|---|---|
-h, --help | List the tools of the target Storybook, or show one tool with its arguments.storybook tools docs show --help |
--cwd <path> | Project directory of the target Storybook.storybook tools docs list --cwd packages/ui |
-c, --config-dir <dir-name> | Storybook configuration directory of the target Storybook.storybook tools docs list -c .storybook |
-p, --port <number> | Port of a running Storybook. Targets that instance directly, without --cwd or --config-dir.storybook tools stories preview --port 6007 ... |
--attach | Require a running Storybook. Fails instead of loading the configuration locally.storybook tools test run --attach |
--no-attach | Load the project configuration without attaching to a running Storybook.storybook tools test run --no-attach |
--input <object> | Raw JSON object with the tool arguments. Individual --key value flags override its entries.storybook tools docs show --input '{"id":"button"}' |
--json | Print the tool's structured result as JSON instead of Markdown.storybook tools docs list --json |
-o, --output <path> | Write the result to a file instead of stdout.storybook tools docs list -o components.md |
info
Reports useful debugging information about your environment. Helpful in providing information when opening an issue or a discussion.
storybook infoExample output:
Storybook Environment Info:
System:
OS: macOS 14.2
CPU: (8) arm64 Apple M3
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.19.0 - ~/.nvm/versions/node/v18.19.0/bin/node
npm: 10.2.3 - ~/.nvm/versions/node/v18.19.0/bin/npm <----- active
Browsers:
Chrome: 120.0.6099.199
npmPackages:
@storybook/addon-onboarding: ^1.0.10 => 1.0.10
@storybook/react: ^7.6.6 => 7.6.6
@storybook/react-vite: ^7.6.6 => 7.6.6
storybook: ^7.6.6 => 7.6.6
npmGlobalPackages:
chromatic: ^10.2.0 => 10.2.0index
Build an index.json that lists all stories and docs entries in your Storybook.
storybook index [options]Options include:
| Option | Description |
|---|---|
-o, --output-file <file-name> | JSON file to output index |
-c, --config-dir <dir-name> | Storybook configuration directory |
--quiet | Suppress verbose build output |
--loglevel <level> | Control level of logging during build |
--disable-telemetry | Disables Storybook's telemetry |
--debug | Outputs more logs in the CLI to assist debugging. |
--enable-crash-reports | Enables sending crash reports to Storybook's telemetry |
sandbox
Generates a local sandbox project using the specified version (e.g., @latest, @8, @next) for testing Storybook features based on the list of supported frameworks. Useful for reproducing bugs when opening an issue or a discussion.
storybook[@version] sandbox [framework-filter] [options]For example, storybook@next sandbox will generated sandboxes using the newest pre-release version of Storybook.
The framework-filter argument is optional and can filter the list of available frameworks. For example, storybook@next sandbox react will only offer to generate React-based sandboxes.
Options include:
| Option | Description |
|---|---|
-h, --help | Output usage information.storybook sandbox --help |
-o, --output [dir-name] | Configures the location of the sandbox project.storybook sandbox --output /my-sandbox-project |
--no-init | Generates a sandbox project without initializing Storybook.storybook sandbox --no-init |
--debug | Outputs more logs in the CLI to assist debugging.storybook sandbox --debug |
--disable-telemetry | Disables Storybook's telemetry. Learn more about it here.storybook sandbox --disable-telemetry |
--enable-crash-reports | Enables sending crash reports to Storybook's telemetry. Learn more about it here.storybook sandbox --enable-crash-reports |
If you're looking for a hosted version of the available sandboxes, see storybook.new.
create-storybook
To streamline the process of creating a new Storybook project, a separate CLI called create-storybook is provided. Package managers such as npm, pnpm, and Yarn will execute this command when running create storybook. You can specify a version (e.g., @latest, @8, @next) or it will default to the latest version. Read more in the installation guide.
create storybook[@version] [options]For example, create storybook@8.6 will install Storybook 8.6 into your project.
Options include:
| Option | Description |
|---|---|
-h, --help | Output usage information.create storybook --help |
-b, --builder | Defines the builder to use for your Storybook instance.create storybook --builder webpack5 |
-f, --force | Forcefully installs Storybook into your project, prompting you to overwrite existing files.create storybook --force |
-s, --skip-install | Skips the dependency installation step. Used only when you need to configure Storybook manually.create storybook --skip-install |
--install-typescript | Adds typescript@^6 to devDependencies without asking, when the project has none. Storybook uses it to read component types for Controls and the Docs args table. Without the flag, init asks, or adds it with --yes, in CI and without a terminal.create storybook --install-typescript |
--no-install-typescript | Does not add or upgrade typescript, and does not ask.create storybook --no-install-typescript |
-t, --type | Defines the framework to use for your Storybook instance.create storybook --type solid |
-y, --yes | Skips interactive prompts and automatically installs Storybook per specified version, including all features.create storybook --yes |
--features [...values] | Use these features when installing, skipping the prompt: docs, test, a11y, and ai (agent skills, plus the setup prompt on Vite projects with React, Vue, or Angular), space separated.create storybook --features docs test a11y |
--package-manager | Sets the package manager to use when installing Storybook. Available package managers include npm, yarn, and pnpm.create storybook --package-manager pnpm |
--debug | Outputs more logs in the CLI to assist debugging.create storybook --debug |
--disable-telemetry | Disables Storybook's telemetry. Learn more about it here.create storybook --disable-telemetry |
--enable-crash-reports | Enables sending crash reports to Storybook's telemetry. Learn more about it here.create storybook --enable-crash-reports |
--loglevel <level> | Controls level of logging during initialization. Available options: trace, debug, info (default), warn, error, silentcreate storybook --loglevel debug |
--logfile [path] | Write all debug logs to the specified file at the end of the run. Defaults to debug-storybook.log when [path] is not provided.create storybook --logfile /tmp/debug-storybook.log |
--no-dev | Complete the initialization of Storybook without running the Storybook dev server.create storybook --no-dev |
