comp-hub-create skill
Hand the comp-hub component spec to your AI assistant — one prompt generates a ready-to-upload component scaffold
ZIP · ~5 KB · includes SKILL.md
- name
- comp-hub-create
- description
- Scaffold comp-hub business components (index.vue for Vue, index.jsx for React, each with demo + README + comp.json). Use when creating, uploading or publishing a comp-hub component.
When it kicks in
Your assistant loads comp-hub-create automatically once it detects these intents
Three steps to install
Download it, drop it into your assistant's skills folder, then just ask in plain language
Download and unzip
Download comp-hub-create.zip and unzip it to get the comp-hub-create folder
Drop into the skills folder
Copy the whole folder into your assistant's skills directory — works for CodeBuddy and Claude
# CodeBuddy
~/.codebuddy/skills/comp-hub-create/
# Claude Code
~/.claude/skills/comp-hub-create/
Ask in plain language
Describe what you need in the chat; the assistant loads the skill and generates a compliant component
帮我创建一个 comp-hub 组件:用户排行榜
Generated structure
The component name is the folder name and must be globally unique; the platform writes __id__ into comp.json
ComponentName/
├── index.vue # 入口文件(必需)
├── README.md # 组件文档(建议)
├── comp.json # 配置文件(自动生成 name + version + __id__)
├── main.js # UI 框架注册(可选)
├── demo/
│ ├── mini.vue # 小窗预览(列表页展示)
│ └── full.vue # 全屏预览(详情页展示)
└── assets/ # 静态资源(如有)
ComponentName/
├── index.jsx # 入口文件(必需,须 default export)
├── README.md # 组件文档(建议)
├── comp.json # 配置文件(自动生成 name + version + __id__)
├── demo/
│ ├── mini.jsx # 小窗预览(列表页展示)
│ └── full.jsx # 全屏预览(详情页展示)
└── assets/ # 静态资源(如有)
Core rules
Hard constraints baked into the skill — generated code follows them automatically
Naming
Component names are globally unique; prefer the prefix form company-domain-component, PascalCase or kebab-case only
Relative asset paths
Always import assets with relative paths like ./assets/xxx.png — the @/ alias is not supported
Component entry
Vue requires index.vue; React entries are index.jsx / index.js / index.tsx and must have a default export
UI framework support
Vue: add main.js for a third-party UI library (Vue.use() for Vue 2, Vue.app.use() for Vue 3); React: just import it — no main.js
Demo files
demo/mini uses a fixed size plus the scaling API; demo/full simply inherits 100% width and height (React uses .jsx / .tsx)
Styles and preprocessors
Vue supports SCSS / Less and should always be scoped; React imports css / scss / less with a relative path
Third-party dependencies
No bundling needed — import statements are scanned and matched automatically at preview time
Framework detection
No declaration needed: importing vue means Vue, importing react means React, importing both cannot be rendered
import Vue from "vue";
import Antd from "ant-design-vue";
import "ant-design-vue/dist/antd.css";
Vue.use(Antd);
import * as Vue from "vue";
import ArcoVue from "@arco-design/web-vue";
import "@arco-design/web-vue/dist/arco.css";
Vue.app.use(ArcoVue);
import { Card } from "antd";
import "./index.css";
export default function MyCard() {
return <Card>Hello</Card>;
}
Scaling and centering API for mini previews
The preview environment injects scaling — $onScaleChange on the Vue instance, onScaleChange as a prop in React — so fixed-size content adapts to the preview panel
For the mini preview only (demo/mini.vue / demo/mini.jsx). This API exists only inside the comp-hub preview environment — always guard with a null check.
<script setup>
import { ref, getCurrentInstance, onBeforeUnmount } from "vue";
const instance = getCurrentInstance();
const scaleStyle = ref({});
const unsub = (instance?.proxy as any)?.$onScaleChange?.(
{ mode: "contain", width: 320, height: 240 },
style => { scaleStyle.value = style; }
);
onBeforeUnmount(() => unsub?.());
</script>
import { useEffect, useState } from "react";
const DemoMini = ({ onScaleChange }) => {
const [scaleStyle, setScaleStyle] = useState({});
useEffect(() => {
if (!onScaleChange) return; // 非 comp-hub 环境
return onScaleChange(
{ mode: "contain", width: 320, height: 240 },
setScaleStyle
);
}, [onScaleChange]);
return <div style={scaleStyle}>{/* 按 320×240 设计的内容 */}</div>;
};
export default DemoMini;
Scale modes
| Mode | Behavior |
|---|---|
| widthFirst | Scales to container width; height may overflow |
| heightFirst | Scales to container height; width may overflow |
| contain | Scales proportionally, content always fully visible (recommended) |
| cover | Scales proportionally to fill the container (may crop) |
Best practices
- Scale in the mini panel, never in the full panel
- Let $onScaleChange push updates (the onScaleChange prop in React) — subscribe to container changes instead of computing scale yourself on every render
- Unsubscribe in beforeDestroy / onBeforeUnmount (Vue) or by returning it from useEffect (React) to avoid leaks
- contain is the safe default — content stays fully visible even in small panels
Let AI write components for you
Install comp-hub-create, hand the repetitive work to your assistant, and just review the result