Create Component logo

Create Component

Community
AntonHu
create-component

指导在前端项目中按团队规范创建和拆分 React 组件,包括目录结构、文件命名、样式与主题变量使用。当前端需要新增或重构组件时使用本技能。

Overview

PublisherAntonHu
Repositoryai-coding-project
Skill namecreate-component
Stars
111
Forks
35
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by AntonHu on GitHub. Read the source before you install it.

Installation

Install the Create Component AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/AntonHu/ai-coding-project/tree/main/.agents/skills/create-component
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/AntonHu/ai-coding-project.git /tmp/ai-coding-project
mkdir -p .claude/skills
cp -r /tmp/ai-coding-project/.agents/skills/create-component .claude/skills/create-component
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Create Component in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Create Component on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Create Component is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

创建与拆分组件

使用场景

当你需要:

  • 新增一个可复用通用组件
  • 为某个页面新增页面级组件
  • 拆分过大的页面/组件文件

请使用本技能,并同时遵守 .agents/rules/03-项目结构.md 与 .agents/rules/04-组件规范.md。


组件放在哪里?

详见 .agents/rules/04-组件规范.md 中的"组件放置决策树"。

  • 通用组件(跨页面复用):src/components/<component-name>/
  • 页面级组件(只在单页使用):src/routes/<route>/components/

命名约定:

  • 目录名:kebab-case,例如 error-boundary
  • React 组件名:PascalCase,例如 ErrorBoundary

标准目录结构

通用组件示例:

text
src/components/shentu-button/
  ├─ index.tsx
  └─ index.module.scss

页面级组件示例:

text
src/routes/home/components/header/
  ├─ index.tsx
  └─ index.module.scss

步骤 1:创建组件骨架

tsx
// src/components/shentu-button/index.tsx
import React from 'react';
import classNames from 'classnames';
import styles from './index.module.scss';

interface ShentuButtonProps {
  onClick: () => void;
  className?: string;
}

export const ShentuButton: React.FC<ShentuButtonProps> = ({onClick, className, children}) => {
  return (
    <button
      type="button"
      className={classNames(styles.shentuButton, className)}
      onClick={onClick}
    >
      {children}
    </button>
  );
};

并在 src/components/index.ts 中集中导出:

ts
// src/components/index.ts
export * from './shentu-button';

步骤 2:样式与主题变量

在 index.module.scss 中:

scss
// src/components/shentu-button/index.module.scss
.shentuButton {
  padding: 8px 16px;
  border-radius: 4px;
  border: none;
  cursor: pointer;

  // 必须使用主题变量,禁止硬编码主色
  background-color: var(--ant-color-primary);
  color: var(--ant-color-text);
}

原则:

  • 必须使用 SCSS Modules:index.module.scss
  • 自定义颜色必须使用主题 CSS 变量:
    • Ant Design 变量:var(--ant-color-primary)、var(--ant-color-text) 等
    • 自定义变量:var(--shentu-card-bg)、var(--shentu-border-radius) 等
  • 禁止在组件样式中直接硬编码主色,如 #1677ff。

样式还原检查:涉及 UI 还原的组件样式开发,请参考 .agents/skills/create-proposal/SKILL.md 中的「样式还原验证检查清单」及对应页面的 docs/样式还原/<名称>-UI分析清单.md。


步骤 3:组件职责与拆分

  • 单个 .tsx 文件建议不超过 400 行,超过时优先考虑拆分为子组件。
  • 拆分时遵循:
    • 页面级组件:只在一个路由使用 → 放在该路由的 components/ 下。
    • 通用组件:在多个路由使用 → 提取到 src/components。
  • 一个组件应聚焦单一职责(一个明确的 UI 区块或交互单元)。

步骤 4:与 Ant Design 协同

通用交互控件应基于 Antd 进行二次封装:

tsx
import React from 'react';
import {Button, ButtonProps} from 'antd';

type ShentuButtonProps = ButtonProps & {
  // 可以扩展一些自定义属性
};

export const ShentuButton: React.FC<ShentuButtonProps> = (props) => {
  return <Button type="primary" {...props} />;
};

快速检查清单

  • 组件目录是否放在了正确位置(通用 vs 页面级)?
  • 是否使用了 index.tsx + index.module.scss 的结构?
  • 是否通过 src/components/index.ts 集中导出通用组件?
  • 样式是否全部使用 SCSS Modules,且颜色使用主题变量?
  • 组件文件是否过大,是否需要拆分子组件?

Frequently asked questions

What does the Create Component AI skill do?

指导在前端项目中按团队规范创建和拆分 React 组件,包括目录结构、文件命名、样式与主题变量使用。当前端需要新增或重构组件时使用本技能。

Why use Create Component on TypingMind?

Because you install it once and use it with any model. Create Component is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Create Component in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/AntonHu/ai-coding-project/tree/main/.agents/skills/create-component. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Create Component?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Create Component?

As many as you like. As long as a model supports skills, you can use Create Component with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Create Component AI skill free?

It is published on GitHub by AntonHu. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