選項
首頁首頁 Skill 程式碼審查 mcore-split-pr

mcore-split-pr

nvidia/skills nvidia/skills

將單個 Pull Request 拆分為多個 Pull Request,以此減少所需的 CODEOWNERS 稽覈團隊數量。

...展開全部
11
更新時間 2026-08-26

關於 mcore-split-pr

mcore-split-pr 工具可用於將龐大的 Megatron-LM pull request 拆分為多個較小的 PR,使得每個 PR 所涉及的 CODEOWNERS 稽覈小組數量儘可能少。它解決了具體的稽覈負擔問題:那些同時涉及核心程式碼、示例、工具以及訓練目錄的 PR 會牽涉到眾多稽覈小組,從而延緩合併進度;而僅針對單個目錄制定的 PR 則只需該目錄對應的稽覈人員即可完成稽覈。

該工具的工作流程分為三個階段。首先,它會透過 gh CLI 獲取 PR 的詳細資訊與差異統計資料,解析 .github/CODEOWNERS 檔案以將檔案型別與對應的所有者小組關聯起來,並統計該 PR 當前所需的獨立稽覈小組數量。接著,它會根據 CODEOWNERS 分組對檔案進行歸類,確保測試檔案與它們所驗證的生產程式碼保持在一起,標記出跨 PR 的依賴關係(例如某個 PR 中重新命名的符號被另一個 PR 所引用),保證每個拆分後的 PR 均可獨立合併,最後以表格形式呈現拆分方案供使用者批准。只有在獲得批准後,它才會執行實際操作:從正確的基分支建立分支,使用 git apply 應用針對特定檔案的差異修改,完成提交後推送到使用者的 fork 分支。該工具建立的 PR 始終為草稿狀態,絕不會直接推送到上游倉庫,在執行強制推送前會先徵得使用者確認;若當前操作使用者並非該 PR 的原作者,還會註明原作者的貢獻。

該工具的目標使用者是那些需要處理龐大 PR 且希望減少每個 PR 所涉及的稽覈小組數量、同時確保每個拆分後的 PR 均可獨立稽覈和合並的 Megatron-LM 貢獻者及維護人員。使用者可透過提供 PR 的 URL 或編號作為引數來呼叫該工具。

常見問題

拆分 PR 能解決什麼問題?

它能減少每個 PR 所需的 CODEOWNERS 稽覈小組數量,從而降低稽覈負擔。不過每個拆分後的 PR 依然需要具備獨立合併和稽覈的能力。

它會直接推送到主倉庫嗎?

不會。該工具建立的 PR 始終為草稿狀態,只會推送到使用者的 fork 分支,絕不會直接上傳到上游倉庫。在執行可能縮小原 PR 範圍的強制推送之前,它也會先與使用者確認。

拆分過程中如何處理測試檔案?

測試檔案會與其所驗證的生產程式碼一同存在。該工具不會僅僅為了減少稽覈小組而將測試檔案拆分為單獨的 PR。

如果某個拆分後的 PR 依賴於另一個 PR,會怎樣?

工具會明確標出這種依賴關係,並在第一個 PR 中新增向後相容的別名、重新匯出機制或適配程式碼,以便後續的 PR 能夠引用它們,同時還會註明正確的合併順序。

執行該工具需要什麼條件?

需要已針對該倉庫完成身份認證的 gh CLI、包含上游遠端倉庫的原生代碼副本,以及用於推送分支的使用者 fork 分支。在開始拆分操作之前,它會等待使用者批准。

所有檔案

5 個檔案SKILL.md4.4 KB檢視skill.oms.sig4.4 KB檢視BENCHMARK.md2.7 KB檢視evals/evals.json0.0 KB檢視skill-card.md2.4 KB檢視

在 GitHub 上查看

Split a large pull request into multiple smaller PRs, where each PR touchesthe fewest possible CODEOWNERS reviewer groups. The goal is to reduce reviewburden: a PR that only touches megatron/core/ needs only the core reviewers,while a PR that also touches examples/, tools/, and megatron/training/pulls in many additional groups.

