Cursor with Storybook: generating stories that match your component patterns
Published 2025-12-29 by Owner
Storybook stories are the kind of work AI tools handle well — repetitive structure, predictable patterns, low novelty. With a few setup choices, Cursor produces stories that fit your patterns on first attempt.
The setup
Pin your existing patterns:
> /add stories/Button.stories.tsx
> /add stories/UserProfile.stories.tsx
These show Cursor your component story format. Standard CSF3, controls, args. Cursor copies the pattern.
In .cursorrules:
Storybook stories follow CSF3 format. Each story file has:
- A meta export with component, title, parameters
- Multiple story exports demonstrating different states
- Args for each story showing reasonable defaults
- argTypes when controls need customization
For components with variants, include one story per variant.
For components with state, include stories for each state (loading, error, success, empty).
A specific request
For a new Card component:
> Generate Storybook stories for Card. Cover:
> - Default state
> - With image
> - Without image
> - Loading state
> - Error state
> - With and without action button
> Follow our existing patterns from UserProfile.stories.tsx.
Cursor produces 6 stories matching the format. Args for each. Reasonable defaults.
About 30 seconds to generate; 5 minutes to review and adjust. Manual would have been 20+ minutes.
What Cursor handles well
Standard stories. Component variations. Cursor scales the pattern.
Args generation. Reasonable defaults for each state. Controls for the props users would change.
Documentation comments. JSDoc-style comments explaining each story’s purpose.
Mock data. When stories need data (lists, profile info), Cursor generates plausible mock data.
What still needs human input
Visual design decisions. Which states matter? Which combinations to show?
Edge cases worth illustrating. What’s the weird state your team will forget about? You decide.
Aesthetic judgment. Stories that look polished require visual care. Cursor’s defaults are generic.
For these, you guide; Cursor implements.
A pattern for new components
The workflow I use:
- Implement the component
- Decide what stories matter
- Ask Cursor to generate stories matching the existing pattern
- Review the generated stories
- Refine args, mock data, controls
The generation step is fast. The review and refinement is real but bounded.
Visual regression integration
If you use Chromatic or similar for visual regression:
> Generate stories that exercise visual variations:
> - Different sizes (small, medium, large)
> - Different states (default, hover, focus, disabled)
> - Different content lengths (short, medium, long with overflow)
Cursor produces matrix stories. Chromatic captures them. Visual regression catches changes.
Cost
Generating stories is cheap. A typical story file (10 stories) costs maybe $0.05 in API tokens. Across a project’s lifetime, the cost is negligible.
Worth using AI for
Storybook is a clear AI fit:
- Repetitive structure
- Standard patterns
- Easy verification (visual)
- Low risk (stories don’t ship to production)
For teams using Storybook, AI generation is essentially free productivity. The ROI is overwhelming.
What I’d skip
A few things AI doesn’t help with:
- Storybook’s add-ons configuration (one-time setup, low value)
- Complex interactive stories with custom logic
- Stories that test specific accessibility patterns
For these, manual. For the bulk of routine stories, AI handles.
Summary
Storybook + Cursor is one of the highest-leverage AI productivity wins for component-heavy frontend work. Setup is minimal; generation is fast; quality is high. Worth integrating into your component workflow.