# PR Splitter

Use when breaking a large, complex, messy, or hard-to-review pull request into multiple...

- Repository: https://github.com/mastra-ai/mastra (29259 stars)
- Category: Git and review
- License: see repository
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add mastra-ai/mastra --skill pr-splitter -g -a claude-code -y`
Codex: `npx skills add mastra-ai/mastra --skill pr-splitter -g -a codex -y`
Cursor: `npx skills add mastra-ai/mastra --skill pr-splitter -g -a cursor -y`
Gemini CLI: `npx skills add mastra-ai/mastra --skill pr-splitter -g -a gemini-cli -y`

## Description

Use when breaking a large, complex, messy, or hard-to-review pull request into multiple smaller PRs; planning stacked PRs; extracting independent changes from a branch; splitting mixed refactor and behavior changes; managing drift after review feedback; rebasing follow-up PRs as earlier PRs change; or preserving original branch intent while shipping incrementally.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# PR Splitter

Preserve the original PR as source material, build smaller reviewable PRs intentionally, and track drift locally as review feedback changes the stack.

## Required workflow

1. **Snapshot before touching history**
   - Check `git status`.
   - Create an immutable local reference to the original branch: `git branch backup/original-large-pr`.
   - Do not delete or rewrite the original branch until the split is complete.

2. **Inventory the original PR**
   - Inspect `git diff --stat <base>...HEAD`, `git diff --name-only <base>...HEAD`, and `git log --oneline <base>..HEAD`.
   - Classify changes by review unit: prep/refactor, API/type changes, behavior, tests, docs, cleanup, generated/lock files.

3. **Create a local scratchpad**
   - Write split notes to an uncommitted local file, preferably `.notes/pr-split.md`.
   - Ensure `.notes/` is ignored or leave it untracked. Do not commit scratchpad notes unless the user explicitly asks.
   - Track: original branch, base branch, planned PRs, files/hunks extracted, verification per PR, remaining original diff, and intentional drift from review feedback.

4. **Choose the split shape**
   - Use stacked PRs when later work depends on earlier work.
   - Use parallel PRs only when changes are truly independent.
   - Use foundation + parallel follow-ups when one shared prep change unlocks independent work.

5. **Extract changes safely**
   - Prefer fresh branches from the correct base plus selective restore over rewriting messy history.
   - Use path-level extraction for clean file ownership: `git checkout backup/original-large-pr -- path/to/file`.
   - Use hunk-level extraction for mixed files: `git restore -p --source backup/original-large-pr -- path/to/file`.
   - Keep each PR independently buildable and reviewable.

The rest: https://github.com/mastra-ai/mastra/blob/HEAD/.claude/skills/pr-splitter/SKILL.md
