Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from bundle
Split a large GitHub PR into reviewable commits on a separate draft PR branch.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
pr-commit-splitter-draft-pr/SKILL.md
1---2name: pr-commit-splitter-draft-pr3description: Use when the user wants a large GitHub PR split into logical review commits without rewriting the real PR branch, by rebuilding the changes on a separate draft PR branch and posting that draft PR back on the original PR.4---56# PR Commit Splitter Draft PR Mode78Create reviewable commit history from one large PR without force-pushing the original review branch.910## When To Use1112Use this flow when at least one condition is true:13- 12 or more changed files14- 500 or more changed lines15- The user explicitly asks for logical commit splitting16- The user wants the original PR branch left untouched1718## Required Tools1920- `git`21- `gh`2223Stop if GitHub CLI is not authenticated or the current repository is not connected to the target PR.2425## Safe Workflow26271. Capture baseline state:28- `git status --short`29- `git fetch origin`30- `gh pr view --json number,title,url,headRefName,baseRefName`31- `git stash list`32- `git branch --show-current`332. Resolve the real PR context:34- Treat the PR head branch as read-only.35- Treat the PR base branch as the source for the draft split branch.36- Create a draft split branch name like `pr-<number>-split-draft`.373. Create the scratch branch from the latest base:38- `git switch -c pr-<number>-split-draft --track origin/<baseRefName>` when no local branch exists.39- If the branch already exists locally, reset expectations first and confirm it is safe to reuse before continuing.404. Propose commit groups by file sets, not line-by-line by default.415. Rebuild the PR as a review stack on the scratch branch:42- For each group, restore files from the real PR head branch onto the scratch branch:43- `git restore --source origin/<headRefName> --staged --worktree -- <group files>`44- Commit each group with a coherent message.456. Verify the scratch branch reproduces the real PR tree:46- Compare trees directly, not commit history:47- `git diff --stat origin/<headRefName> HEAD`48- Stop if the final tree differs.497. Push the scratch branch:50- `git push -u origin pr-<number>-split-draft`518. Open a draft PR against the same base branch:52- `gh pr create --draft --base <baseRefName> --head pr-<number>-split-draft`539. Comment on the original PR with:54- The draft PR URL55- The ordered commit list56- Per-commit compare links for review5710. Return to the original branch when finished.5859## Default Commit Grouping Order60611. Domain or contract changes622. Persistence or infra changes633. Runtime handlers, controllers, or workers644. Application wiring655. Tests666. Tooling or chore files6768Keep each commit independently reviewable.6970## Comment Payload7172Post one concise comment on the original PR with this structure:7374```text75Created a draft review stack for this PR:76- Draft PR: <url>77- Commit 1: <subject> (<compare-url>)78- Commit 2: <subject> (<compare-url>)79- Commit 3: <subject> (<compare-url>)8081The original PR branch was left unchanged.82```8384Prefer compare links of the form:85- First commit: `<repo>/compare/<base_sha>...<commit_sha>`86- Later commits: `<repo>/compare/<previous_commit_sha>...<commit_sha>`8788## Prehook Failure Recovery8990If a commit fails because hooks need dependent files:911. Read the hook output.922. Restore only the missing files from `origin/<headRefName>`.933. Add them to the same commit and retry once.944. If the dependency boundary becomes unclear, stop and explain the blocker.9596## Safety Rules9798- Never force-push the original PR branch.99- Never rewrite the original PR branch in place.100- Do not use destructive commands such as `git reset --hard`.101- Do not drop or overwrite user stash entries.102- Stop immediately if branch reuse, tree verification, or PR comment targeting is ambiguous.103