[Coding Agent] add claude skills for API Compatibility#7899
[Coding Agent] add claude skills for API Compatibility#7899sunzhongkai588 merged 1 commit intoPaddlePaddle:developfrom
Conversation
|
感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-7899.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html |
📚 本次 PR 文档预览链接(点击展开)
|
7e492b2 to
b3d561c
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR adds a Claude skill-based workflow for “Paddle API 对齐 PyTorch” and refreshes the API compatibility guide to document the new end-to-end and step-by-step usage.
Changes:
- Reworked the API compatibility README to describe the new skill体系, usage modes, and step workflow.
- Added multiple
.claude/skills/*/SKILL.mddocuments to define per-step skills (decision, implementation, validation, docs update, PR creation). - Added an orchestrator skill (
api-compatibility) describing the full pipeline and constraints.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/dev_guides/coding_agent/api_compatibility/README.md | Updates the guide to the new skill体系 and documents one-shot vs step-by-step usage. |
| docs/dev_guides/coding_agent/api_compatibility/.claude/skills/api-compatibility/SKILL.md | Adds the orchestrator skill spec (project goals,流程/约束、调用子技能). |
| docs/dev_guides/coding_agent/api_compatibility/.claude/skills/api-change-decider/SKILL.md | Adds Step1 decision skill spec (diff analysis + scheme selection). |
| docs/dev_guides/coding_agent/api_compatibility/.claude/skills/python-decorator/SKILL.md | Adds Step2 Python decorator implementation playbook. |
| docs/dev_guides/coding_agent/api_compatibility/.claude/skills/cpp-sink/SKILL.md | Adds Step2 C++ sinking implementation playbook. |
| docs/dev_guides/coding_agent/api_compatibility/.claude/skills/pytorch-alignment-validator/SKILL.md | Adds Step3 PaConvert-based alignment validation playbook. |
| docs/dev_guides/coding_agent/api_compatibility/.claude/skills/api-docs-updater/SKILL.md | Adds Step4 Chinese docs update playbook. |
| docs/dev_guides/coding_agent/api_compatibility/.claude/skills/create-pr/SKILL.md | Adds Step4 PR creation instructions across three repos. |
There was a problem hiding this comment.
Markdown 表格行首使用了 ||,在 GitHub Flavored Markdown 下会多出一个空白列,导致渲染错位。建议统一改为单个 | 起始(如 | 阶段 | Skill | 用途 |),并在本 PR 新增的其他 SKILL 文档表格处保持一致。
There was a problem hiding this comment.
分步示例里同时执行了 /cpp-sink 和 /python-decorator 两种 Step2 实现方式,但实际应根据 Step1 的方案二选一;按当前文案会误导读者把两种修改叠加。建议改成条件分支说明(例如“若方案=cpp-sink 则运行 /cpp-sink,否则运行 /python-decorator”),或给出两个互斥的示例流程。
| /api-change-decider torch.atan # 先确定方案 | |
| # 若 Step1 判定为“方案 2:C++下沉”,则执行: | |
| /cpp-sink torch.atan | |
| # 若 Step1 判定为“方案 1:Python 装饰器”,则执行: | |
| /python-decorator torch.atan |
| --- | ||
| name: pytorch-alignment-validator | ||
| description: 仅用于《Paddle API 对齐 PyTorch 项目》,负责 Step3:Pytorch 对齐验证,基于 PaConvert 工具验证 Paddle API 与 PyTorch API 是否用法完全对齐一致 | ||
| allowed-tools: Read Grep Glob Write Edit Bash(python *) |
There was a problem hiding this comment.
allowed-tools 这一行在 Grep/Glob/Write/Edit 之间疑似包含零宽字符(不可见分隔符),可能导致工具白名单解析失败或在不同环境下行为不一致。建议删除这些特殊字符并用普通空格分隔,保证 frontmatter 为纯 ASCII/UTF-8 可见字符。
| allowed-tools: Read Grep Glob Write Edit Bash(python *) | |
| allowed-tools: Read Grep Glob Write Edit Bash(python *) |
| ## Step 3:推送代码到 upstream claude 分支 | ||
|
|
||
| ```bash | ||
| # Paddle 仓库 | ||
| cd /path/to/Paddle | ||
| git push upstream HEAD:claude -f | ||
|
|
||
| # docs 仓库 | ||
| cd /path/to/docs | ||
| git push upstream HEAD:claude -f | ||
|
|
||
| # PaConvert 仓库 | ||
| cd /path/to/PaConvert | ||
| git push upstream HEAD:claude -f |
There was a problem hiding this comment.
这里把 remote(upstream)、分支名(claude)以及 GitHub 用户名(zhwesky2010)写死,会导致他人按文档执行时大概率失败(remote 名称不同、分支策略不同、fork 用户名不同)。建议将这些改为占位符/变量(例如 <GITHUB_USER>、<BRANCH>、<REMOTE>),或加入获取当前用户/remote 的命令指引(如用 gh api user -q .login 获取 login),避免流程不可复用。
| ## Step 3:推送代码到 upstream claude 分支 | |
| ```bash | |
| # Paddle 仓库 | |
| cd /path/to/Paddle | |
| git push upstream HEAD:claude -f | |
| # docs 仓库 | |
| cd /path/to/docs | |
| git push upstream HEAD:claude -f | |
| # PaConvert 仓库 | |
| cd /path/to/PaConvert | |
| git push upstream HEAD:claude -f | |
| ## Step 3:推送代码到指定 remote 和分支 | |
| 请先根据本地仓库实际配置确认用于推送的 remote 名称和目标分支名,并将下面命令中的 `<REMOTE>`、`<BRANCH>` 替换为对应值。 | |
| ```bash | |
| # Paddle 仓库 | |
| cd /path/to/Paddle | |
| git push <REMOTE> HEAD:<BRANCH> | |
| # docs 仓库 | |
| cd /path/to/docs | |
| git push <REMOTE> HEAD:<BRANCH> | |
| # PaConvert 仓库 | |
| cd /path/to/PaConvert | |
| git push <REMOTE> HEAD:<BRANCH> |
| ## Step 3:推送代码到 upstream claude 分支 | ||
|
|
||
| ```bash | ||
| # Paddle 仓库 | ||
| cd /path/to/Paddle | ||
| git push upstream HEAD:claude -f | ||
|
|
||
| # docs 仓库 | ||
| cd /path/to/docs | ||
| git push upstream HEAD:claude -f | ||
|
|
||
| # PaConvert 仓库 | ||
| cd /path/to/PaConvert | ||
| git push upstream HEAD:claude -f |
There was a problem hiding this comment.
这里把 remote(upstream)、分支名(claude)以及 GitHub 用户名(zhwesky2010)写死,会导致他人按文档执行时大概率失败(remote 名称不同、分支策略不同、fork 用户名不同)。建议将这些改为占位符/变量(例如 <GITHUB_USER>、<BRANCH>、<REMOTE>),或加入获取当前用户/remote 的命令指引(如用 gh api user -q .login 获取 login),避免流程不可复用。
| ## Step 3:推送代码到 upstream claude 分支 | |
| ```bash | |
| # Paddle 仓库 | |
| cd /path/to/Paddle | |
| git push upstream HEAD:claude -f | |
| # docs 仓库 | |
| cd /path/to/docs | |
| git push upstream HEAD:claude -f | |
| # PaConvert 仓库 | |
| cd /path/to/PaConvert | |
| git push upstream HEAD:claude -f | |
| ## Step 3:推送代码到指定 remote 的目标分支 | |
| 将下面命令中的 `<REMOTE>` 和 `<BRANCH>` 替换为当前仓库实际使用的 remote 名称和目标分支名后再执行。 | |
| ```bash | |
| # Paddle 仓库 | |
| cd /path/to/Paddle | |
| git push <REMOTE> HEAD:<BRANCH> | |
| # docs 仓库 | |
| cd /path/to/docs | |
| git push <REMOTE> HEAD:<BRANCH> | |
| # PaConvert 仓库 | |
| cd /path/to/PaConvert | |
| git push <REMOTE> HEAD:<BRANCH> |
| )" | ||
|
|
||
| # Docs PR | ||
| gh pr create --repo PaddlePaddle/docs --base develop --head zhwesky2010:claude \ |
There was a problem hiding this comment.
这里把 remote(upstream)、分支名(claude)以及 GitHub 用户名(zhwesky2010)写死,会导致他人按文档执行时大概率失败(remote 名称不同、分支策略不同、fork 用户名不同)。建议将这些改为占位符/变量(例如 <GITHUB_USER>、<BRANCH>、<REMOTE>),或加入获取当前用户/remote 的命令指引(如用 gh api user -q .login 获取 login),避免流程不可复用。
| )" | ||
|
|
||
| # PaConvert PR | ||
| gh pr create --repo PaddlePaddle/PaConvert --base master --head zhwesky2010:claude \ |
There was a problem hiding this comment.
这里把 remote(upstream)、分支名(claude)以及 GitHub 用户名(zhwesky2010)写死,会导致他人按文档执行时大概率失败(remote 名称不同、分支策略不同、fork 用户名不同)。建议将这些改为占位符/变量(例如 <GITHUB_USER>、<BRANCH>、<REMOTE>),或加入获取当前用户/remote 的命令指引(如用 gh api user -q .login 获取 login),避免流程不可复用。
| 3. 输出结果序号需要保持连贯,每一个输出结果均需要检验,尽可能循环检验减少行数。 | ||
| 3. 比对测试项,对于内容相同的测试项,不要重复添加。 |
There was a problem hiding this comment.
列表编号重复(两条都是 3.),会影响阅读和引用。建议把后一条改为 4.(或使用无序列表)以保持编号一致。
| |-|-|-|-|-| | ||
| |API 中文文档|`{api_name}_cn.rst`|docs/docs/api/paddle/|tan_cn.rst|| | ||
| |API 差异文档|`torch.{api_name}.md`|docs/docs/guides/model_convert/convert_from_pytorch/api_difference/|torch.tan.md|| | ||
| |C++下沉使用|`python_api_info.yaml`、`ops.yaml`|Paddle/paddle/phi/ops/yaml/|python_api_info.yamlops.yaml|| |
There was a problem hiding this comment.
示例列里 python_api_info.yamlops.yaml 缺少分隔,读者无法直观看出是两个文件名。建议改为 python_api_info.yaml / ops.yaml 或 python_api_info.yaml, ops.yaml(与同表其他行的示例风格一致)。
| |C++下沉使用|`python_api_info.yaml`、`ops.yaml`|Paddle/paddle/phi/ops/yaml/|python_api_info.yamlops.yaml|| | |
| |C++下沉使用|`python_api_info.yaml`、`ops.yaml`|Paddle/paddle/phi/ops/yaml/|python_api_info.yaml / ops.yaml|| |
| 1. 接收待对齐的 Pytorch API 列表:$ARGUMENTS | ||
| 2. 为对应的 Paddle API 决策改动方案 | ||
| 3. 执行具体的 Paddle API 修改 | ||
| 4. 验证修改后的 Paddle API 是否对齐 Pytorch | ||
| 5. 更新修改后的 Paddle API 中文文档 | ||
| 6. 给出 Pytorch API 列表的对齐结果统计 |
There was a problem hiding this comment.
专有名词大小写不一致:文档中多处使用了 Pytorch,建议统一为官方写法 PyTorch(同一文件内已同时出现 PyTorch/Pytorch 时更容易造成检索与引用混乱)。
9cd1814 to
aed0e96
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
《Paddle API 对齐 PyTorch 项目》完整 SKILL 体系
AI Agent 自动对齐 Paddle API 与 PyTorch API。包含 1 个总 skill 和 6 个分阶段 skill。
两种使用方式
方式一:一步到位(推荐)
使用总 skill
/api-compatibility,传入待对齐的 PyTorch API 列表:总 skill 会自动执行完整流程(Step1→Step2→Step3→Step4→Step5),返回对齐结果统计表。
方式二:分步操作
针对具体任务,单独调用对应 skill:
/api-change-decider/python-decorator/cpp-sink/pytorch-alignment-validator/api-docs-updater/create-pr工作流程
使用示例
完整对齐一个 API(推荐方式):
自动完成全流程,得到对齐结果。
调试单个 API(需要逐步修改):