Skip to content

Documentation: Add agentic flow and storybook ai command docs#34560

Merged
kylegach merged 5 commits into
project/sb-agentic-setupfrom
yann/storybook-ai-api-docs
Apr 17, 2026
Merged

Documentation: Add agentic flow and storybook ai command docs#34560
kylegach merged 5 commits into
project/sb-agentic-setupfrom
yann/storybook-ai-api-docs

Conversation

@yannbf
Copy link
Copy Markdown
Member

@yannbf yannbf commented Apr 16, 2026

Closes #

What I did

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

Caution

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • New Features

    • Added an "Agentic setup" workflow for AI-assisted Storybook configuration with agent- and user-initiated modes and an option to write setup output to a file or stdout.
    • Introduced a top-level "ai" CLI with an ai setup subcommand and options for output path, telemetry opt-out, logging, and config selection.
  • Documentation

    • Added comprehensive "Agentic setup" docs, CLI reference, and usage snippets for multiple package managers.

@yannbf yannbf self-assigned this Apr 16, 2026
@yannbf yannbf requested a review from kylegach as a code owner April 16, 2026 10:16
@yannbf yannbf added the ci:docs Run the CI jobs for documentation checks only. label Apr 16, 2026
@yannbf yannbf requested a review from jonniebigodes as a code owner April 16, 2026 10:16
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 16, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 82fa8aa1-80ff-4bc5-9c25-21b028a06af8

📥 Commits

Reviewing files that changed from the base of the PR and between 809ba4e and a6355f4.

📒 Files selected for processing (7)
  • docs/ai/best-practices.mdx
  • docs/ai/index.mdx
  • docs/ai/manifests.mdx
  • docs/ai/mcp/api.mdx
  • docs/ai/mcp/overview.mdx
  • docs/ai/mcp/sharing.mdx
  • docs/api/cli-options.mdx
✅ Files skipped from review due to trivial changes (7)
  • docs/ai/mcp/api.mdx
  • docs/ai/best-practices.mdx
  • docs/ai/manifests.mdx
  • docs/ai/index.mdx
  • docs/ai/mcp/sharing.mdx
  • docs/ai/mcp/overview.mdx
  • docs/api/cli-options.mdx

📝 Walkthrough

Walkthrough

Adds documentation and CLI reference for a new "Agentic setup" workflow: a new docs/ai/setup.mdx page, links to it from multiple AI docs pages, a CLI reference for storybook ai setup in docs/api/cli-options.mdx, and a snippet docs/_snippets/ai-setup-output.md. All changes are documentation-only.

Changes

Cohort / File(s) Summary
AI Docs & Setup page
docs/ai/setup.mdx, docs/ai/index.mdx, docs/ai/best-practices.mdx
Added new setup.mdx describing the agent- and user-initiated storybook ai setup workflow (React+Vite scope note, telemetry opt-out, verification steps, next steps). Added links to it from AI index and best-practices pages.
AI Manifests / MCP nav
docs/ai/manifests.mdx, docs/ai/mcp/api.mdx, docs/ai/mcp/overview.mdx, docs/ai/mcp/sharing.mdx
Inserted “Agentic setup” navigation entries linking to setup.mdx across manifests and MCP docs.
CLI Reference
docs/api/cli-options.mdx
Documented top-level storybook ai command and new ai setup subcommand with options (--output, -c/--config-dir, --package-manager, --disable-telemetry, --debug, --loglevel, --logfile) and stdout vs file output behavior.
Snippets
docs/_snippets/ai-setup-output.md
Added shell examples showing storybook ai setup --output storybook-setup.md for npm, pnpm, and yarn.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
docs/ai/setup.mdx (1)

1-85: Consider a companion update to AGENTS.md for the new agentic workflow.

This page introduces new agent workflow/command guidance (storybook ai setup). To keep agent instructions canonical, add (or link) the same expectations in AGENTS.md so contributors and coding agents don’t diverge.

