Before you begin
- Storybook 8 or higher
- Node.js 22+
- An AI provider subscription (Anthropic, OpenAI, Google, or Amazon Bedrock)
Install the addon
1
Install the package
2
Register in your Storybook config
.storybook/main.ts
3
Start Storybook
Launch Storybook and open the Loracle tab in the bottom panel.

Configure a provider
The addon uses OpenCode to connect to your existing AI provider credentials. If you already have OpenCode configured, the addon picks up your provider automatically — no extra setup needed. To configure a specific provider, create.storybook/opencode.json:
.storybook/opencode.json
Authenticate your provider after saving:
Connect Loracle MCP (optional)
Give the AI access to your published component catalog so it can look up real components, props, and usage examples when writing stories. Add MCP config to your.storybook/opencode.json:
- Remote (recommended)
- Via npx proxy
.storybook/opencode.json
Using the chat panel
Open any story and switch to the Loracle tab. The status bar shows a green Connected indicator and the current story path.
Example prompts
- “Add a disabled state to this button story”
- “Create variants for small, medium, and large sizes”
- “Style this to match our brand colors”
- “Add an interactive form with validation”
- “Make this component responsive”
Attach an image
Click the + button in the chat input to pick an image, or paste directly from your clipboard. A thumbnail preview appears before you send. This is one of the most powerful features of the addon — you can turn any visual into a working story built with your design system:- Screenshot to story — paste a screenshot of an existing UI and ask the AI to recreate it as a story using your components
- Visual iteration — screenshot a rendered story and ask “make the spacing tighter” or “match this layout instead”
Revert a change
Every time you send a message, the addon snapshots your story file before the AI responds. Hover over any of your messages to reveal the Restore button — clicking it rolls the file back to that point, removes all subsequent messages from the conversation, and reloads the page.Safety
The addon applies secure defaults to protect your codebase:- Writes restricted to story files — the AI can only edit
*.stories.*files - Bash, web fetch, and web search disabled — prevents unintended side effects
- No destructive tools — patch and other filesystem tools are blocked
permission field to your .storybook/opencode.json. See the OpenCode documentation for permission configuration.
Guide the AI with AGENTS.md
The addon runs on OpenCode, so it respects standard agent instruction files: AGENTS.md,CLAUDE.md, and others. Use them to set persistent rules for how the AI writes stories.
Useful things to include:
- Import paths: Where your components live, so the agent doesn’t guess
- Story structure: Naming conventions, required exports, file layout
- Styling rules: Design tokens over raw CSS, or a specific styling approach
- Forbidden patterns: No inline styles, no hardcoded strings, no deprecated APIs
AGENTS.md
Troubleshooting
”Setup required” onboarding screen
The addon couldn’t detect an AI provider. Either:- Create
.storybook/opencode.jsonwith your provider and model - Or authenticate via OpenCode:
opencode auth login --provider anthropic - See the OpenCode provider guide for all supported providers
Addon panel not showing
Verify the addon is registered in your.storybook/main.ts addons array and restart Storybook.
”Error: fetch failed”
The AI provider couldn’t be reached. Check that:- Your provider credentials are valid — run
opencode auth login --provider <provider> - Your API key has available credits
- You’re not behind a proxy that blocks the provider’s API
AI can’t edit my files
By default the addon only allows edits to*.stories.* files. If you need broader access, add a custom permission field to your .storybook/opencode.json.
Next steps
MCP server
Connect your coding agent to the published catalog.
Loracle CLI
Publish your design system to make it available via MCP.