pr-splitter
它能做什么
这项技能规划如何把一项大型代码改动拆分为若干较小的拉取请求。它会备份原始分支,并跟踪每个部分,确保没有内容丢失。
适用场景
- ✓当一个拉取请求过大或内容杂乱,难以良好审阅时。
- ✓当你想从同一个分支规划堆叠或并行的拉取请求时。
- ✓当审阅意见改动了某个堆叠中的一部分,后续部分需要相应更新时。
技能链接
https://github.com/mastra-ai/mastra/blob/main/.claude/skills/pr-splitter/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“这个拉取请求把重构和新功能混在了一起。请帮我把它拆分成更小的拉取请求。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会备份原始分支,列出改动的文件,并将它们分组为若干审阅单元。然后它会规划堆叠结构,逐个提取每个部分,并在继续之前检查每一部分。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
PR Splitter
Preserve the original PR as source material, build smaller reviewable PRs intentionally, and track drift locally as review feedback changes the stack.
Required workflow
Snapshot before touching history
- Check
git status. - Create an immutable local reference to the original branch:
git branch backup/original-large-pr. - Do not delete or rewrite the original branch until the split is complete.
- Check
Inventory the original PR
- Inspect
git diff --stat <base>...HEAD,git diff --name-only <base>...HEAD, andgit log --oneline <base>..HEAD. - Classify changes by review unit: prep/refactor, API/type changes, behavior, tests, docs, cleanup, generated/lock files.
- Inspect
Create a local scratchpad
- Write split notes to an uncommitted local file, preferably
.notes/pr-split.md. - Ensure
.notes/is ignored or leave it untracked. Do not commit scratchpad notes unless the user explicitly asks. - Track: original branch, base branch, planned PRs, files/hunks extracted, verification per PR, remaining original diff, and intentional drift from review feedback.
- Write split notes to an uncommitted local file, preferably
Choose the split shape
- Use stacked PRs when later work depends on earlier work.
- Use parallel PRs only when changes are truly independent.
- Use foundation + parallel follow-ups when one shared prep change unlocks independent work.
Extract changes safely
- Prefer fresh branches from the correct base plus selective restore over rewriting messy history.
- Use path-level extraction for clean file ownership:
git checkout backup/original-large-pr -- path/to/file. - Use hunk-level extraction for mixed files:
git restore -p --source backup/original-large-pr -- path/to/file. - Keep each PR independently buildable and reviewable.
Verify each PR independently
- Run the narrowest relevant build, typecheck, lint, and tests for that PR's scope.
- Do not leave tests, docs, or generated files separated from the code they validate unless the split plan explicitly calls for it.
Manage drift deliberately
- Treat reviewer-approved changes as the new source of truth for the stack.
- After changing an earlier PR, rebase dependent PRs onto it and resolve conflicts in favor of the reviewed direction, not blindly in favor of the original branch.
- Compare the evolving stack against
backup/original-large-prto find remaining intent, not to force byte-for-byte equality. - Record intentional differences in
.notes/pr-split.md.
Use range-diff for rewritten stacks
- Use
git range-diffafter rebases, conflict resolution, or force-pushes to understand what changed. - Summarize meaningful range-diff results for reviewers when updating a stacked PR.
- Use
PR description pattern
Keep PR descriptions concise and reviewer-facing:
## Summary
This is PR N of M split from a larger change.
## Scope
- ...
## Intentionally excluded
- Follow-up PR will handle ...
## Verification
- ...
Do not put the full split ledger in PR descriptions. Keep detailed extraction notes and drift tracking in .notes/pr-split.md.
Scratchpad template
# PR split scratchpad
Original branch: backup/original-large-pr
Base branch: main
## Planned PRs
1. branch-name
- Scope:
- Files/hunks extracted:
- Verification:
- Changeset: (package names, bump type, scoped message)
- Status:
## Remaining original intent
- ...
## Drift notes
- Date / branch / reason:
Changesets
Each split PR must carry its own changeset scoped to the changes in that PR. Do not keep the original changeset from the source branch — it covers the full combined change and does not belong in any single split PR.
After extracting changes into a split branch:
- Delete any changeset files carried over from the original branch. These were written for the combined diff and will produce incorrect changelog entries.
- Create a new changeset for each PR using the CLI (see
.mastracode/commands/changeset.md):pnpm changeset -s -m "your scoped message" (--major | --minor | --patch) pkg-name - Scope the message to that PR's changes only. The changeset message should describe what this specific PR does, not the full original feature.
- Include only the packages actually changed in this PR. If the original changeset listed five packages but this PR only touches
@mastra/core, the new changeset should only reference `@ma
常见问题
原始分支会被删除吗?
不会。技能会先做备份,并在拆分完成之前保留原始分支。
堆叠式和并行式拉取请求都支持吗?
支持。当后续工作依赖于先前工作时,它选择堆叠式;当改动相互独立时,则选择并行式。
规划笔记会被共享吗?
不会。笔记保存在本地文件中,除非你要求,否则不会提交。
详情
作者的原始描述
Use when breaking a large, complex, messy, or hard-to-review pull request into multiple smaller PRs; planning stacked PRs; extracting independent changes from a branch; splitting mixed refactor and behavior changes; managing drift after review feedback; rebasing follow-up PRs as earlier PRs change; or preserving original branch intent while shipping incrementally.
repo: mastra-ai/mastra
热度
- GitHub 星标
- 29k
- 排名
- #9363
- 许可证
- —
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
debugging-difficult-bugs
29k帮你的智能体通过记录真实程序在运行时的行为来调试疑难问题,而不是只凭测试去猜测。
mastra-frontend
29k帮你的智能体通过组合 Mastra playground 设计系统的现成组件来搭建应用界面,而不是从头编写样式。
pr-explainer
29k帮你的智能体把一个拉取请求整理成清晰、独立的 HTML 页面,向审阅者解释这项改动。
ralph-plan
29k帮你的智能体通过简短的来回问答,规划一条结构化、目标明确的任务指令,使工作有清晰的步骤和检查。