Before you begin
- Storybook 8 or higher
- Node.js 22+
- An AI provider subscription (Anthropic, OpenAI, Google, or Amazon Bedrock)
Install the addon
Configure with opencode.json
The addon uses OpenCode to connect to your provider. Useopencode.json to choose your AI provider and model, and to connect the addon to your published component catalog via MCP.
opencode.json
| Field | Why you’d set it |
|---|---|
provider | Choose your AI provider: anthropic, amazon-bedrock, openai, or google. |
model | Pick a specific model, such as claude-sonnet-4-6, us.anthropic.claude-sonnet-4-6, or gpt-4o. |
mcp.loracle | Give the AI access to your published component catalog so it can look up real components, props, and usage examples when writing stories. See the MCP guide. |
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
Use the chat panel
Open any story and switch to the Loracle panel. Describe what you want, and the AI edits the story file while Storybook hot-reloads with the result. 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”
Attach an image
Click the image button in the chat input to attach a screenshot or design mockup. The AI uses it as visual context when generating code. Supported formats: PNG, JPEG, and WebP.Revert a change
Every AI response snapshots your story file. Hover over any past message to reveal the Restore button. Clicking it rolls the file back to that point and reloads the page.Troubleshooting
”Setup required” onboarding screen
The addon couldn’t detect an AI provider. Either:- Create
opencode.jsonwith your provider and model - Or authenticate via OpenCode:
opencode auth login --provider anthropic - See the OpenCode provider guide for all supported providers
”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 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.