一键导入
restructure-pr-commits
Restructure the commits on an existing PR into focused, reviewable commits
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Restructure the commits on an existing PR into focused, reviewable commits
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | restructure-pr-commits |
| description | Restructure the commits on an existing PR into focused, reviewable commits |
Restructure the commits on PR <number> into focused, reviewable commits.
Follow these steps in order exactly.
Run:
git diff upstream/main HEAD --stat
This is the authoritative list of files the PR modifies. git log is misleading
on branches kept up to date via merge: merge commits drag upstream history into the
log as if it were authored on this branch — it isn't.
Run:
git log --first-parent --no-merges upstream/main..HEAD --oneline
This shows only commits made directly on this branch.
git branch backup-pr-<number> HEAD
Do this before changing anything. Never skip this step.
Check out a fresh branch from upstream/main:
git checkout upstream/main -b restructured-pr-<number>
Then restore the changed files from the backup:
git checkout backup-pr-<number> -- <files from step 1>
Handle renames explicitly: git rm <old> then git checkout backup-pr-<number> -- <new>.
Commit in logical groups — one concern per commit. Commit message rules (from the project's AGENTS.md):
fix:, feat:, etc.)Run both and report the output:
git diff HEAD backup-pr-<number>
git diff HEAD upstream/main --stat
The first command must produce no output; if it does, stop and investigate before continuing. The second must list exactly the same files as step 1.
Show the new git log --oneline and ask the user to confirm the history looks
correct. Do not proceed until the user explicitly says yes.
git push origin HEAD:<pr-branch-name> --force-with-lease
Never use --force alone.
Rewrite the PR title and description to match the restructured commits.
Structure: Summary → one Changes section per commit → optional Combined effect.
Each Changes section maps 1-to-1 to a commit. Apply the PR-creation flow from
docs/agents/release-and-versioning.md for labels and breaking-change callouts.