Based on learnings: Keep AGENTS.md up to date when Storybook's architecture, tooling, workflows, or contributor guidance changes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/ai/setup.mdx` around lines 1 - 85, Add a companion section or link in
AGENTS.md that mirrors the new agentic setup guidance in docs/ai/setup.mdx:
document the "storybook ai setup" command and its --output and
--disable-telemetry options, the expected agent workflow (agent-run vs
user-run), the post-run expectations (tagging generated stories with
"ai-generated" and "needs-work", running Vitest/type checks), how the Storybook
MCP server integrates post-setup, and guidance for keeping AGENTS.md synced with
future changes so contributors and coding agents remain canonical.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/api/cli-options.mdx`:
- Line 311: The docs entry for the logfile CLI option incorrectly shows a
required argument (`--logfile <path>`); update the table row in
docs/api/cli-options.mdx to match the CLI definition which uses an optional path
(`--logfile [path]`) and keep the descriptive text and example usage consistent
with optional semantics (e.g., `storybook ai setup --logfile ./sb.log`). Ensure
the documented flag text exactly matches the CLI option string `--logfile
[path]` used in the run.ts CLI definition.
- Around line 293-295: Update the docs to match the current CLI gating: change
the Callout text for `storybook ai setup` to state the command is available for
projects using the React renderer OR the Vite builder (i.e., either condition),
since the CLI check in the ai command uses the isReact / isVite gating logic
(see the check in ai/index.ts that currently combines those flags) — this keeps
docs accurate until the CLI gating (the boolean check around isReact/isVite in
the ai setup handler) is fixed.

---

Nitpick comments:
In `@docs/ai/setup.mdx`:
- Around line 1-85: Add a companion section or link in AGENTS.md that mirrors
the new agentic setup guidance in docs/ai/setup.mdx: document the "storybook ai
setup" command and its --output and --disable-telemetry options, the expected
agent workflow (agent-run vs user-run), the post-run expectations (tagging
generated stories with "ai-generated" and "needs-work", running Vitest/type
checks), how the Storybook MCP server integrates post-setup, and guidance for
keeping AGENTS.md synced with future changes so contributors and coding agents
remain canonical.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d4a9139f-869c-4b56-b593-0f2d0eefb7fe

📥 Commits

Reviewing files that changed from the base of the PR and between 7821847 and c473959.

📒 Files selected for processing (3)
  • docs/ai/index.mdx
  • docs/ai/setup.mdx
  • docs/api/cli-options.mdx

Comment thread docs/api/cli-options.mdx
Comment on lines +293 to +295
<Callout variant="info">
`storybook ai setup` is currently only available for projects using the React renderer with the Vite builder.
</Callout>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Availability statement does not match current command gating logic.

Line 294 says ai setup is only available for React+Vite, but code/lib/cli-storybook/src/ai/index.ts (Lines 69-85) currently checks with &&, which allows execution when either side matches. This will mislead users about what is actually blocked.

Suggested doc-side mitigation (until CLI check is corrected)
-  `storybook ai setup` is currently only available for projects using the React renderer with the Vite builder.
+  `storybook ai setup` is intended for projects using the React renderer with the Vite builder.
+  If your project uses a different setup, behavior may be limited while support is expanded.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Callout variant="info">
`storybook ai setup` is currently only available for projects using the React renderer with the Vite builder.
</Callout>
<Callout variant="info">
`storybook ai setup` is intended for projects using the React renderer with the Vite builder.
If your project uses a different setup, behavior may be limited while support is expanded.
</Callout>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/api/cli-options.mdx` around lines 293 - 295, Update the docs to match
the current CLI gating: change the Callout text for `storybook ai setup` to
state the command is available for projects using the React renderer OR the Vite
builder (i.e., either condition), since the CLI check in the ai command uses the
isReact / isVite gating logic (see the check in ai/index.ts that currently
combines those flags) — this keeps docs accurate until the CLI gating (the
boolean check around isReact/isVite in the ai setup handler) is fixed.

Comment thread docs/api/cli-options.mdx Outdated
Comment thread docs/ai/setup.mdx Outdated
- Remove redundant sidebar.title, em dashes, and npx prefix
- Add "Starting from storybook init" section
- Reduce intro/detail redundancy with anchor link
- Replace inline code block with CodeSnippets for package manager variants
- Add cross-references to decorators, preview, MSW, stories, tags, play functions, Vitest
- Wrap telemetry note in callout
- Clarify cli-options.mdx link text and prose

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@kylegach kylegach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the great start, @yannbf!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (2)
docs/api/cli-options.mdx (2)

