원클릭으로
component-doc
为 @skyroc/web-ui 组件编写文档。当用户说出组件名(如 Button、Accordion、AlertDialog)时触发。自动定位组件源码、playground demo、已有文档,按照项目文档规范生成或更新 MDX 文档。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
为 @skyroc/web-ui 组件编写文档。当用户说出组件名(如 Button、Accordion、AlertDialog)时触发。自动定位组件源码、playground demo、已有文档,按照项目文档规范生成或更新 MDX 文档。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
UI/UX design intelligence with searchable database
Simplifies and refines code for clarity, consistency, and maintainability while preserving all functionality. Focuses on recently modified code unless instructed otherwise.
Refactor high-complexity React components in Dify frontend. Use when `pnpm analyze-component --json` shows complexity > 50 or lineCount > 300, when the user asks for code splitting, hook extraction, or complexity reduction, or when `pnpm analyze-component` warns to refactor before testing; avoid for simple/well-structured components, third-party wrappers, or when the user explicitly wants testing without refactoring.
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.
Guided feature development with codebase understanding and architecture focus
Generate Vitest + React Testing Library tests for Dify frontend components, hooks, and utilities. Triggers on testing, spec files, coverage, Vitest, RTL, unit tests, integration tests, or write/review test requests.
| name | component-doc |
| description | 为 @skyroc/web-ui 组件编写文档。当用户说出组件名(如 Button、Accordion、AlertDialog)时触发。自动定位组件源码、playground demo、已有文档,按照项目文档规范生成或更新 MDX 文档。 |
| argument-hint | 组件名,如 Button、Accordion、AlertDialog |
为 @skyroc/web-ui 组件库编写文档的专用工作流。
给定组件名 $COMPONENT(用户输入,如 Button),将其转为 kebab-case $slug(如 button),然后按以下路径查找:
| 用途 | 路径 |
|---|---|
| 组件源码 | packages/web/ui/shadcn/src/components/$slug/ |
| Playground Demo | apps/web-ui-playground/src/app/[locale]/(demo)/$slug/modules/ |
| 文档 MDX | apps/web-ui-docs/content/docs/components/$slug.mdx |
文档基础设施文件(不需要每次都读,但需要了解):
| 文件 | 作用 |
|---|---|
apps/web-ui-docs/components/props-table.tsx | <PropsTable> — API 属性表格 |
apps/web-ui-docs/components/type-table.tsx | <TypeTable> + <UnionType> — 类型定义区 |
apps/web-ui-docs/components/type-anchor.tsx | 类型链接解析(PascalCase 自定义类型 → 蓝色可点击锚点) |
apps/web-ui-docs/components/type-registry.ts | 跨页面类型链接注册表 |
apps/web-ui-docs/components/demo/index.tsx | <Demo> — 从 playground 加载 live demo |
apps/web-ui-docs/components/mdx.tsx | MDX 组件注册(Demo / PropsTable / TypeTable / UnionType) |
packages/web/ui/shadcn/src/components/$slug/ 下所有文件
index.ts(导出)、types.ts(Props 定义)、*-variants.ts(样式变体)、主组件文件apps/web-ui-playground/src/app/[locale]/(demo)/$slug/modules/ 下所有 demo
packages/web/ui/shadcn/src/preset/$slug/ 了解预设封装和 useComponentConfig 集成apps/web-ui-docs/content/docs/components/$slug.mdxalert.mdx,其次 button.mdx)文档不是 API 想象稿,必须从 源码、类型、demo、实际行为 四者交叉验证。
写文档前必须同时检查:
types.ts 声明了哪些 public props / typesclassNames / slot props / size / variant / color 等样式控制是否真的生效index.ts 实际导出了哪些组件和类型如果发现 类型/API 承诺 与 实现行为 不一致:
典型例子:
BottomSheetProps.size 声明为主组件尺寸,但主组件没有传给 BottomSheetContent:这是实现 bug,应提出或修复---
title: $COMPONENT
description: 一句话描述组件用途
---
组件概述段落。
\`\`\`tsx
import { ... } from '@skyroc/web-ui';
\`\`\`
## 何时使用
- 使用场景 1
- 使用场景 2
- 与相似组件的区分
## 功能章节 1(如"颜色"、"变体"、"尺寸"等)
说明文字 + 表格(可选)
<Demo src="@playground/$slug/modules/DemoName" />
\`\`\`tsx
// 内联代码作为 API 快速参考
<Component prop="value" />
\`\`\`
## 功能章节 N
...
## API
### $COMPONENT
通用属性参考说明。
<PropsTable data={[...]} />
### 子组件(如有)
<PropsTable data={[...]} />
## 类型
<TypeTable data={[...]} />
<UnionType name="..." description="..." type="..." />
每个功能章节的示例由两部分组成,缺一不可:
<Demo> 标签(必须):引用 playground 源码,用户可在文档中看到交互式 live demo 和完整源码。<Demo> 后面,提供简洁的 API 用法速查。内联代码块的编写原则:
示例:
## 受控模式
通过 `page` + `onPageChange` 实现受控分页。
<Demo src="@playground/pagination/modules/Controlled" />
\`\`\`tsx
const [page, setPage] = useState(1);
<Pagination
total={200}
itemsPerPage={10}
page={page}
onPageChange={setPage}
/>
\`\`\`
type 字段:短字面量联合类型必须直接内联,不要另起 PascalCase 类型名,也不要在 ## 类型 区域写 <UnionType>。"'primary' | 'destructive' | 'success' | 'warning' | 'info' | 'carbon' | 'secondary' | 'accent'""'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'""boolean | 'indeterminate'"、"'horizontal' | 'vertical'"、"'left' | 'right'"、"'square' | 'rounded'"typeToReactNode 自动渲染为蓝色可点击链接,跳转到当前页类型定义或 type-registry.ts 注册的跨页锚点。default 用字符串表示,如 "'md'"、'false'required: true 仅在属性必填时添加核心原则:PropsTable / TypeTable 中出现的每一个非内置 PascalCase 类型名,都必须在当前页 ## 类型 区域有对应定义,或在 type-registry.ts 中注册了跨页面链接。不允许出现"引用了但未定义"的类型。
检查清单(写完文档后逐项核对):
<PropsTable> 的 type 字段,收集全部 PascalCase 类型名<TypeTable> 的 fields[].type,收集全部 PascalCase 类型名ReactNode、HTMLElement、Record、Partial 等,见 type-anchor.tsx 的 BUILTIN_TYPE_NAMES)<TypeTable> 中作为 name 定义<UnionType> 中作为 name 定义type-registry.ts 中注册了跨页面链接<UnionType>,应改为在 type 字段直接内联。特别注意:
titleProps: AlertTitleProps、descriptionProps: AlertDescriptionProps 等 props,这些类型也必须在 TypeTable 中定义,包含各自的字段列表index.ts / types.ts 导出的 Props、ClassNames/Ui、Slots、ItemData、Option、Variant 等类型,都必须在当前页类型区定义或跨页注册StyledComponentProps<T>、HTMLComponentProps<T>、Radix Props、Vaul Props 等,需要在类型区说明这些包装类型和关键字段ButtonProps、DropdownMenuProps),且该类型不属于当前组件,可以只引用并通过 type-registry.ts 跨页链接;不要在当前页复制展开全部字段ThemeColor、ThemeSize 这类短联合直接内联;ClassValue 这类复杂类型可以在类型区保留定义。DeepPartial、ElementType、StandardSchema、Values 等泛型/外部类型),需要确认它已在 type-anchor.tsx 的 BUILTIN_TYPE_NAMES 中注册。如果没有注册,会生成错误的本地锚点链接。遇到这种情况需要将其添加到 BUILTIN_TYPE_NAMES 中。以下类型在多数组件文档中都需要,按需取用:
type: "'primary' | 'destructive' | 'success' | 'warning' | 'info' | 'carbon' | 'secondary' | 'accent'"
type: "'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'"
<UnionType name="ClassValue" description="CSS 类名类型" type="string | null | undefined | Record<string, boolean> | ClassValue[]" />
## 类型 区域定义本页引用的所有非内置类型<TypeTable> — 对象类型(有字段列表的类型,如 ClassNames、子组件 Props)<UnionType> — 复杂联合、外部库派生类型、确实需要解释的类型定义;短字面量联合不要使用 <UnionType>,直接内联到表格type 字段一致,系统自动生成锚点 ID<TypeTable>(对象类型),再 <UnionType>(联合类型)当 PropsTable 中引用了定义在其他页面的类型(如 AlertDialog 引用 ButtonProps):
apps/web-ui-docs/components/type-registry.ts 中注册映射TypeName: '/docs/components/target-page#anchor'<Demo src="@playground/$slug/modules/DemoModuleName" />./shared、同目录模块、图片、路由组件或其他非 scope 内容当 playground modules/ 目录不存在或缺少所需 demo 时,必须创建,不能因为缺 demo 而只写内联代码。
创建 demo 文件的规范:
apps/web-ui-playground/src/app/[locale]/(demo)/$slug/modules/$DemoName.tsx'use client';
import { ... } from '@skyroc/web-ui';
const $DemoName = () => {
// demo 实现
return (
<div className="...">
...
</div>
);
};
export default $DemoName;
创建规则:
'use client' 指令export default 导出@skyroc/web-ui 导入 UI 组件,不要从内部路径导入lucide-react 导入shared.tsx,demo 应自包含(如需共享常量直接内联到各 demo 中)同步 page.tsx:如果 page.tsx 不存在或未引用新 demo,需要一并创建/更新
判断流程:
读取 playground/$slug/modules/ 目录
├── 已有 demo 覆盖文档需要的功能点 → 直接引用
├── 有 page.tsx 但缺少部分 demo → 补充缺失的 demo 模块
└── 目录不存在 → 创建全部 demo 模块 + page.tsx
Demo 在 react-live 沙箱中执行,scope 定义在 apps/web-ui-docs/components/demo/scope.ts。需注意:
@skyroc/web-ui 和 lucide-react,后者也导出部分同名组件(如 Badge)@skyroc/web-ui 优先(最后赋值覆盖同名导出)lucide-react 图标同名,需确认 scope 中不存在冲突,或调整赋值顺序apps/web-ui-docs/content/docs/components/$slug.mdx以 apps/web-ui-docs/content/docs/components/alert.mdx 为首选参考,button.mdx 为辅助参考。
alert.mdx 展示了完整的类型引用模式:PropsTable 使用类型名引用 → 类型区包含全部 TypeTable 和 UnionType 定义 → 无遗漏。