external/ag-shared/prompts/skills/pr-split/SKILL.md
Transform a large branch into a sequence of small, high-quality PRs that:
The goal is reviewer experience, not mechanical splitting. Each PR should be something you'd be proud to send for review.
If the user provides a command option of help:
gh) must be available and authenticatedVerify the working tree is clean, not on main branch, and gh CLI is authenticated before proceeding.
Determine the commit message prefix from the branch name:
Detect the project from the repo name (enclosing directory):
| Repo | Branch Pattern | JIRA Prefix |
|---|---|---|
ag-studio | st-NNNNN/description | ST- |
ag-charts | ag-NNNNN/description | AG- |
ag-grid | ag-NNNNN/description | AG- |
| (default) | ag-NNNNN/description | AG- |
If branch matches the project's pattern: extract JIRA ticket (e.g., ST-12345, AG-12345)
Otherwise: derive prefix from branch name (e.g., feature/null-keys becomes null-keys)
Store this prefix for use in commit messages and PR titles.
Use a sub-agent (type: Explore) to deeply analyse the changes:
latest)Focus on content and purpose, not commit boundaries. Identify:
Key questions to answer:
After analysis, use AskUserQuestion to present 2-3 concrete split proposals based on content analysis:
Option types to consider:
Guidelines:
Do NOT offer "By commit" splitting. If commits are already well-structured, the user can trivially do this themselves. The value of this command is reorganising changes into logical, reviewable units.
If user selects a pre-defined option: Proceed with that strategy.
If user selects "Custom": Ask for details on how many PRs and what goes in each.
Present the detailed plan for confirmation:
## Proposed Split Plan
### PR 1: [Title]
- Purpose: [what this PR accomplishes]
- Files: [list or patterns]
- Lines: ~XXX
### PR 2: [Title]
- Purpose: [what this PR accomplishes]
- Files: [list or patterns]
- Lines: ~XXX
- Depends on: PR 1
[etc.]
Use AskUserQuestion to confirm before proceeding.
Run the /plan-review skill to check for completeness and correctness.
Create a temporary branch that holds all changes as staged files:
latest (converts all commits to staged changes)For each PR in the plan:
First PR:
latestgit checkout <temp-branch> -- <files> for clean file extractiongit add -p for partial file staging when neededSubsequent PRs:
Each commit message must:
Good example:
AG-12345 Add null category handling for bar series
Previously, null categories caused bars to render at position 0.
Now they are filtered out during data processing, matching the
behaviour of line and area series.
Bad example:
AG-12345 Update files
After creating all PR branches:
This phase is essential. Each PR must be polished until reviewer-ready, not just "builds".
Rebase onto base
latestRun /pr-review (via sub-agent)
Assess Logical Coherence
Assess Presentation Quality
Run Build Validation
Fix Issues
git commit --amend to improveIterate Until High Quality
Before proceeding to create PRs, verify each branch meets these criteria:
/pr-reviewPush each branch with upstream tracking:
git push -u origin "${branch_name}"
For each branch, create a draft PR using gh pr create:
latestPR Description Template:
## Summary
[Brief description of what this PR accomplishes and why]
## Position in Stack
PR N of M in the series.
**Previous PR:** #<number> (if applicable)
**Next PR:** #<number> (if applicable)
## JIRA
Jira: [TICKET-12345](https://jira.example.com/browse/TICKET-12345)
## Test Plan
- [ ] Unit tests pass
- [ ] Build succeeds
- [ ] Lint passes
Output a summary of the created PRs:
# PR Split Complete
## Summary
Split `{original_branch}` into {N} stacked PRs.
## PR Chain
| # | Branch | PR | Description | Base |
|---|--------|-----|-------------|------|
| 1 | {branch-part-1} | #{pr1} | {desc1} | latest |
| 2 | {branch-part-2} | #{pr2} | {desc2} | {branch-part-1} |
| ... | ... | ... | ... | ... |
## Dependency Diagram
latest └── {branch-part-1} (PR #{pr1}) └── {branch-part-2} (PR #{pr2}) └── {branch-part-3} (PR #{pr3})
## Reviewer Instructions
1. Review PRs in order (1, 2, 3, ...)
2. Each PR shows only its incremental changes
3. To see cumulative changes up to PR N, compare `{branch-part-N}` to `latest`
4. Approve and merge in order; later PRs will auto-update their base
git stash or git commit -am "WIP"| Phase | Sub-Agent Type | Purpose |
|---|---|---|
| 1 | Explore | Analyse code changes and identify logical groupings |
| 2 | plan-review (skill) | Validate the split plan |
| 4 | general-purpose | Run /pr-review for each branch |
| 4 | code-fixup (skill) | Fix build/lint/test issues |