Skip to content

commandGit and releases

Split PR

Plans how to break a large branch into small pull requests, in an order where each one builds, passes tests and can merge alone.

npx workspacetemplates add split-pr --tool claude-code

Writes 1 file to .claude/commands/

.claude/commands/split-pr.md14 lines · 1.3 KBFile
---
description: Plans how to break a large branch into small pull requests, in an order where each one builds, passes tests and can merge alone.
argument-hint: "[max size per PR or base branch]"
---

Split the current branch into smaller pull requests. Notes: $ARGUMENTS

1. Find the base with `git merge-base HEAD <default branch>`. Read `git diff --stat <base>..HEAD` and the commit list, then the diff by area.
2. Classify every changed file into a concern: pure refactor or rename, dependency or config change, database migration, new internal API, feature UI, tests, docs. Note which files must stay together because one does not compile without the other.
3. Propose an ordered series where each pull request builds and passes tests on its own, lands the risk early (refactors and migrations first, behavior last), and stays under about 400 changed lines. For each give a title, files, size and what depends on it.
4. Show the plan as a table and mention any file needing a split across two pull requests.
5. Do nothing yet. After approval, create one branch per piece from the previous one (`git checkout <base> -- <files>`), run tests for each, and keep the original branch intact.

Finish with the branch names, the merge order and a suggested description for each pull request. Never push or open pull requests unasked.

What it does

Large pull requests get skimmed and approved without real review. Smaller ones get read. This command analyzes what a branch changes and proposes a sequence of focused pull requests with the dependency between them spelled out.

It plans first and shows file lists per piece. It creates branches only after you approve, and leaves your original branch untouched.

Example

you › /split-pr 400 lines max

agent › Branch changes 34 files, 1,900 lines. Proposed order:
1. refactor: extract pricing helpers (6 files, 210 lines)
2. migration: add discounts table (3 files, 90)
3. feat: discount API and service (9 files, 380)
4. feat: discount UI and tests (16 files, 410)
Original branch stays untouched. Create these branches?

Questions

Does it open the pull requests?
No. It prepares local branches and descriptions, and pushing or opening them is up to you.
What if the pieces depend on each other?
The plan stacks them in order, with each branch built on the previous one, and tells you which must merge first.
  • Branch Cleanup

    CommandGit and releases

    Free
  • Changelog Entry

    CommandGit and releases

    Free
  • Cherry Pick Fix

    CommandGit and releases

    Free
  • Commit Message

    CommandGit and releases

    Free