Agent Skill for AI Coding Assistants

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, index.js for Web Components, 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

You ask it to create a comp-hub component
You want a new component that follows the comp-hub spec
You want to create a Web Component

Three steps to install

Download it, drop it into your assistant's skills folder, then just ask in plain language

1

Download and unzip

Download comp-hub-create.zip and unzip it to get the comp-hub-create folder

2

Drop into the skills folder

Copy the whole folder into your assistant's skills directory — works for CodeBuddy and Claude

skills 目录
bash 复制代码
# CodeBuddy
~/.codebuddy/skills/comp-hub-create/

# Claude Code
~/.claude/skills/comp-hub-create/
3

Ask in plain language

Describe what you need in the chat; the assistant loads the skill and generates a compliant component

对话输入
plaintext 复制代码
帮我创建一个 comp-hub 组件:用户排行榜

Generated structure

The component name is the folder name and must be globally unique; the platform writes __id__ into comp.json

ComponentName/ · Vue
plaintext 复制代码
ComponentName/
├── index.vue            # 入口文件(必需)
├── README.md            # 组件文档(建议)
├── comp.json            # 配置文件(自动生成 name + version + __id__)
├── main.js              # UI 框架注册(可选)
├── demo/
│   ├── mini.vue         # 小窗预览(列表页展示)
│   └── full.vue         # 全屏预览(详情页展示)
└── assets/              # 静态资源(如有)
ComponentName/ · React
plaintext 复制代码
ComponentName/
├── index.jsx            # 入口文件(必需,须 default export)
├── README.md            # 组件文档(建议)
├── comp.json            # 配置文件(自动生成 name + version + __id__)
├── demo/
│   ├── mini.jsx         # 小窗预览(列表页展示)
│   └── full.jsx         # 全屏预览(详情页展示)
└── assets/              # 静态资源(如有)
MyElement/ · Web Component
plaintext 复制代码
MyElement/
├── index.js               # 入口文件(必需):注册自定义元素
├── README.md              # 组件文档(建议)
├── comp.json              # 配置文件(自动生成 name + version + __id__)
├── demo/
│   ├── mini.html          # 小窗预览(须含 <script type="module">)
│   └── full.html          # 全屏预览
└── screenshot_mini.png    # 缩略图(平台无法自动截图,需自行放置)

Web Component source must be plain JavaScript the browser can run directly (no TypeScript / JSX) and the preview HTML must contain at least one <script type="module">; the platform cannot auto-screenshot shadow DOM either, so place screenshot_mini.png yourself

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; Web Components use index.js and must register a custom element

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 and Web Components: 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; Web Components use .html with at least one <script type="module">

Styles and preprocessors

Vue supports SCSS / Less and should always be scoped; React imports css / scss / less with a relative path; Web Components scope styles inside the shadow root

Third-party dependencies

No bundling needed — import statements are scanned and matched automatically at preview time

Framework detection

No declaration needed — the platform probes the source: index.vue means Vue, index.jsx / .tsx means React, customElements.define( means Web Component; if none match you pick manually

main.js · Vue 2
javascript 复制代码
import Vue from "vue";
import Antd from "ant-design-vue";
import "ant-design-vue/dist/antd.css";

Vue.use(Antd);
main.js · Vue 3
javascript 复制代码
import * as Vue from "vue";
import ArcoVue from "@arco-design/web-vue";
import "@arco-design/web-vue/dist/arco.css";

Vue.app.use(ArcoVue);
index.jsx · React
javascript 复制代码
import { Card } from "antd";
import "./index.css";

export default function MyCard() {
  return <Card>Hello</Card>;
}
index.js · Web Component
javascript 复制代码
// index.js
import dayjs from "dayjs";

class MyElement extends HTMLElement {
  connectedCallback() {
    this.textContent = dayjs().format("YYYY-MM-DD");
  }
}

customElements.define("my-element", MyElement);

Scaling and centering API for mini previews

The preview environment injects scaling — $onScaleChange on the Vue instance, onScaleChange as a prop in React, window.compHub.onScaleChange for Web Components — so fixed-size content adapts to the preview panel

For the mini preview only (demo/mini.vue / demo/mini.jsx / demo/mini.html). This API exists only inside the comp-hub preview environment — always guard with a null check.

$onScaleChange(params, callback)
html 复制代码
<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>
onScaleChange(params, callback)
javascript 复制代码
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;
window.compHub?.onScaleChange(params, callback)
html 复制代码
<div id="mini-wrapper">
  <!-- 按 320×240 设计的内容 -->
</div>
<my-element></my-element>

<script type="module" src="../index.js"></script>
<script type="module">
  const wrapper = document.getElementById("mini-wrapper");

  // 可选链判空:单独打开这份 HTML 时 window.compHub 不存在
  window.compHub?.onScaleChange({ mode: "contain", width: 320, height: 240 }, style => {
    Object.assign(wrapper.style, style);
  });
</script>

Scale modes

ModeBehavior
widthFirstScales to container width; height may overflow
heightFirstScales to container height; width may overflow
containScales proportionally, content always fully visible (recommended)
coverScales 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, window.compHub?.onScaleChange for Web Components) — subscribe to container changes instead of computing scale yourself on every render
  • Unsubscribe in beforeDestroy / onBeforeUnmount (Vue) or by returning it from useEffect (React); Web Components use window.compHub?.onCleanup() to clear timers and global listeners
  • 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

CH
Comp-Hub

A professional component sharing platform for frontend developers. Discover, share, and use high-quality open-source components.

© 2026 Comp-Hub. All rights reserved.