Communitygithub.com

0xAlchemist-cs/personal-ui-system

在用户任务涉及 Ant Design (antd) 时使用——编写 antd 组件、调试 antd 问题、查询 antd API/属性/Token/示例、在 antd 版本间迁移,或分析项目中的 antd 使用情况。当出现 antd 相关代码、来自 'antd' 的导入或明确的 antd 问题时触发。

personal-ui-system 是什么?

此技能为 AI 助手提供了本地化的 `@ant-design/cli` 命令行工具,其中包含了 antd v4/v5/v6 的完整元数据以及 v3→v4、v4→v5、v5→v6 的迁移指南。该工具完全离线运行,无需网络,支持使用 JSON 结构输出,非常适合自动解析和处理。技能涵盖编写 antd 组件前的 API 查询、问题调试、版本迁移检查、项目分析、Bug 报告以及作为 MCP 服务器在 IDE 中提供服务等场景。此外,它提供了严格的规则,例如“在编写前先查询”、“匹配用户使用的 antd 版本”、“始终使用 `--format json`”和“更改后执行 lint”,以确保 AI 代理能够准确、可靠地协助用户进行 antd 开发工作。

兼容平台✓Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/0xAlchemist-cs/personal-ui-system/tree/HEAD/.agents/skills/antd

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Ant Design CLI

您可以使用 @ant-design/cli——一个本地 CLI 工具,其中包含了 v4/v5/v6 的 antd 元数据(以及 v3→v4、v4→v5、v5→v6 的迁移指南)。使用它来查询组件知识、分析项目并指导迁移。所有数据离线可用,无需网络。

安装

首次使用前,检查 CLI 是否已安装。如果未安装,请自动安装:

which antd || npm install -g @ant-design/cli

运行任何命令后,如果输出包含 "Update available" 提示,请先运行 antd upgrade 更新,然后再继续。

始终使用 --format json 以获得结构化的输出,便于编程解析。

场景

1. 编写 antd 组件代码

在编写任何 antd 组件代码之前,首先查阅其 API——不要依赖记忆。

# 查看可用的属性
antd info Button --format json

# 获取一个可用的示例作为起点
antd demo Button basic --format json

# 检查用于自定义样式的语义化 className / styles
antd semantic Button --format json

# 检查用于主题定制的组件级设计 Token
antd token Button --format json

# 获取整体设计语言(design.md):颜色、排版、间距、圆角 + 设计原则
antd design.md --format json

工作流程: antd info → 理解属性 → antd demo → 获取工作示例 → 编写代码。

2. 查询完整文档

当您需要全面的组件文档(不仅仅是属性)时:

antd doc Table --format json        # Table 的完整 Markdown 文档
antd doc Table --lang zh            # 中文文档

3. 调试 antd 问题

当代码未能按预期工作或用户报告 antd 错误时:

# 收集完整的环境快照(系统、依赖、浏览器、构建工具)
antd env --format json

# 检查该属性在用户使用的 antd 版本中是否存在
antd info Select --version 5.12.0 --format json

# 检查属性是否已被弃用
antd lint ./src/components/MyForm.tsx --format json

# 诊断项目级配置问题
antd doctor --format json

工作流程: antd env → 捕获完整环境 → antd doctor → 检查配置 → antd info --version X → 根据用户的确切版本验证 API → antd lint → 查找已弃用或不正确的用法。

4. 版本间迁移

当用户想要升级 antd(例如 v3→v4 或 v4→v5)时:

# 获取完整的迁移清单
antd migrate 3 4 --format json    # v3 → v4
antd migrate 4 5 --format json    # v4 → v5

# 检查特定组件的迁移指南
antd migrate 4 5 --component Select --format json

# 生成对智能体友好的自动迁移提示(不修改文件)
antd migrate 4 5 --apply ./src --format json

# 查看两个版本之间发生了什么变化
antd changelog 4.24.0 5.0.0 --format json

# 查看特定组件的变更
antd changelog 4.24.0 5.0.0 Select --format json

工作流程: antd migrate → 获取完整清单 → antd changelog <v1> <v2> → 理解不兼容的变更 → 应用修复 → antd lint → 验证是否没有残留已弃用的用法。

5. 分析项目 antd 使用情况

