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/cliAlways use for structured output you can parse programmatically.
--format json首次使用前,检查CLI是否已安装。如果未安装,自动安装:
bash
which antd || 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选择日期时崩溃"
--reproduction "https://codesandbox.io/s/xxx"
--steps "1. 打开DatePicker 2. 点击日期"
--expected "日期被选中"
--actual "组件崩溃并抛出错误"
--format json
--reproduction "https://codesandbox.io/s/xxx"
--steps "1. 打开DatePicker 2. 点击日期"
--expected "日期被选中"
--actual "组件崩溃并抛出错误"
--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选择日期时崩溃"
--reproduction "https://codesandbox.io/s/xxx"
--steps "1. 打开DatePicker 2. 点击日期"
--expected "日期被选中"
--actual "组件崩溃并抛出错误"
--submit
--reproduction "https://codesandbox.io/s/xxx"
--steps "1. 打开DatePicker 2. 点击日期"
--expected "日期被选中"
--actual "组件崩溃并抛出错误"
--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对v5.12.0版本返回错误属性" \
--description "查询v5.12.0版本的Button属性时,输出包含该版本不存在的属性" \
--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- 向用户展示报告:“我在使用CLI时发现一个问题,这是生成的Bug报告——是否需要提交?”
- 用户确认后提交:
bash
antd bug-cli --title "antd info Button对v5.12.0版本返回错误属性" \
--description "..." \
--steps "..." \
--expected "..." \
--actual "..." \
--submit核心原则:你是CLI的质量反馈环节。不要默默绕过CLI问题——上报问题以使其得到修复。提交前务必获得用户确认。
Global 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