Split an Oversized Change Into a Sequence of Pull Requests That Can Each Be Reviewed and Reverted Alone

You are a senior engineer helping me split one oversized change into a sequence of smaller pull requests that can each be reviewed, merged and reverted on their own.

I will paste a diff summary (file list with rough line counts) or the full diff, plus a sentence describing the goal of the change. Do the following, in order.

1. Group the changed files and hunks by purpose. Use only these purposes: mechanical (renames, formatting, moves), preparatory (refactors that change no behavior), new behavior, tests, configuration or migration, cleanup. Quote file paths so I can check your grouping.
2. Propose an ordered list of pull requests. For each one give: a title, the files and hunks it contains, why it is safe to merge by itself, and what it depends on. A pull request must leave the main branch building and passing tests. If a step cannot do that without another step, say so and merge the two.
3. For each pull request, state the revert story in one sentence: what happens if it is reverted alone, and whether later pull requests in the sequence would break.
4. Flag any hunk that mixes purposes (for example a rename inside a logic change) and tell me how to separate it.
5. Call out anything that must ship together, such as a schema change and the code that reads it, and propose the compatible intermediate form (for example, add the column first, write to both, then switch reads).
6. End with the two riskiest pull requests in the sequence and what a reviewer should look at first in each.

Rules: do not invent files or hunks that I did not provide. If the input is too thin to group a file confidently, list it under "Needs your input" with a specific question. Prefer fewer, meaningful pull requests over many tiny ones; do not exceed seven unless the diff clearly demands it.

## When to use it

Use this when a branch has grown past what a reviewer can hold in their head, or when review comments keep saying "I can't tell what this is for." It works best before you open the pull request, but it also helps when a reviewer asks you to split an existing one.

## How to adapt it

Add your team's norms to the prompt: a maximum diff size, whether you use stacked branches, or whether refactors must land before features. If you ship behind feature flags, add "assume new behavior can merge dark behind a flag" so the model can order pull requests more freely. For very large diffs, run step 1 first on its own and check the grouping before asking for the sequence.

## Example input and good output

Input: "Goal: move retries into a shared client. Files: client/http.py (+180/-40), billing/api.py (+25/-60), search/api.py (+22/-55), tests/test_http.py (+140), tests/test_billing.py (+10/-30), pyproject.toml (+2)."

A good answer proposes: PR 1, add the shared client and its tests with no callers (safe, nothing uses it); PR 2, switch billing to the client and update its tests, with a revert note that PR 1 stays valid; PR 3, switch search; PR 4, remove the old retry code. It flags that the pyproject change belongs in PR 1, and asks whether billing's old retry behavior differs, because that would be a behavior change needing its own review.

Sign in to upvote this prompt.