Answer-First Constraints

For split-planning questions, lead with these constraints before the fullworkflow:

  • Minimize CODEOWNERS reviewer groups per PR, but each resulting PR must stillbe independently mergeable and reviewable.
  • Tests travel with the production code they validate; do not split tests into aseparate PR just to reduce reviewer groups.
  • If PR B depends on symbols renamed in PR A, call out the dependency and putbackward-compatible aliases, re-exports, or shims in PR A when needed.
  • Wait for user approval before execution.
  • Execution creates draft PRs from the right base, applies file-scoped diffswith git diff upstream/main..<source-branch> -- <paths> | git apply, pushesto the user's fork, and never pushes directly to upstream.

Workflow

1. Analyze the PR

  1. Fetch the PR details: gh pr view <number> --repo NVIDIA/Megatron-LM --json title,body,headRefName,author and gh pr diff <number> --repo NVIDIA/Megatron-LM --stat. Also determine the current GitHub user with gh api user --jq .login.
  2. Parse .github/CODEOWNERS to build a mapping from file path patterns to owner groups.
  3. For each changed file in the PR, determine which CODEOWNERS groups would be required to review it.
  4. Build a summary table grouped by CODEOWNERS group, showing which files pull in which groups.
  5. Count the total number of distinct reviewer groups the PR currently requires.

2. Propose a split that minimizes reviewer groups per PR

The primary optimization goal: minimize the number of CODEOWNERS reviewer groups required for each resulting PR.

Strategy:

  1. Cluster files by their CODEOWNERS groups. Files owned by the same set of groups naturally belong together.
  2. Identify the largest cluster — this becomes the first (and usually largest) PR.
  3. Remaining files form one or more additional PRs, each ideally requiring only one or two reviewer groups.
  4. If a split creates a dependency (e.g., PR B uses symbols renamed in PR A), the dependent PR must be merged after the first. Note this explicitly.
  5. Each PR must be independently mergeable to main — no broken imports, no missing symbols. Backward-compatible aliases and re-export stubs in the first PR can make this possible.

Present the proposed split as a table:

  • PR name/description
  • Files included
  • CODEOWNERS groups required
  • Dependencies on other PRs (if any)

Wait for user approval before proceeding.

3. Execute the split (after user approval)

For each new PR:

  1. Create a new branch from the appropriate base (main, or a dependency PR's branch).
  2. Extract the relevant changes: git diff upstream/main..<source-branch> -- <file paths> | git apply.
  3. Stage, commit with a clear message, and push to the user's fork.
  4. Create the PR as a draft (per repo contributing guidelines).
  5. If the original PR needs to be narrowed in scope, confirm with the user before force-pushing.
  6. Report all PR URLs when done.

Important guidelines

  • Always create PRs as drafts and push to the user's fork, never directly to upstream.
  • Backward-compatible changes (aliases, re-exports, deprecation shims) should go in the first PR so subsequent PRs can depend on them.
  • Test files should go with the production code they test, not in a separate PR.
  • Prefer a single clean commit per split PR over replaying the original commit history.
  • If a file is hard to categorize (e.g., it touches two groups), ask the user which PR it should go in.
  • If the current GitHub user is not the author of the original PR, each new PR's description must explicitly credit the original author (e.g., "Original changes by @ in #").

所有檔案

0 個檔案

安裝 mcore-split-pr

將技能檔案下載並解壓到您的 .claude/skills/ 目錄中。

下載 ZIP

複製儲存庫並將技能檔案複製到您的專案中。

git clone https://github.com/NVIDIA/skills/blob/main/skills/mcore-split-pr/SKILL.md # Copy SKILL.md to your .claude/skills/ directory

複製 複製
快速設定: 將該技能資料夾複製到 .claude/skills/ 目錄中,Claude 會自動檢測並使用該技能。
儲存庫 nvidia/skills

相關技能

code-simplify
更新時間 2026-07-02
requesting-code-review
更新時間 2026-06-29
Git Commit Helper
更新時間 2026-06-29
commit-standards
更新時間 2026-06-29
OR