Storybook 生成器:自动创建 React Storybook - Openclaw Skills
作者:互联网
2026-04-14
什么是 Storybook 生成器?
Storybook 生成器是一款强大的工具,旨在消除编写样板 story 文件的繁琐手动工作。通过将工具指向 React 组件,开发人员可以自动获得包含变体、控件和边缘情况的完整 stories。这是 Openclaw Skills 生态系统的核心部分,确保项目中的每个组件都能在没有手动开销的情况下得到妥善展示。
该工具专门为处理现代 React 开发的复杂性而构建,包括 TypeScript 类型、复杂的 prop 对象和回调函数。无论您是在构建全新的设计系统还是为旧代码库编写文档,它都提供了一个开箱即用的零配置解决方案。
下载入口:https://github.com/openclaw/skills/tree/main/skills/lxgicstudios/storybook-gen
安装与下载
1. ClawHub CLI
从源直接安装技能的最快方式。
npx clawhub@latest install storybook-gen
2. 手动安装
将技能文件夹复制到以下位置之一
全局模式~/.openclaw/skills/
工作区
/skills/
优先级:工作区 > 本地 > 内置
3. 提示词安装
将此提示词复制到 OpenClaw 即可自动安装。
请帮我使用 Clawhub 安装 storybook-gen。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。
Storybook 生成器 应用场景
- 为现有的旧 React 代码库设置 Storybook。
- 在开发生命周期中快速为新组件编写文档。
- 为跨团队协作构建标准化的设计系统。
- 为复杂的 UI 组件生成全面的测试场景。
- 该工具解析目标 React 组件以提取 prop 类型、默认值和功能结构。
- 它使用 Openclaw Skills 逻辑将识别出的 props 映射到适当的 Storybook 控件和参数。
- 系统为常见的组件状态(如默认、禁用、加载和错误)生成 stories。
- 它生成一个组件 Story 格式 (CSF3) 文件,包括逼真的示例数据和 TypeScript 定义。
- 生成的文件将保存到您的项目中,可立即使用或进行手动微调。
Storybook 生成器 配置指南
Storybook 生成器需要 Node.js 18 或更高版本。无需永久安装,因为它可以通过 npx 直接执行。
# 为特定组件生成 stories
npx ai-storybook ./src/components/Button.tsx
# 查看所有可用选项
npx ai-storybook --help
Storybook 生成器 数据架构与分类体系
该技能分析源文件并根据以下架构生成结构化文档:
| 特性 | 详情 |
|---|---|
| 输入支持 | .tsx, .jsx, .ts, .js React 文件 |
| 输出格式 | CSF3 (Component Story Format) |
| 类型安全 | story 参数的完整 TypeScript 支持 |
| 状态覆盖 | 默认、禁用、加载、错误和自定义变体 |
| 文档 | 将 JSDoc 注释集成到 Storybook 说明中 |
name: storybook-gen
description: Generate Storybook stories from React components. Use when documenting components or setting up a design system.
Storybook Generator
Point it at a React component. Get back complete Storybook stories with all the variants, controls, and edge cases. No more writing boilerplate stories by hand.
One command. Zero config. Just works.
Quick Start
npx ai-storybook ./src/components/Button.tsx
What It Does
- Analyzes component props and generates appropriate controls
- Creates stories for common states (default, disabled, loading, error)
- Handles complex prop types including objects and callbacks
- Generates proper TypeScript types for story args
- Includes realistic example data, not just placeholder text
Usage Examples
# Generate stories for a single component
npx ai-storybook ./src/components/Card.tsx
# Process entire components directory
npx ai-storybook ./src/components/ --recursive
# Output CSF3 format
npx ai-storybook ./src/Button.tsx --format csf3
# Include interaction tests
npx ai-storybook ./src/Modal.tsx --with-interactions
# Specify output directory
npx ai-storybook ./src/Input.tsx -o ./stories/
Best Practices
- Write good prop types first - Better TypeScript types mean better generated stories
- Include JSDoc comments - The AI uses your documentation to create meaningful descriptions
- Generate, then customize - Use this for the boilerplate, add your specific edge cases manually
- Keep components focused - Components with clear, single responsibilities generate cleaner stories
When to Use This
- Setting up Storybook for an existing codebase
- Adding a new component and need stories fast
- Documenting a component library for your team
- Creating a design system with consistent story patterns
Part of the LXGIC Dev Toolkit
This is one of 110+ free developer tools built by LXGIC Studios. No paywalls, no sign-ups, no API keys on free tiers. Just tools that work.
Find more:
- GitHub: https://github.com/LXGIC-Studios
- Twitter: https://x.com/lxgicstudios
- Substack: https://lxgicstudios.substack.com
- Website: https://lxgic.dev
Requirements
No install needed. Just run with npx. Node.js 18+ recommended.
npx ai-storybook --help
How It Works
The tool parses your React component to extract prop types, default values, and component structure. It then generates Storybook stories that exercise each prop combination, creating meaningful examples based on the prop names and types.
License
MIT. Free forever. Use it however you want.
相关推荐
专题
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
最新数据
相关文章
代理状态:监控支付意图和交易 - Openclaw Skills
Proxy MCP:AI 智能体支付与虚拟卡 - Openclaw Skills
Apify Ultimate Scraper: AI 网页数据抓取 - Openclaw Skills
加密诈骗检测器:实时欺诈预防 - Openclaw Skills
newsmcp: 实时 AI 新闻聚合与过滤 - Openclaw Skills
Moltbook 优化器:策略与排名精通 - Openclaw 技能
Frigate NVR:智能摄像机管理与自动化 - Openclaw Skills
Markdown 检查器:样式、链接和格式工具 - Openclaw Skills
Venice.ai 至尊路由:私密且无审查的模型路由 - Openclaw Skills
图片优化器:使用 Openclaw Skills 压缩和调整图片尺寸
AI精选
