AGENTS.md · ant-design/ant-design
AGENTS.md from ant-design/ant-design: 294 lines covering 项目信息, 通用编码规范, 样式优先级规范, Demo 导入规范 and more.
Template by ant-design
Chalk Labs
Need help deploying AGENTS.md · ant-design/ant-design?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
Install
Works with Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Claude Code. Read the repository before you give any tool access to your data.
curl -fsSL https://raw.githubusercontent.com/ant-design/ant-design/master/AGENTS.md -o AGENTS.md
Read it and adapt it to your project before use.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: prompt-engineering
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
What's in it
An AGENTS.md file: instructions coding agents (Codex, Cursor, Copilot, Gemini CLI and others) read before working in a repo.
- For
- Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Claude Code
- Length
- 294 lines
- File
AGENTS.md
Sections
- 项目信息
- 通用编码规范
- 样式优先级规范
- Demo 导入规范
- Test 导入规范
- 文档规范
- PR 规范
- Changelog 规范
- 参考资源
- 编码行为准则
First lines (shown under the repo's MIT license)
# Ant Design 项目开发指南
> 本文件为 AI 编程助手提供项目上下文和开发规范。
## 项目信息
- React 组件库,发布为 npm 包 `antd`
- 使用 TypeScript 和 React 开发
- 采用 CSS-in-JS 架构(基于 `@ant-design/cssinjs`)
- 支持 Design Token 主题系统、暗色模式、RTL 布局、SSR、国际化(150+ 语言)
### 项目结构
```
ant-design/
├── components/ # 组件源代码(84+ 组件)
│ ├── component-name/ # 单个组件目录
│ │ ├── ComponentName.tsx # 主组件实现
│ │ ├── demo/ # 演示代码(*.tsx 和 *.md)
│ │ ├── style/ # 样式系统(index.ts / token.ts)
│ │ ├── __tests__/ # 单元测试
│ │ ├── index.en-US.md # 英文文档
│ │ ├── index.zh-CN.md # 中文文档
│ │ └── index.tsx # 导出入口
│ ├── _util/ # 共享工具函数库
│ ├── theme/ # 主题系统
│ └── locale/ # 国际化文本
├── tests/ # 测试工具和共享测试
├── docs/ # 站点文档
├── CHANGELOG.zh-CN.md # 中文更新日志
└── CHANGELOG.en-US.md # 英文更新日志
```
---
## 通用编码规范
- 判断数据类型时,优先使用 `@rc-component/util` 中的 `isNonNullable`、`isReactRenderable`,或 `components/_util/is.ts` 中已有的方法,例如 `isNumber`、`isString`、`isPlainObject`、`isFunction`、`isThenable`、`isPrimitive`。
- 仅当 `components/_util/is.ts` 中没有合适方法,或当前场景需要更严格、更特殊的判断逻辑时,再使用内联 `typeof`、`instanceof` 等判断方式。
## 样式优先级规范
- 当组件根节点同时支持 ConfigProvider 的 `styles.root`、ConfigProvider 的 `style`、组件自身的 `styles.root` 和组件自身的 `style` 时,优先级从低到高为:ConfigProvider `styles.root` -> ConfigProvider `style` -> 组件 `styles.root` -> 组件 `style`;如在 util 层预合并根节点样式,预合并结果内部应保持前三者的同样顺序,组件自身 `style` 保持最终最高优先级。
---
## Demo 导入规范
- 常规 `components/**/demo/` 文件在引入 Ant Design 组件、组件内部模块、工具方法、变量、类型定义时,一律使用绝对路径导入,不使用相对路径导入。
- `components/**/demo/_semantic*.tsx` 属于语义文档专用 demo,是例外场景:允许通过相对路径引用 `.dumi/hooks/useLocale`、`.dumi/theme/common/*` 等站点侧辅助模块。
- `.dumi/` 目录内部的站点实现文件可按现有目录结构使用相对路径引用本目录模块;当引用仓库内 Ant Design 组件入口时,优先使用项目公开入口或已配置别名。
- 允许的导入形式应优先使用项目公开入口或已配置别名,例如:`antd`、`antd/es/*`、`antd/lib/*`、`antd/locale/*`、`@@/*`。
- `.dumi/*` 不是仓库通用的 TS 路径别名;如需引用 `.dumi` 内部模块,请按文件位置使用相对路径。
- 常规 demo 文件中,禁止使用 `..`、`../xxx`、`../../xxx`、`./xxx` 这类相对路径去引用组件实现、内部模块、方法、变量、类型,包含跨 demo、跨目录复用的场景。
- 常规 demo 与 `.dumi` 文件之间不要互相相对引用(`_semantic*.tsx` 等站点语义 demo 复用 `.dumi` 辅助模块除外)。如果需要复用少量逻辑,优先内联,或提取到可通过绝对路径访问的公共位置。
## Test 导入规范
- 本规范适用于 `components/**/__tests__/` 下的测试文件。
- 在这些目录下引入 Ant Design 组件,或引入组件内部模块、工具方法、变量、类型定义时,一律使用相对路径导入,不使用绝对路径导入。
- 测试文件应优先从当前组件目录、相邻内部模块或共享测试工具目录通过相对路径引用,例如:`..`、`../index`、`../xxx`、`../../_util/*`、`../../../tests/shared/*`。
- 禁止在 `__tests__` 目录下使用 `antd`、`antd/es/*`、`antd/lib/*`、`antd/locale/*`、`.dumi/*`、`@@/*` 这类绝对路径或别名路径去引用仓库内代码。
- 如需引用仓库外第三方依赖,仍按依赖包名正常导入,例如 `react`、`@testing-library/react`、`dayjs`。
---
## 文档规范
### API 表格格式
英文版:
| Property | Description | Type | Default | Version | [Global Config](/components/config-provider#component-config) |
| --- | --- | --- | --- | --- | --- |
| disabled | Whether the component is disabled | boolean | false | - | × |
| loadingIcon | (Only supports global configuration) Custom loading icon | ReactNode | - | - | 6.2.0 |
| type | Button type | `primary` \| `default` | `default` | - | ✔ |
中文版:
| 参数 | 说明 | 类型 | 默认值 | 版本 | [全局配置](/components/config-provider-cn#component-config) |
| --- | --- | --- | --- | --- | --- |
| disabled | 是否禁用 | boolean | false | - | × |
| loadingIcon | (仅支持全局配置) 自定义加载图标 | ReactNode | - | × | 6.2.0 |
| type | 按钮类型 | `primary` \| `default` | `default` | - | ✔ |
列说明:
- 参数:按字母顺序排列,忽略 className, style, onClick, onKeyDown 等通用属性, onChange, onClick 等事件回调放在最后
- 说明:简洁描述参数作用,如果仅支持全局配置需在描述中用括号注明
- 类型:使用 TypeScript 定义的类型
- 默认值:字符串用反引号,布尔/数字直接写,无默认值用 `-`
- 版本:新增属性需声明引入的版本号;上个大版本已存在属性标注 `-`;仅支持全局配置的属性标注 `×`
- 全局配置:支持全局配置的属性需标注版本号;上个大版本已支持的标注 `✔`;不支持全局配置的属性标注 `×`
### 文档锚点 ID 规范
- 中文标题必须手动指定英文锚点:`## 中文标题 {#english-anchor-id}`
- 锚点 ID 符合 `^[a-zA-Z][\w-:\.]*$`,长度不超过 32 字符
- FAQ 章节下的锚点必须以 `faq-` 为前缀
- 同一问题的中英文锚点保持一致
### 国际化规范
- 本地化配置文件:`components/locale/`,命名如 `zh_CN.ts`、`en_US.ts`
- 添加或修改本地化配置时,需同时修改所有语言文件
- 类型入口:`components/locale/index.tsx`
---
## PR 规范
### 标题与内容
- PR 标题始终使用英文,格式:`类型: 简短描述`
- PR 内容默认使用英文,可根据用户语言习惯决定使用中文或英文
- 示例:`fix: fix button style issues in Safari browser`
### PR 模板(必须使用)
- 英文模板:`.github/PULL_REQUEST_TEMPLATE.md`
- 中文模板:`.github/PULL_REQUEST_TEMPLATE_CN.md`
- 使用 `gh pr create` 创建 PR 时,必须手动填充模板内容
### 分支策略
- 新特性开发需基于 `feature` 分支,PR 目标分支也需为 `feature`
- 其余提交至 `master` 分支
- 当前 PR 的目标分支为 `master` 时,必须先基于最新的 `feature` 分支进行一次模拟合并,并结合当前 PR 的 diff 逐项判断冲突来源;仅当当前 PR 的改动内容与 `feature` 存在冲突时,才将 PR 目标分支改为 `feature`,按下条规则清理提交历史并解决相关冲突;若无冲突,或冲突仅来自 `master` 与 `feature` 之间与当前 PR 无关的改动,则保持目标分支为 `master`。不得仅因存在冲突,或冲突文件与 PR 改动文件相同,就改投 `feature`。
- PR 的原目标分支为 `master` 时,若需更改目标分支为 `feature` 或 `next`,必须先对 PR 源分支进行 rebase 清理,仅将当前 PR 的相关提交重放到新目标分支的最新版本上,保持提交历史干净;不得带入 `master` 上与当前 PR 无关的他人提交或改动。清理后需检查相对新目标分支的提交列表和 diff,确认仅包含当前 PR 的预期改动。
- 分支命名规范:
- 功能开发:`feat/description-of-feature`
- 问题修复:`fix/issue-number-or-description`
- 文档更新:`docs/what-is-changed`
- 代码重构:`refactor/what-is-changed`
### PR 改动类型
- 🆕 新特性提交
- 🐞 Bug 修复
- 📝 文档改进
- 📽️ 演示代码改进
- 💄 样式/交互改进
- 🤖 TypeScript 更新
- 📦 包体积优化
- ⚡️ 性能优化
- 🌐 国际化改进
---
## Changelog 规范
### 适用范围
- 本节仅适用于用户明确要求收集/生成 changelog、准备 release PR、版本发布,或正在编辑 `CHANGELOG.en-US.md` / `CHANGELOG.zh-CN.md` 的场景。
- 普通功能、修复、文档、demo PR 不要求直接修改 `CHANGELOG.en-US.md` / `CHANGELOG.zh-CN.md`;代码 CR 时也不应仅因缺少 CHANGELOG 文件改动而提出 finding。
- 普通 PR 如需填写 PR 模板中的 Change Log,仅描述本 PR 对用户或开发者的影响,或按模板填写 `N/A` / `No changelog required` / `无需更新日志`。正式 CHANGELOG 由 release owner 在发布流程中统一整理。
### 核心原则Signals
- Stars
- 99,886
- Forks
- 54,642
- Open issues
- 961
- Last commit (this folder)
- Oct 17, 2026 (14 days ago)
- Last release
- Oct 20, 2026 (11 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/ant-design/ant-design
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from ant-design
- 0.849score
ant-design-pro (starter)
ant-design
👨🏻💻👩🏻💻 Use Ant Design like a Pro!
TemplateAFreshness: A★ 38.9K - 0.812score
CLAUDE.md · ant-design/ant-design-pro
ant-design
CLAUDE.md from ant-design/ant-design-pro: 130 lines covering Project, Commands, Critical Rules, Architecture Essentials and more.
TemplateBFreshness: B★ 38.9KClaude Code
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get AGENTS.md · ant-design/ant-design running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
AGENTS.md · ant-design/ant-design. Agent Mart. https://agentmart.dev/templates/ant-design-ant-design-agents-md (last updated 2026-10-24)