| name | uplift |
| description | Create an uplift PR that cherry-picks fixes from merged PRs into a release branch. Auto-detects release branches from the repo. Triggers on: /uplift, create uplift, uplift PRs. |
| argument-hint | [github-username] [release-branch] [all|<num>d|PR1,PR2,PR3] |
| allowed-tools | Bash, Read, WebFetch, Grep, Glob |
Uplift PR Creator
Create an uplift pull request that cherry-picks fixes from a contributor's
recently merged PRs into a target release branch.
Inputs
- Arguments:
$ARGUMENTS -- space-separated values:
Parse the arguments by splitting $ARGUMENTS on whitespace. Examples:
/uplift alice -> username=alice, branch=auto-detect, filter=recent 50
/uplift alice v2.1.x -> username=alice, branch=v2.1.x, filter=recent 50
/uplift alice v2.1.x all -> username=alice, branch=v2.1.x, filter=all
(past 30 days)
/uplift alice v2.1.x 10d -> username=alice, branch=v2.1.x, filter=past
10 days
/uplift alice v2.1.x 100,105,110 -> username=alice, branch=v2.1.x,
filter=only those PRs
Step 1: Gather Information
Auto-detect the repository:
REPO=$(gh repo view --json nameWithOwner --jq '.nameWithOwner')
Run these in parallel:
-
Fetch closed PRs (method depends on the third argument):
- Default (no third arg): Use
gh pr list --repo $REPO --author <username> --state closed --limit 50 --json number,title,mergedAt,mergeCommit,labels,body,url --jq 'sort_by(.mergedAt)'
all: Use
gh pr list --repo $REPO --author <username> --state closed --limit 200 --search "closed:>YYYY-MM-DD" --json number,title,mergedAt,mergeCommit,labels,body,url --jq 'sort_by(.mergedAt)'
where YYYY-MM-DD is 30 days ago from today.
<num>d duration: Same as all but YYYY-MM-DD is <num> days ago.
- Comma-separated PR list: For each PR number, use
gh pr view <number> --repo $REPO --json number,title,mergedAt,mergeCommit,labels,body,url.
Collect results sorted by mergedAt.
Skip any PR where mergedAt is null (closed without merge).
-
Determine the target branch: If not provided as an argument, auto-detect
release branches from the repo and present them to the user.
Step 2: Classify PRs
Review each merged PR and classify as include or exclude:
INCLUDE if the PR is any of:
- Bug fix (titles contain "fix", "bugfix", "patch", "hotfix")
- Flaky/intermittent test fix ("Fix flaky", "Fix test:", "Fix intermittent",
"Disable flaky")
- Crash fix ("crash", "null dereference", "segfault", "SIGSEGV", etc.)
- Test filter updates (disabling broken tests, updating stale filter entries)
- Critical regression fix
EXCLUDE if the PR is:
- A feature addition (not a fix)
- A refactor unrelated to stability or crashes
- Already cherry-picked into the target branch (check by searching
git log <remote>/<target-branch> --oneline --grep="#<PR_NUMBER>")
- Not merged (
mergedAt is null)
Step 3: Cherry-Pick in Chronological Order
- Detect the remote: Run
git remote -v to determine whether upstream or
origin points to the repository. Use whichever remote is correct.
- Fetch the target branch:
git fetch <remote> <target-branch>
- Choose a unique branch name: Use
uplift_<username>_<target-branch> as
the base name. If that branch already exists (locally or on the remote),
append a numeric suffix (_2, _3, etc.) until you find an unused name.
Create the branch:
git checkout -b <branch-name> <remote>/<target-branch>
- Filter out commits already in the target branch: Before cherry-picking,
check which included commits are already present in the target branch. For
each commit, search the target branch log for the PR number from the commit
message (e.g.,
git log <remote>/<target-branch> --oneline --grep="#XXXXX").
If a match is found, mark it as excluded with reason "Already in target
branch" and skip it.
- Cherry-pick the remaining commits sorted by
mergedAt timestamp (earliest
first):
git cherry-pick <merge_commit_sha>
- If a cherry-pick has conflicts, try to resolve them. If unresolvable, skip
that PR and note it in the summary.
Step 4: Pre-submission Checks
After all cherry-picks are complete but before pushing, run whatever preflight
checks the repository uses. Look for common patterns:
If preflight checks indicate formatting changes are needed, apply the fixes and
amend the last commit:
git add -A && git commit --amend --no-edit
If preflight checks fail for reasons unrelated to the cherry-picked changes
(pre-existing issues in the target branch), note the failures in the summary
but proceed.
Step 5: Create the Uplift PR
Title Format
Generate the title dynamically based on the categories of PRs actually included:
- If only test fixes:
Cherry-pick test fixes to <target-branch>
- If only crash/bug fixes:
Cherry-pick bug fixes to <target-branch>
- If both:
Cherry-pick test and bug fixes to <target-branch>
Body Format
Only list the PRs being cherry-picked. Do NOT mention excluded PRs in the body.
Use a HEREDOC for correct formatting:
gh pr create --repo $REPO --base <target-branch> --title "<title>" --body "$(cat <<'EOF'
Cherry-pick of #XXXX
Cherry-pick of #YYYY
Cherry-pick of #ZZZZ
## Included PRs
- #XXXX - <PR title>
- #YYYY - <PR title>
...
EOF
)"
Push and Create
git push -u origin <branch-name>
Step 6: Summary
After creating the PR, output a clear summary to the user:
Cherry-picked:
List each included PR with its number, title, and merge commit SHA.
Not Cherry-picked:
List each excluded PR with its number, title, and the reason it was excluded
(e.g., "not merged", "already in target branch", "not a fix",
"cherry-pick conflict").
PR Link:
Provide the URL of the newly created uplift PR.