293-295: ⚠️ Potential issue | 🟠 Major

Availability statement is stricter than current CLI gating behavior.

Line 294 says React with Vite only, but the current guard in code/lib/cli-storybook/src/ai/index.ts uses renderer != react && builder != vite, which allows execution when either side matches. This can mislead users until the CLI condition is tightened.

Suggested doc-side mitigation
-  `storybook ai setup` is currently only available for projects using the React renderer with the Vite builder.
+  `storybook ai setup` is intended for projects using the React renderer with the Vite builder.
+  If your project uses a different setup, behavior may be limited while support is expanded.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/api/cli-options.mdx` around lines 293 - 295, The doc statement is too
strict compared to the CLI gate: the CLI uses the condition `renderer != react
&& builder != vite` (in the AI setup logic) which means the command `storybook
ai setup` is allowed when either the renderer is React OR the builder is Vite;
update the callout text in docs/api/cli-options.mdx so it reflects that
availability (e.g., "currently available for projects using the React renderer
or the Vite builder") to match the existing check `renderer != react && builder
!= vite`.

311-311: ⚠️ Potential issue | 🟡 Minor

Use optional arg shape for --logfile to match CLI semantics.

Line 311 documents --logfile <path> as required. This should be [path] (optional) to stay consistent with the CLI option shape and default logfile behavior documented elsewhere in this page.

Proposed fix
-| `--logfile <path>`              | Write debug logs to a file.<br />`storybook ai setup --logfile ./sb.log`                                                                                                 |
+| `--logfile [path]`              | Write debug logs to a file. Defaults to `debug-storybook.log` when no path is provided.<br />`storybook ai setup --logfile ./sb.log`                                   |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/api/cli-options.mdx` at line 311, The documentation entry for the CLI
option `--logfile` currently shows a required arg shape (`--logfile <path>`) but
the CLI treats it as optional; update the table cell for `--logfile` to use the
optional arg shape (`--logfile [path]`) and keep the existing example and
description intact so it matches the actual `--logfile` semantics and default
logfile behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@docs/api/cli-options.mdx`:
- Around line 293-295: The doc statement is too strict compared to the CLI gate:
the CLI uses the condition `renderer != react && builder != vite` (in the AI
setup logic) which means the command `storybook ai setup` is allowed when either
the renderer is React OR the builder is Vite; update the callout text in
docs/api/cli-options.mdx so it reflects that availability (e.g., "currently
available for projects using the React renderer or the Vite builder") to match
the existing check `renderer != react && builder != vite`.
- Line 311: The documentation entry for the CLI option `--logfile` currently
shows a required arg shape (`--logfile <path>`) but the CLI treats it as
optional; update the table cell for `--logfile` to use the optional arg shape
(`--logfile [path]`) and keep the existing example and description intact so it
matches the actual `--logfile` semantics and default logfile behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 57f76c3a-8e4d-4cdf-86f9-b60b677393ca

📥 Commits

Reviewing files that changed from the base of the PR and between c473959 and 2ec3044.

📒 Files selected for processing (3)
  • docs/_snippets/ai-setup-output.md
  • docs/ai/setup.mdx
  • docs/api/cli-options.mdx
✅ Files skipped from review due to trivial changes (2)
  • docs/_snippets/ai-setup-output.md
  • docs/ai/setup.mdx

* project/sb-agentic-setup: (103 commits)
  CLI: Change mock event detection
  fix tests
  fix tests
  Ensure process termination on signal when telemetry is disabled
  Add story with changeDetection disabled
  skip ai prompts in react native
  Removed data.changedFiles from change-detection status internals and updated tests accordingly.
  Fix type error
  Docs: Improve change detection page clarity
  Extend doc types to support section-level classification
  Build: Add docs-review skill
  Fix type error
  Address feedback
  Address feedback
  Format
  Address feedback
  Add images
  add bluesky
  fix tests
  gracefully handle cache failures
  ...
@kylegach kylegach merged commit 3ef7a4d into project/sb-agentic-setup Apr 17, 2026
9 of 12 checks passed
@kylegach kylegach deleted the yann/storybook-ai-api-docs branch April 17, 2026 16:32
@coderabbitai coderabbitai Bot mentioned this pull request Apr 28, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:docs Run the CI jobs for documentation checks only. documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants