Storybook CLI: Develop, document, and test UI components in isolation
—
Detect and automatically fix compatibility issues, deprecated patterns, and configuration problems. The automigration system provides a comprehensive suite of automated fixes that keep Storybook configurations up-to-date and resolve common issues without manual intervention.
Automatically detect and apply fixes for known compatibility and configuration issues.
storybook automigrate [fixId] [options]
Parameters:
fixId Optional specific fix ID to run
Options:
-y, --yes Skip prompting the user
-n, --dry-run Only check for fixes, do not actually run them
--package-manager <npm|pnpm|yarn1|yarn2|bun> Force package manager
-l, --list List available migrations
-c, --config-dir <dir-name> Directory of Storybook configurations to migrate
-s, --skip-install Skip installing deps
--renderer <renderer-pkg-name> The renderer package for the framework Storybook is using
--skip-doctor Skip doctor checkUsage Examples:
# Run all applicable automigrations
npx storybook automigrate
# List available automigrations
npx storybook automigrate --list
# Run specific automigration by ID
npx storybook automigrate addon-docs-config
# Dry run to see what would be fixed
npx storybook automigrate --dry-run
# Run without prompts
npx storybook automigrate --yes
# Skip dependency installation
npx storybook automigrate --skip-install
# Specify custom config directory
npx storybook automigrate --config-dir .custom-storybook
# Force specific package manager
npx storybook automigrate --package-manager yarn1Automigrations are organized into several categories:
Each fix can have one of several statuses:
enum FixStatus {
SKIPPED = "skipped", // Fix was not applicable
APPLIED = "applied", // Fix was successfully applied
FAILED = "failed", // Fix failed to apply
UNNECESSARY = "unnecessary", // Fix was not needed
CHECK_FAILED = "check_failed" // Pre-check failed
}Handle monorepos and multiple Storybook configurations:
# Automatically discover and migrate all Storybook projects
npx storybook automigrate
# Specify multiple config directories
npx storybook automigrate --config-dir packages/app/.storybook --config-dir packages/lib/.storybookCommon automigrations include:
addon-docs-config - Update addon-docs configurationaddon-controls-config - Migrate addon-controls settingsaddon-actions-config - Update addon-actions configurationremove-addon-interactions - Remove deprecated addon-interactionsreact-vite-config - Update React + Vite configurationnextjs-config - Migrate Next.js Storybook setupangular-config - Update Angular Storybook configurationwebpack5-config - Migrate to Webpack 5main-config-format - Update main.js formatpreview-config-format - Update preview.js formattypescript-config - Fix TypeScript configuration--yes)Preview what fixes would be applied without making changes:
# See what would be fixed
npx storybook automigrate --dry-run
# Dry run for specific fix
npx storybook automigrate addon-docs-config --dry-runAutomigrations are automatically triggered by:
import { doAutomigrate, runAutomigrations } from "@storybook/cli";
/**
* Main automigration entry point
* @param options - Automigration configuration
*/
function doAutomigrate(options: AutofixOptions): Promise<void>;
/**
* Run automigrations across multiple projects
* @param projects - List of project configurations
* @param options - Automigration options
*/
function runAutomigrations(
projects: CollectProjectsSuccessResult[],
options: AutofixOptions
): Promise<AutomigrationResult[]>;
interface AutofixOptions {
fixId?: string;
yes?: boolean;
dryRun?: boolean;
packageManager?: PackageManagerName;
list?: boolean;
configDir?: string;
skipInstall?: boolean;
renderer?: string;
skipDoctor?: boolean;
}
interface AutomigrationResult {
fixId: string;
status: FixStatus;
description?: string;
details?: string;
}
interface Fix {
id: string;
name: string;
description: string;
check: (options: CheckOptions) => Promise<CheckResult>;
run: (options: RunOptions) => Promise<RunResult>;
}Programmatic Examples:
import { doAutomigrate } from "@storybook/cli";
// Run all automigrations programmatically
await doAutomigrate({
yes: true,
dryRun: false,
packageManager: "npm"
});
// Run specific fix programmatically
await doAutomigrate({
fixId: "addon-docs-config",
yes: true
});Create custom automigrations for your specific needs:
interface CustomFix extends Fix {
id: string;
name: string;
description: string;
// Check if fix is applicable
check(options: CheckOptions): Promise<CheckResult>;
// Apply the fix
run(options: RunOptions): Promise<RunResult>;
}Robust error handling with rollback capabilities:
Install with Tessl CLI
npx tessl i tessl/npm-storybook--cli