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, 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

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/              # 静态资源(如有)

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

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>;
}

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.

$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;

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) — 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

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.