当用户想要了解 antd 在其项目中的使用方式时:

# 扫描组件使用统计信息
antd usage ./src --format json

# 过滤到特定组件
antd usage ./src --filter Form --format json

# 检查是否违反最佳实践
antd lint ./src --format json

# 仅检查特定规则类别
antd lint ./src --only deprecated --format json
antd lint ./src --only a11y --format json
antd lint ./src --only performance --format json

6. 检查变更日志和版本历史

当用户询问某个版本中发生了什么更改时:

# 特定版本的变更日志
antd changelog 5.22.0 --format json

# 版本范围(包含两端)
antd changelog 5.21.0..5.24.0 --format json

7. 浏览可用的组件

当用户正在选择要使用的组件时:

# 列出所有组件及其分类
antd list --format json

# 列出特定 antd 版本的组件
antd list --version 5.0.0 --format json

8. 收集环境信息

当您需要了解项目的 antd 配置,或为错误报告准备信息时:

# 完整的环境快照(文本——粘贴到 GitHub Issues 中)
antd env

# 结构化的 JSON,用于编程使用
antd env --format json

# 扫描特定项目目录
antd env ./my-project --format json

收集的信息包括:操作系统、Node.js、包管理器(npm/pnpm/yarn/bun/utoo)、npm 注册表、浏览器、核心依赖(antd/react/dayjs)、所有 @ant-design/* 和 rc-* 包,以及构建工具(umi/vite/webpack/typescript 等)。

9. 报告 antd 错误

当用户要求您报告 antd 错误时:

# 步骤 0:收集环境信息以供参考(可选——antd bug 已嵌入基本环境信息)
# 使用输出来交叉检查版本或向错误报告附加额外详细信息
antd env --format json

# 步骤 1:供用户预览
antd bug --title "DatePicker 选择日期时崩溃" \
  --reproduction "https://codesandbox.io/s/xxx" \
  --steps "1. 打开 DatePicker 2. 点击一个日期" \
  --expected "日期被选中" \
  --actual "组件崩溃并报错" \
  --format json

# 步骤 2:展示给用户,请求确认

# 步骤 3:用户确认后提交
antd bug --title "DatePicker 选择日期时崩溃" \
  --reproduction "https://codesandbox.io/s/xxx" \
  --steps "1. 打开 DatePicker 2. 点击一个日期" \
  --expected "日期被选中" \
  --actual "组件崩溃并报错" \
  --submit

10. 报告 CLI 问题

当用户要求您报告 CLI 错误,或明确请求帮助提交问题时:

# 为用户预览错误报告
antd bug-cli --title "antd info Button 为 v5.12.0 返回了错误的属性" \
  --description "查询 Button 属性时针对版本 5.12.0,输出包含该版本中不存在的属性" \
  --steps "1. 运行:antd info Button --version 5.12.0 --format json" \
  --expected "与 antd 5.12.0 Button API 匹配的属性" \
  --actual "输出包含 'classNames',该属性在 5.16.0 中才添加" \
  --format json

向用户展示报告并在提交前确认:

antd bug-cli --title "antd info Button 为 v5.12.0 返回了错误的属性" \
  --description "..." \
  --steps "..." \
  --expected "..." \
  --actual "..." \
  --submit

选择退出: 如果设置了环境变量 ANTD_NO_AUTO_REPORT=1,则完全跳过所有 Bug 报告建议——除非用户直接要求,否则不要建议 antd bug 或 antd bug-cli。

11. 升级 CLI

当用户想要将 @ant-design/cli 更新到最新版本,或者出现 "Update available" 提示时:

# 升级到最新版本(自动检测包管理器)
antd upgrade

该命令会检测安装 CLI 的包管理器(npm, yarn, pnpm, bun, cnpm, utoo)并运行相应的升级命令。如果检测失败,它会建议手动命令。

12. 作为 MCP 服务器使用

如果在支持 MCP 的 IDE(Claude Desktop、Cursor 等)中工作,CLI 也可以作为 MCP 服务器运行,直接公开所有知识查询工具:

{
  "mcpServers": {
    "antd": {
      "command": "antd",
      "args": ["mcp", "--version", "5.20.0"]
    }
  }
}

这通过 MCP 协议提供 8 个工具(antd_list、antd_info、antd_doc、antd_demo、antd_token、antd_design_md、antd_semantic、antd_changelog)和 2 个提示(antd-expert、antd-page-generator)。

全局标志

标志用途
--format <format>输出格式:json、text 或 markdown(智能体应优先使用 json)
--version <v>定位特定的 antd 版本(例如 5.20.0)
--lang zh中文输出(默认:en)
--detail包含额外字段(描述、引入版本、弃用状态、常见问题)
-V, --cli-version打印 CLI 版本并退出

关键规则

  1. 始终先查询再编写 —— 不要凭记忆猜测 antd API。先运行 antd info。
  2. 匹配用户的版本 —— 知识查询(list/info/doc/demo/token/semantic/changelog)支持 antd v4+。如果项目使用 antd 4.x/5.x/6.x,请传递 --version 4.24.0 / 5.24.0 / 6.x。对于 antd v3 项目,请先使用 antd migrate 3 4。
  3. 使用 --format json —— 每个命令都支持。解析 JSON 输出,而不是使用正则匹配文本输出。
  4. 在建议迁移之前先检查 —— 在建议版本升级之前,请先运行 antd changelog <v1> <v2> 和 antd migrate。
  5. 更改后执行 lint —— 在编写或修改 antd 代码后,对更改的文件运行 antd lint 以捕获已弃用或存在问题的用法。
  6. 报告 antd 错误 —— 当用户要求报告 antd 错误时,请使用 antd bug。始终先预览,获得用户确认,然后提交。
  7. 报告 CLI 问题 —— 当用户询问 CLI 问题时,请使用 antd bug-cli 帮助他们提交报告。始终先预览,获得用户确认,然后提交。

Individual skills in this repo

This repo contains 4 individual skills — each has its own dedicated page.

0xAlchemist-cs/personal-ui-system

Build responsive, accessible UI components and layouts using Chakra UI v3, install or configure Chakra UI in new and existing projects, and design scalable themes using tokens, semantic tokens, recipes, and slot recipes. Use this skill whenever a user asks to build, create, or generate any UI component, page, form, dashboard, navbar, card, landing section, pricing table, or layout using Chakra UI; wants to add Chakra UI to a project, set up ChakraProvider, run CLI snippets, configure color mode, or fix provider wrapping; or asks about theming — defining brand colors, design tokens, semantic tokens, dark mode values, component recipes, slot recipes, typegen, or ejecting the default theme. Trigger on any Chakra UI building, setup, or theming or charts request, however casually phrased — "add my brand colors", "make a reusable card style", "build a bar chart", "show me a line chart", "make me a login form", "build a sidebar", "add Chakra to my app".

0xAlchemist-cs/personal-ui-system

Migrate Chakra UI projects from v2 to v3, covering package changes, codemods, provider setup, color mode, prop renaming, compound components, theming, recipes, and Next.js updates. Use this skill whenever a user is upgrading Chakra UI versions, encountering breaking changes after an upgrade, converting old v2 patterns (ColorModeScript, useColorModeValue, styleConfig, extendTheme, isDisabled, colorScheme, @chakra-ui/icons, framer-motion dependency), fixing compound component patterns, or asking about differences between Chakra UI v2 and v3 — even if they don't say "migrate" or "upgrade" explicitly.

0xAlchemist-cs/personal-ui-system

Review, convert, and improve UI code using Chakra UI v3. Use this skill whenever a user wants to review Chakra UI code for issues, convert plain HTML/CSS, Tailwind, CSS Modules, or styled-components to Chakra UI, clean up messy Chakra components, fix layout structure or token usage, or asks anything like "is this correct", "what's wrong with this", "review my component", "refactor this", "clean up", "convert", or "chakra-ify this" — even without the words "review" or "refactor". Trigger on any request to check, improve, or convert Chakra UI code, however casually phrased.

0xAlchemist-cs/personal-ui-system

Integrates Material UI with Next.js App and Pages routers using @mui/material-nextjs, Emotion cache providers, next/font, CSS layers with Tailwind/CSS Modules, Link component prop patterns, CSS theme variables SSR notes, and App Router useSearchParams + Suspense. Use when setting up or debugging MUI in a Next.js app.

相关技能