/caravan:split-pr-stackfrom caravan
Split one big pull request into a linear stack of small PRs (each ~5 minutes of review), where every branch builds and passes its tests on its own and the top of the stack is byte-identical to the original PR. Plans the chunks, carves shared files into intermediate versions, verifies every branch, pushes once, opens the chained PRs with "Stack: phase N of M" descriptions, babysits CI and closes the original. Use it whenever the user wants to split, chunk, break up, stack or slice a PR or branch that is too big to review — "split this PR like we did in #30", "make this reviewable in 5-minute chunks", "stacked PRs", "trocea esta PR", "divide la PR", "this PR is too big" — even if they only paste a PR link and point at an earlier stack as the example.
Ships in caravan. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
The goal is a chain main ← PR1 ← PR2 ← … ← PRn where:
git diff original top is empty), so the split
loses and adds nothing.The last property is the safety net for everything else: carve freely, then prove it.
gh pr view <n> --json title,body,headRefName,baseRefName,additions,deletions plus
git diff --stat origin/<base>...<head> for the file map, and git log of the branch.gh pr list --state all to see how it was chained (base of each = previous head) and how the
descriptions are written. Copy that format.Order by dependency, bottom first. A shape that works well:
Measure before committing to it: for each planned PR estimate code vs test lines, and split again anything whose production code is clearly over budget. Tell the user the plan (number of PRs, one line each) if it differs a lot from what they expect; otherwise proceed.
Put commits under the project's branch and commit conventions (check CI workflows for branch
name regexes and "spec impact"-style checks, and git log for the message style).
Most files go into exactly one PR unchanged. The work is in the few files several PRs touch (the page view, the component, the big test files, a shared config or provider). For those:
scratch/v8/laravel/...,
scratch/v7/...), one copy per version that differs.bin/rm_php_methods.py <file> <name>... removes each named
method with its attributes and docblock (PHP classes; adapt the idea for other languages).
Watch the class tail — removing the last method can leave a blank line before }.edit(path, [(old, new), ...]) helper that fails when
old does not match exactly once — silent no-op replacements are the typical carving bug.Write one script that rebuilds the whole stack from scratch, so fixing a carve is "edit the version, rerun":
take() { git checkout "$FINAL" -- "$@"; } # file as in the final PR
from() { v=$1; shift; for f; do mkdir -p "$(dirname "$f")"; cp "$S/$v/$f" "$f"; git add "$f"; done; }
br() { git checkout -q -B "$1" "$2"; } # branch off the previous one
commit() { git commit -q -m "$1"; }
Each block: br <name> <previous>, take …, from vK …, commit "<message>". End the script
with git diff --stat "$FINAL" <top-branch> — it must print nothing. If it prints anything, a
file was forgotten or a version drifted; fix it before going further.
Run, for each branch, the tests of the areas the stack touches plus the project's linters
and style checks. The point is that branch k passes without k+1, so sync that branch's tree into
the test environment and delete the files it does not have yet — otherwise a later branch's
file masks a missing piece. Look for the project's own way of running tests (Makefile,
composer/npm scripts, remote-runner scripts, CLAUDE.md).
Only push when every branch is green. If the environment is shared or slow, the full suite once on the top branch plus targeted suites per branch is a fair trade.
git push -u origin b1 b2 …: pre-push hooks then run once,
not n times.gh pr create --base <previous-branch> --head <branch> and a
placeholder body that already names the PR's spec path (or Spec impact: None — <why> for a
tooling phase), collecting the numbers — the overseer harness blocks a PR body without one; then write the real bodies (they need the numbers)
and apply them with gh pr edit <n> --body-file.git diff origin/<original-head> origin/<top-head> is empty).Opening n PRs at once starts n pipelines together, and anything shared will contend: Terraform state locks ("Error acquiring the state lock"), deployment/promotion systems that cannot find an image yet, rate limits. These are not code failures:
gh api repos/<o>/<r>/actions/jobs/<id>/logs --allow-escape-sequences).gh run rerun <run> --failed, and waits again works well.Do not close the original PR on your own. When the user agrees, close it with a comment that lists the stack in merge order and states the diff-is-empty invariant. Keep its branch unless asked: it is the reference the invariant is checked against.
End with a table (PR, one-line scope, code/total lines), the verification done per branch, the CI state per PR with the reason for any red, and the open decisions for the user.
remotePHP, make intern pods, pre-push hook,
Terraform plan per PR): read references/laravel-base.md.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub serban-marius/pip-boy --plugin caravan