branch-surgery-pr-split
Skill4 starsChanged 13 months agoApache-2.0View on GitHub
Split oversized or mixed-concern branches into smaller, reviewable PR stacks with safety refs, topology selection, parity audits, and merge sequencing. Use when a PR or branch is too large, difficult to review, mixed across concerns, conflict-prone, or needs to be decomposed without losing net changes.
In this repository8 other files it gives its agents.
- AGENTS.mdAGENTS.md
- browser-qaSkill
- create-mermaid-diagramsSkill
- create-pull-requestSkill
- git-commit-conventionalSkill
- mastra-apiSkill
- tilt-devSkill
- uv-usageSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. About 0 are common, 15 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈15
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Use this skill to turn a risky monolithic branch into a safe, auditable set of scoped PRs.
- Distinctive: line 11
Treat topology as a decision, not a default recipe, and collaborate with the user before executing branch surgery.
- Distinctive: line 16
Always present the top two topology options with explicit tradeoffs.
- Distinctive: line 20
Run parity and completeness audits.
- Distinctive: line 27
Commit count and net churn versus base.
- Distinctive: line 33
If signals are incomplete, gather more evidence before recommending topology.
- Very specific: line 37
Always provide the top two options with tradeoffs and a recommendation.
- Very specific: line 38
Use references/topology-patterns.md to select options.
- Distinctive: line 48
Do not skip tradeoffs.
- Very specific: line 52
Use targeted discovery questions from references/facilitated-discovery-questions.md.
- Distinctive: line 61
If the user is unsure, recommend one option and explain what would change with the second option.
- Distinctive: line 68
Commit disposition map (keep, split, drop-as-superseded).
- Very specific: line 74
Use templates in references/pr-stack-templates.md.
- Distinctive: line 80
Create backup refs first (tag and/or backup branch).
- Distinctive: line 83
Keep shared-doc churn isolated when selected topology calls for it.
- Distinctive: line 84
Avoid hidden carryover changes by checking staged file lists before commit.
- Very specific: line 88
Run audit gates from references/audit-gates.md.
- Distinctive: line 93
No missing files compared to original net diff.
- Distinctive: line 94
No unexpected extra files.
- Distinctive: line 101
If audit finds issues:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Branch Surgery PR Split
Overview
Use this skill to turn a risky monolithic branch into a safe, auditable set of scoped PRs. Treat topology as a decision, not a default recipe, and collaborate with the user before executing branch surgery.
Workflow
- Quantify branch shape before proposing solutions.
- Always present the top two topology options with explicit tradeoffs.
- Collaborate with the user to select one topology.
- Produce a decision-complete split plan.
- Execute with safety refs and strict scope boundaries.
- Run parity and completeness audits.
- Remediate drift and generate PR metadata.
Step 1: Quantify Branch Shape
Collect objective signals first:
- Commit count and net churn versus base.
- Number of changed files and hotspot files.
- Mixed-commit prevalence (single commit touching unrelated concerns).
- Dependency density between concerns.
- Expected review risk and conflict risk.
If signals are incomplete, gather more evidence before recommending topology.
Step 2: Generate Topology Options
Always provide the top two options with tradeoffs and a recommendation.
Use references/topology-patterns.md to select options.
For each option, include:
- Topology name.
- Why it fits this branch shape.
- Review ergonomics, merge complexity, and conflict risk.
- Failure modes and mitigations.
- Cost of execution (low/medium/high).
Do not skip tradeoffs.
Step 3: Collaborate on Topology Selection
Use targeted discovery questions from references/facilitated-discovery-questions.md.
Confirm constraints before surgery:
- Must-merge-first dependencies.
- Parallel review goals.
- Tolerance for stacked PR depth.
- Documentation isolation preference.
- Release timing constraints.
If the user is unsure, recommend one option and explain what would change with the second option.
Step 4: Produce a Decision-Complete Split Plan
Produce:
- Branch inventory with base branch mapping.
- Commit disposition map (keep, split, drop-as-superseded).
- Execution order.
- Merge order.
- Validation gates.
- Risk register and mitigations.
Use templates in references/pr-stack-templates.md.
Step 5: Execute Branch Surgery Safely
Execution rules:
- Create backup refs first (tag and/or backup branch).
- Preserve explicit scope contracts per split branch.
- For mixed commits, use
cherry-pick -nand stage only owned files/hunks. - Keep shared-doc churn isolated when selected topology calls for it.
- Avoid hidden carryover changes by checking staged file lists before commit.
Step 6: Audit Before Confidence
Run audit gates from references/audit-gates.md.
A split is incomplete until all gates pass or deviations are documented.
Mandatory checks:
- No missing files compared to original net diff.
- No unexpected extra files.
- Per-file parity or intentional documented divergence.
- Deletion semantics parity.
- Branch scope boundaries match PR intent.
Step 7: Remediate and Package PRs
If audit finds issues:
- Fix scope drift or ownership errors.
- Re-run audits.
- Remove redundant branches.
Then generate PR metadata and merge sequencing notes using references/pr-stack-templates.md.
Output Standard
Always provide:
- Chosen topology and why it won over the runner-up.
- Branch plan and merge order.
- Audit summary with pass/fail status per gate.
- Remediation actions taken.
References
references/topology-patterns.mdreferences/facilitated-discovery-questions.mdreferences/audit-gates.mdreferences/pr-stack-templates.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

