antd
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAnt Design CLI
Ant Design CLI
You have access to — a local CLI tool with bundled antd metadata for v4/v5/v6. Use it to query component knowledge, analyze projects, and guide migrations. All data is offline, no network needed.
@ant-design/cli你可以使用——一款本地CLI工具,内置了v4/v5/v6版本的antd元数据。可用于查询组件知识、分析项目以及指导版本迁移。所有数据均为离线存储,无需网络。
@ant-design/cliSetup
安装配置
Before first use, check if the CLI is installed. If not, install it automatically:
bash
which antd || npm install -g @ant-design/cliAfter running any command, if the output contains an "Update available" notice, run to update before continuing.
npm install -g @ant-design/cliAlways use for structured output you can parse programmatically.
--format json首次使用前,请检查CLI是否已安装。如果未安装,请自动安装:
bash
which antd || npm install -g @ant-design/cli运行任意命令后,如果输出中包含“Update available”(可用更新)提示,请先运行进行更新,然后再继续操作。
npm install -g @ant-design/cli请始终使用参数以获得可通过编程解析的结构化输出。
--format jsonScenarios
使用场景
1. Writing antd component code
1. 编写antd组件代码
Before writing any antd component code, look up its API first — don't rely on memory.
bash
undefined在编写任何antd组件代码之前,请先查阅其API——不要凭记忆猜测。
bash
undefinedCheck what props are available
查看可用属性
antd info Button --format json
antd info Button --format json
Get a working demo as starting point
获取可用的示例作为开发起点
antd demo Button basic --format json
antd demo Button basic --format json
Check semantic classNames/styles for custom styling
查看用于自定义样式的语义化类名/样式
antd semantic Button --format json
antd semantic Button --format json
Check component-level design tokens for theming
查看用于主题定制的组件级设计令牌
antd token Button --format json
**Workflow:** `antd info` → understand props → `antd demo` → grab a working example → write code.antd token Button --format json
**工作流程:** `antd info` → 了解组件属性 → `antd demo` → 获取可用示例 → 编写代码。2. Looking up full documentation
2. 查阅完整文档
When you need comprehensive component docs (not just props):
bash
antd doc Table --format json # full markdown docs for Table
antd doc Table --lang zh # Chinese docs当你需要组件的完整文档(不仅仅是属性)时:
bash
antd doc Table --format json # Table组件的完整Markdown文档
antd doc Table --lang zh # 中文文档3. Debugging antd issues
3. 调试antd问题
When code isn't working as expected or the user reports an antd bug:
bash
undefined当代码未按预期运行或用户反馈antd相关Bug时:
bash
undefinedCheck if the prop exists for the user's antd version
检查该属性在用户使用的antd版本中是否存在
antd info Select --version 5.12.0 --format json
antd info Select --version 5.12.0 --format json
Check if the prop is deprecated
检查属性是否已被废弃
antd lint ./src/components/MyForm.tsx --format json
antd lint ./src/components/MyForm.tsx --format json
Diagnose project-level configuration issues
诊断项目级配置问题
antd doctor --format json
**Workflow:** `antd doctor` → check environment → `antd info --version X` → verify API against the user's exact version → `antd lint` → find deprecated or incorrect usage.antd doctor --format json
**工作流程:** `antd doctor` → 检查环境 → `antd info --version X` → 对照用户使用的具体版本验证API → `antd lint` → 找出已废弃或错误的用法。4. Migrating between versions
4. 版本间迁移
When the user wants to upgrade antd (e.g., v4 → v5):
bash
undefined当用户想要升级antd版本(例如从v4升级到v5)时:
bash
undefinedGet full migration checklist
获取完整的迁移清单
antd migrate 4 5 --format json
antd migrate 4 5 --format json
Check migration for a specific component
查看特定组件的迁移指南
antd migrate 4 5 --component Select --format json
antd migrate 4 5 --component Select --format json
See what changed between two versions
查看两个版本之间的变更内容
antd changelog 4.24.0 5.0.0 --format json
antd changelog 4.24.0 5.0.0 --format json
See changes for a specific component
查看特定组件的版本变更
antd changelog 4.24.0 5.0.0 Select --format json
**Workflow:** `antd migrate` → get full checklist → `antd changelog <v1> <v2>` → understand breaking changes → apply fixes → `antd lint` → verify no deprecated usage remains.antd changelog 4.24.0 5.0.0 Select --format json
**工作流程:** `antd migrate` → 获取完整迁移清单 → `antd changelog <v1> <v2>` → 了解破坏性变更 → 应用修复 → `antd lint` → 验证是否存在已废弃的用法。5. Analyzing project antd usage
5. 分析项目中antd的使用情况
When the user wants to understand how antd is used in their project:
bash
undefined当用户想要了解项目中antd的使用方式时:
bash
undefinedScan component usage statistics
扫描组件使用统计数据
antd usage ./src --format json
antd usage ./src --format json
Filter to a specific component
过滤查看特定组件的使用情况
antd usage ./src --filter Form --format json
antd usage ./src --filter Form --format json
Lint for best practice violations
检查是否违反最佳实践
antd lint ./src --format json
antd lint ./src --format json
Check only specific rule categories
仅检查特定规则类别
antd lint ./src --only deprecated --format json
antd lint ./src --only a11y --format json
antd lint ./src --only performance --format json
undefinedantd lint ./src --only deprecated --format json
antd lint ./src --only a11y --format json
antd lint ./src --only performance --format json
undefined6. Checking changelogs and version history
6. 查看更新日志和版本历史
When the user asks about what changed in a version:
bash
undefined当用户询问某个版本的变更内容时:
bash
undefinedSpecific version changelog
特定版本的更新日志
antd changelog 5.22.0 --format json
antd changelog 5.22.0 --format json
Version range (both ends inclusive)
版本范围(包含两端版本)
antd changelog 5.21.0..5.24.0 --format json
undefinedantd changelog 5.21.0..5.24.0 --format json
undefined7. Exploring available components
7. 探索可用组件
When the user is choosing which component to use:
bash
undefined当用户需要选择合适的组件时:
bash
undefinedList all components with categories
查看所有带分类的组件
antd list --format json
antd list --format json
List components for a specific antd version
查看特定antd版本的可用组件
antd list --version 5.0.0 --format json
undefinedantd list --version 5.0.0 --format json
undefined8. Reporting antd bugs
8. 上报antd Bug
When you encounter a confirmed antd component bug that can't be resolved locally:
bash
undefined当你遇到确认无法在本地解决的antd组件Bug时:
bash
undefinedStep 1: Preview for user review
步骤1:生成预览版供用户查看
antd bug --title "DatePicker crashes when selecting date"
--reproduction "https://codesandbox.io/s/xxx"
--steps "1. Open DatePicker 2. Click a date"
--expected "Date is selected"
--actual "Component crashes with error"
--format json
--reproduction "https://codesandbox.io/s/xxx"
--steps "1. Open DatePicker 2. Click a date"
--expected "Date is selected"
--actual "Component crashes with error"
--format json
antd bug --title "DatePicker crashes when selecting date"
--reproduction "https://codesandbox.io/s/xxx"
--steps "1. Open DatePicker 2. Click a date"
--expected "Date is selected"
--actual "Component crashes with error"
--format json
--reproduction "https://codesandbox.io/s/xxx"
--steps "1. Open DatePicker 2. Click a date"
--expected "Date is selected"
--actual "Component crashes with error"
--format json
Step 2: Show to user, ask for confirmation
步骤2:展示给用户,请求确认
Step 3: Submit after user confirms
步骤3:用户确认后提交
antd bug --title "DatePicker crashes when selecting date"
--reproduction "https://codesandbox.io/s/xxx"
--steps "1. Open DatePicker 2. Click a date"
--expected "Date is selected"
--actual "Component crashes with error"
--submit
--reproduction "https://codesandbox.io/s/xxx"
--steps "1. Open DatePicker 2. Click a date"
--expected "Date is selected"
--actual "Component crashes with error"
--submit
undefinedantd bug --title "DatePicker crashes when selecting date"
--reproduction "https://codesandbox.io/s/xxx"
--steps "1. Open DatePicker 2. Click a date"
--expected "Date is selected"
--actual "Component crashes with error"
--submit
--reproduction "https://codesandbox.io/s/xxx"
--steps "1. Open DatePicker 2. Click a date"
--expected "Date is selected"
--actual "Component crashes with error"
--submit
undefined9. Auto-reporting CLI issues
9. 自动上报CLI问题
IMPORTANT: Whenever you use any CLI command and notice something wrong, you should proactively initiate a bug report using .
antdantd bug-cliTrigger conditions — report a CLI bug when you observe any of these:
- A command crashes or exits with an unexpected error
- A command returns clearly incorrect data (e.g. shows wrong props, missing props, or props from the wrong version)
antd info Button - A command's output doesn't match its documented behavior (e.g. returns non-JSON,
--format jsonis ignored)--version X - A command returns empty or missing data when it shouldn't (e.g. returns no demos,
antd demo Buttonreturns no tokens for v5+)antd token Button - Inconsistencies between commands (e.g. shows a component but
antd listsays it doesn't exist)antd info
Workflow:
- You notice something wrong while using the CLI
- Gather evidence: the exact command you ran, what was returned, and what you expected
- Preview the bug report for the user:
bash
antd bug-cli --title "antd info Button returns wrong props for v5.12.0" \
--description "When querying Button props for version 5.12.0, the output includes props that don't exist in that version" \
--steps "1. Run: antd info Button --version 5.12.0 --format json" \
--expected "Props matching antd 5.12.0 Button API" \
--actual "Props include 'classNames' which was added in 5.16.0" \
--format json- Show the report to the user: "I noticed an issue with the CLI while working. Here's a bug report — shall I submit it?"
- Submit after user confirms:
bash
antd bug-cli --title "antd info Button returns wrong props for v5.12.0" \
--description "..." \
--steps "..." \
--expected "..." \
--actual "..." \
--submitKey principle: You are a quality feedback loop for the CLI. Don't silently work around CLI issues — report them so they get fixed. Always confirm with the user before submitting.
重要提示:无论何时使用 CLI命令,若发现异常,都应主动使用发起Bug上报。
antdantd bug-cli触发条件——当你观察到以下任意情况时,上报CLI Bug:
- 命令崩溃或退出时出现意外错误
- 命令返回明显错误的数据(例如显示错误的属性、缺失属性,或者来自错误版本的属性)
antd info Button - 命令的输出与文档描述的行为不符(例如返回非JSON内容,
--format json参数被忽略)--version X - 命令在不应返回空数据时返回空或缺失数据(例如未返回示例,
antd demo Button未返回v5+版本的设计令牌)antd token Button - 命令之间存在不一致(例如显示某组件存在,但
antd list提示该组件不存在)antd info
工作流程:
- 使用CLI时发现异常
- 收集证据:你执行的具体命令、返回结果以及预期结果
- 生成Bug上报预览版供用户查看:
bash
antd bug-cli --title "antd info Button returns wrong props for v5.12.0" \
--description "When querying Button props for version 5.12.0, the output includes props that don't exist in that version" \
--steps "1. Run: antd info Button --version 5.12.0 --format json" \
--expected "Props matching antd 5.12.0 Button API" \
--actual "Props include 'classNames' which was added in 5.16.0" \
--format json- 向用户展示上报内容:“我在使用CLI时发现了一个问题,这是生成的Bug上报——是否需要提交?”
- 用户确认后提交:
bash
antd bug-cli --title "antd info Button returns wrong props for v5.12.0" \
--description "..." \
--steps "..." \
--expected "..." \
--actual "..." \
--submit核心原则: 你是CLI的质量反馈环节。不要默默绕过CLI问题——请上报问题以便修复。提交前务必获得用户确认。
10. Using as MCP server
10. 作为MCP服务器使用
If working in an IDE that supports MCP (Claude Desktop, Cursor, etc.), the CLI can also run as an MCP server, exposing all knowledge-query tools directly:
json
{
"mcpServers": {
"antd": {
"command": "antd",
"args": ["mcp", "--version", "5.20.0"]
}
}
}This provides 7 tools (, , , , , , ) and 2 prompts (, ) via MCP protocol.
antd_listantd_infoantd_docantd_demoantd_tokenantd_semanticantd_changelogantd-expertantd-page-generator如果在支持MCP的IDE(如Claude Desktop、Cursor等)中工作,CLI还可以作为MCP服务器运行,直接暴露所有知识查询工具:
json
{
"mcpServers": {
"antd": {
"command": "antd",
"args": ["mcp", "--version", "5.20.0"]
}
}
}通过MCP协议,你可以使用7个工具(, , , , , , )和2个提示词(, )。
antd_listantd_infoantd_docantd_demoantd_tokenantd_semanticantd_changelogantd-expertantd-page-generatorGlobal Flags
全局参数
| Flag | Purpose |
|---|---|
| Structured output — always use this |
| Target a specific antd version (e.g. |
| Chinese output (default: |
| Include extra fields (description, since, deprecated, FAQ) |
| 标志 | 用途 |
|---|---|
| 结构化输出——请始终使用该参数 |
| 指定目标antd版本(例如 |
| 中文输出(默认:英文) |
| 包含额外字段(描述、新增版本、废弃信息、常见问题) |
Key Rules
核心规则
- Always query before writing — Don't guess antd APIs from memory. Run first.
antd info - Match the user's version — If the project uses antd 4.x, pass . The CLI auto-detects from
--version 4.24.0if no flag is given.node_modules - Use — Every command supports it. Parse the JSON output rather than regex-matching text output.
--format json - Check before suggesting migration — Run and
antd changelog <v1> <v2>before advising on version upgrades.antd migrate - Lint after changes — After writing or modifying antd code, run on the changed files to catch deprecated or problematic usage.
antd lint - Report antd bugs — When you encounter an antd component bug, use to report it. Always preview first, get user confirmation, then submit.
antd bug - Auto-report CLI issues — If any command crashes, returns wrong data, or behaves inconsistently, proactively use
antdto report it. You are the quality feedback loop for the CLI — don't silently work around issues.antd bug-cli
- 编写前先查询 —— 不要凭记忆猜测antd的API。先运行。
antd info - 匹配用户的版本 —— 如果项目使用antd 4.x版本,请传入参数。如果未指定版本,CLI会自动从
--version 4.24.0中检测。node_modules - 使用—— 所有命令均支持该参数。请解析JSON输出,而非通过正则匹配文本输出。
--format json - 建议迁移前先检查 —— 在建议版本升级前,先运行和
antd changelog <v1> <v2>。antd migrate - 修改后检查 —— 编写或修改antd代码后,运行检查修改后的文件,以发现已废弃或有问题的用法。
antd lint - 上报antd Bug —— 当你遇到antd组件Bug时,使用上报。请先生成预览版,获得用户确认后再提交。
antd bug - 自动上报CLI问题 —— 如果任何命令崩溃、返回错误数据或行为不一致,请主动使用
antd上报。你是CLI的质量反馈环节——不要默默绕过问题。antd bug-cli