Agent skill

Backport PR

by rundeck in rundeck/rundeck

Backport commits from an existing GitHub Pull Request to a target branch and open a new backport PR.

Apache-2.0Auto-check passedDevOps & Cloud

Install Backport PR

skills CLI
$ npx skills add rundeck/rundeck --skill backport-pr -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install rundeck/rundeck backport-pr --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/rundeck/rundeck.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/backport-pr .claude/skills/backport-pr && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
backport-pr
GitHub stars
6.3k
Token cost
~3k tokens
SKILL.md length
1,008 words
Files
1
Skills in repo
10
Repo updated
First seen
Licence
Apache-2.0

At a glance

Backport commits from an existing GitHub Pull Request to a target branch and open a new backport PR.

  • Works in 9 steps: Validate Environment → Fetch PR Metadata → Determine Commits to Cherry-Pick… → …
  • The user asks to backport a PR
  • SKILL.md covers Prerequisites, Inputs, Workflow and Error Handling, plus 3 more sections
  • Calls git and gh

What it does

Backport PR is an agent skill from rundeck/rundeck. Backport commits from an existing GitHub Pull Request to a target branch and open a new backport PR. Use when the user asks to backport a PR, cherry-pick a merged PR into a release/maintenance branch, port a fix to an older version, or mentions "backport".

Its SKILL.md is about 3k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in DevOps & Cloud. It works with GitHub. The repository describes itself as: Enable Self-Service Operations: Give specific users access to your existing tools, services, and scripts. The licence is Apache-2.0.

When your agent uses it

  • The user asks to backport a PR
  • Cherry-pick a merged PR into a release/maintenance branch
  • Port a fix to an older version
  • Mentions backport

Example prompts

  • “backport”
  • “/backport-pr”

Workflow steps

9 steps, taken from the step headings in SKILL.md.

  1. Validate Environment
  2. Fetch PR Metadata
  3. Determine Commits to Cherry-Pick (Auto-Detect Merge Strategy)
  4. Prompt for Target Branch
  5. Create Backport Branch
  6. Cherry-Pick Commit(s)
  7. Push Backport Branch
  8. Open Backport PR
  9. Final Summary

What it can do on your machine

Read from SKILL.md and the folder at commit d526b7c. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • git
    • gh

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git and gh, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Backport PR loads about 3k tokens when it runs. Until then it costs about 67 tokens; SKILL.md has 1,008 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~67
When it runs · the whole SKILL.md, loaded when a task matches
~3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from rundeck/rundeck at commit d526b7c, republished under its Apache-2.0 licence (© rundeck). 1,008 words, ~2,986 tokens.

Download SKILL.mdSave it as .claude/skills/backport-pr/SKILL.md (or your agent's skills folder).
name
backport-pr
description
Backport commits from an existing GitHub Pull Request to a target branch and open a new backport PR. Use when the user asks to backport a PR, cherry-pick a merged PR into a release/maintenance branch, port a fix to an older version, or mentions "backport".
user_invocable
true

Backport PR Skill

Purpose: Given an existing GitHub Pull Request number, cherry-pick its commit(s) onto a target branch (e.g. release/5.x, maintenance/4.x) and open a new backport PR referencing the original.

When to use:

  • Porting a merged fix/feature from main to a release branch
  • Re-applying a patch from one long-lived branch onto another
  • User mentions "backport", "cherry-pick PR", or "port fix to <branch>"

Prerequisites

Before starting, verify:

  1. gh CLI installed and authenticated:
    bash
    gh auth status
  2. Current repo is a valid git clone with origin pointing at the GitHub repo.
  3. Working tree is clean (no uncommitted changes).
  4. You have push access to the origin remote (needed to open the backport PR).

If any check fails, stop and report the issue to the user before proceeding.


Inputs

The skill takes one required input:

  • PR number — the numeric GitHub PR being backported (e.g. 1234).

Accept it from the invocation argument or prompt for it:

Enter the PR number to backport:

The target branch is always prompted (see Step 4).


Workflow

Copy this checklist and track progress:

Backport Progress:
- [ ] Step 1: Validate environment
- [ ] Step 2: Fetch PR metadata
- [ ] Step 3: Determine commits to cherry-pick (merge strategy)
- [ ] Step 4: Prompt for target branch
- [ ] Step 5: Create backport branch
- [ ] Step 6: Cherry-pick commit(s)
- [ ] Step 7: Push backport branch
- [ ] Step 8: Open backport PR
- [ ] Step 9: Final summary

Step 1: Validate Environment
bash
gh auth status
git rev-parse --is-inside-work-tree
git status --short
  • If gh auth status fails → tell the user to run gh auth login and stop.
  • If git status --short shows any output → ask the user to commit or stash first and stop.

Also capture the remote repo slug for later PR operations:

bash
gh repo view --json nameWithOwner -q .nameWithOwner

Step 2: Fetch PR Metadata
bash
gh pr view <pr-number> --json number,title,state,mergedAt,mergeCommit,commits,baseRefName,headRefName,url,author

Extract and store:

  • number → $PR_NUMBER
  • title → $PR_TITLE
  • state → must be MERGED (warn if not; allow override)
  • mergeCommit.oid → $MERGE_SHA (null indicates a rebase-merged PR; present for squash or merge-commit)
  • commits[*].oid → $PR_COMMITS (ordered list)
  • baseRefName → $ORIGINAL_BASE (usually main)
  • headRefName → $ORIGINAL_HEAD (original source branch)
  • url → $PR_URL

Display a short summary to the user:

PR #<number>: <title>
  Author:      <author.login>
  State:       <state>
  Base:        <baseRefName>
  Head:        <headRefName>
  Commits:     <len(commits)>
  Merge SHA:   <mergeCommit.oid or "none (likely rebase-merged)">

If state is not MERGED, ask:

This PR is not yet merged. Backport anyway? (yes/no)

Step 3: Determine Commits to Cherry-Pick (Auto-Detect Merge Strategy)

Fetch the latest refs first:

bash
git fetch origin --tags

Auto-detect which commit(s) to cherry-pick based on how the PR was merged:

  1. Squash merge — mergeCommit.oid points to a commit on $ORIGINAL_BASE whose parent count is 1 AND whose commit message typically contains (#<pr-number>). Check with:

    bash
    git cat-file -p <MERGE_SHA> | head -20
    # parents count:
    git rev-list --parents -n 1 <MERGE_SHA> | awk '{print NF-1}'
    • Parent count 1 → squash. Cherry-pick strategy: git cherry-pick <MERGE_SHA>.
    • Store: CP_MODE=squash, CP_ARGS="<MERGE_SHA>".
  2. Merge commit — mergeCommit.oid has 2 parents.

    • Cherry-pick strategy: git cherry-pick -m 1 <MERGE_SHA>.
    • Store: CP_MODE=merge, CP_ARGS="-m 1 <MERGE_SHA>".
  3. Rebase merge — mergeCommit.oid is null OR the commits appear individually on $ORIGINAL_BASE (no merge/squash commit). Also falls here if PR is not merged yet.

    • Cherry-pick strategy: cherry-pick every SHA in $PR_COMMITS in order.
    • Store: CP_MODE=rebase, CP_ARGS="<sha1> <sha2> ...".

Always confirm the detected plan with the user before proceeding:

Detected merge strategy: <CP_MODE>
Will cherry-pick: <CP_ARGS>

Proceed? (yes/no/override)

If override, offer the three modes explicitly and let the user pick.


Step 4: Prompt for Target Branch

Ask the user (always — do not guess):

Enter the target branch to backport into (e.g. release/5.x, maintenance/4.x):

Store as $TARGET_BRANCH.

Verify the target exists on origin:

bash
git ls-remote --heads origin <TARGET_BRANCH>

If empty → error out with: Target branch '<TARGET_BRANCH>' not found on origin.

Fetch the target:

bash
git fetch origin <TARGET_BRANCH>

Step 5: Create Backport Branch

Compute branch name: backport/<target-sanitized>/pr-<pr-number>

Where <target-sanitized> replaces / with - (e.g. release/5.x → release-5.x).

Examples:

  • Target release/5.x, PR 1234 → backport/release-5.x/pr-1234
  • Target maintenance/4.x, PR 987 → backport/maintenance-4.x/pr-987

Show the user:

Backport branch name: backport/<target-sanitized>/pr-<pr-number>

Accept this name or provide an override? (accept/override)

Create the branch from the target:

bash
git checkout -b backport/<target-sanitized>/pr-<pr-number> origin/<TARGET_BRANCH>

If the local branch already exists → ask:

Branch already exists. (delete-and-recreate/use-existing/abort)

Step 6: Cherry-Pick Commit(s)

Execute according to CP_MODE:

squash / merge:

bash
git cherry-pick $CP_ARGS

rebase (multiple commits): iterate in order:

bash
git cherry-pick <sha1>
git cherry-pick <sha2>
...

For each cherry-pick, check exit code:

  • Success (exit 0) → continue to next commit (if any).

  • Conflict (exit non-zero) → pause and prompt the user:

    ⚠️ Cherry-pick conflict on <sha>
    
    Conflicted files:
    <git diff --name-only --diff-filter=U output>
    
    Options:
    1. Pause — I'll resolve the conflict manually, then you continue
    2. Abort — run `git cherry-pick --abort` and delete the backport branch
    3. Skip — run `git cherry-pick --skip` and move on (rebase mode only)
    
    Choose (1-3):
    • Option 1 (pause): wait for user to resolve, then run:
      bash
      git status
      Confirm no unmerged paths remain, then:
      bash
      git cherry-pick --continue
    • Option 2 (abort):
      bash
      git cherry-pick --abort
      # Switch to a safe branch before deleting the backport branch.
      # Use the local target branch if it exists; otherwise create it tracking origin.
      git show-ref --verify --quiet refs/heads/<TARGET_BRANCH> \
        && git checkout <TARGET_BRANCH> \
        || git checkout -b <TARGET_BRANCH> --track origin/<TARGET_BRANCH>
      git branch -D backport/<target-sanitized>/pr-<pr-number>
      Stop the skill and report failure.
    • Option 3 (skip): only valid in rebase mode with multiple commits:
      bash
      git cherry-pick --skip

After all commits are applied, verify:

bash
git log --oneline origin/<TARGET_BRANCH>..HEAD

Show the list of new commits to the user for confirmation.


Show full SKILL.md (365 more words)Show less
Step 7: Push Backport Branch
bash
git push -u origin backport/<target-sanitized>/pr-<pr-number>

If push fails:

  • Authentication/permission → stop and surface the error.
  • Branch already exists on remote → ask: force-push (--force-with-lease) / rename / abort.

Step 8: Open Backport PR

Use gh CLI directly so the title format matches the project convention requested:

Title format:

[<TARGET_BRANCH>] Merge pull request <PR_NUMBER> from <ORIGINAL_HEAD>

Example: [release/5.x] Merge pull request 1234 from feature/fix-logging

Body template:

markdown
Backport of #<PR_NUMBER> to `<TARGET_BRANCH>`.

**Original PR:** <PR_URL>
**Original title:** <PR_TITLE>
**Original base:** `<ORIGINAL_BASE>`
**Original head:** `<ORIGINAL_HEAD>`
**Merge strategy detected:** <CP_MODE>

## Commits cherry-picked
<bulleted list of `<short-sha> <subject>` from `git log --oneline origin/<TARGET_BRANCH>..HEAD`>

## Test plan
- [ ] Verify the backport builds on `<TARGET_BRANCH>`
- [ ] Re-run the original PR's tests against this branch

Create the PR:

bash
gh pr create \
  --base "<TARGET_BRANCH>" \
  --head "backport/<target-sanitized>/pr-<PR_NUMBER>" \
  --title "[<TARGET_BRANCH>] Merge pull request <PR_NUMBER> from <ORIGINAL_HEAD>" \
  --body "<body content built above>"

Pass the body via a heredoc when invoking from the Shell tool:

bash
gh pr create --base "<TARGET_BRANCH>" \
  --head "backport/<target-sanitized>/pr-<PR_NUMBER>" \
  --title "[<TARGET_BRANCH>] Merge pull request <PR_NUMBER> from <ORIGINAL_HEAD>" \
  --body "$(cat <<'EOF'
Backport of #<PR_NUMBER> to `<TARGET_BRANCH>`.
...
EOF
)"

Capture the returned PR URL.

Alternative: The user may instead invoke /sdlc-workflow:open-pr after Step 7 to use the standard PR-opening skill. That path produces a [KEY] <description> title (derived from the Jira ticket key in the branch name) rather than the backport-specific title above. Only use that alternative if the project PR-title convention is explicitly preferred for backports.


Step 9: Final Summary

Present a compact summary to the user:

Backport Complete

  Original PR:     #<PR_NUMBER> — <PR_TITLE>
                   <PR_URL>
  Target branch:   <TARGET_BRANCH>
  Backport branch: backport/<target-sanitized>/pr-<PR_NUMBER>
  Strategy:        <CP_MODE>
  Commits applied: <count>

Backport PR:       <new PR URL>

Next steps:
  1. Wait for CI to pass on the backport PR.
  2. Request review from the original PR's author/owners.
  3. Merge using the project's standard flow for release branches.

Error Handling

gh pr view returns 404

The PR number does not exist or is in a different repo. Ask the user to verify the PR number.

mergeCommit.oid is null but PR is MERGED

Likely a rebase-merged PR. Use CP_MODE=rebase and cherry-pick the individual commits.

Cherry-pick reports "The previous cherry-pick is now empty"

The change is already present on the target branch. Offer:

1. Skip this commit (git cherry-pick --skip)
2. Keep as empty commit (git commit --allow-empty)
3. Abort
"refusing to merge unrelated histories"

The target branch is too far diverged. Abort the cherry-pick, report to the user, and suggest manual backport.

Push rejected (non-fast-forward on backport branch)

Only occurs if the branch existed remotely. Ask the user to choose:

  • --force-with-lease (safe force push)
  • Rename the local branch and retry
  • Abort

Important Notes

  • Never commit directly to the target branch. All work happens on the dedicated backport/... branch; the PR is what updates the target branch.
  • Never use plain git push --force. Use --force-with-lease if force is needed.
  • The skill never merges the created PR — reviewers own that step.
  • Keep the original PR's commit authorship intact; cherry-pick preserves Author: by default. Do not pass --no-commit or rewrite authors unless the user explicitly asks.

Files Modified During Execution

  • Local git state only: a new branch backport/<target-sanitized>/pr-<pr-number> pushed to origin.
  • No files in the working tree are modified outside of cherry-pick content from the original PR.

  • /sdlc-workflow:open-pr — alternative generic PR-opening skill (different title format)

© rundeck, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .claude/skills/backport-pr of rundeck/rundeck.

Open the folder on GitHubat commit d526b7c

Compare with similar skills

Backport PR next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Backport PR compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Backport PR this skillrundeck/rundeck6.3k—~3kAutomated safety check: PassApache-2.0
Azure Pipelines Log Downloaderansible/ansible71k—~825Automated safety check: PassGPL-3.0
Nushellccusage/ccusage19k—~938Automated safety check: PassCustom licence
Make GitHub Actions Workflowdotnet/efcore15k—~2.1kAutomated safety check: PassMIT
AI News RadarLearnPrompt/ai-news-radar1.8k—~2.5kAutomated safety check: NotesMIT
Megatron-LM CI/CD GuideNVIDIA/Megatron-LM18k—~1.8kAutomated safety check: PassApache-2.0

Similar skills

  • Downloads Azure Pipelines CI logs for an Ansible pull request or build so the agent can analyze test failures, after asking you first.

    71k GitHub stars~825 tokensUpdated today
    DevOps & CloudAuto-check passed
  • Nushell

    ccusage/ccusage

    Guides ccusage Nushell scripts. An agent skill from ccusage/ccusage.

    19k GitHub stars~938 tokensUpdated today
    DevOps & CloudAuto-check passed
  • Official

    Create GitHub Actions workflows for CI, automation, or PR management.

    15k GitHub stars~2.1k tokensUpdated today
    DevOps & CloudAuto-check passed
  • AI News Radar

    LearnPrompt/ai-news-radar

    A skill your agent uses when working on AI News Radar, 24 小时 AI 更新雷达, AI 更新雷达, 伯乐Skill, or Scout Skill: finding high-signal AI/tech sources, adding RSS/OPML/GitHub feeds, checking source health…

    1.8k GitHub stars~2.5k tokensUpdated today
    DevOps & CloudAuto-check: notes
  • Megatron-LM CI/CD Guide

    NVIDIA/Megatron-LM

    Official

    Explains Megatron-LM's CI pipeline, PR scope labels, triggering the internal GitLab CI with a dry run first, and investigating CI failures.

    18k GitHub stars~1.8k tokensUpdated today
    DevOps & CloudAuto-check passed
  • Clawsweeper

    openclaw/openclaw

    A skill your agent uses for all ClawSweeper work: OpenClaw issue/PR sweep reports, repair jobs, cloud fix PRs, @clawsweeper maintainer mention commands, trusted ClawSweeper-reviewed…

    392k GitHub stars~3k tokensUpdated today
    DevOps & CloudAuto-check passed

More from rundeck/rundeck

All 10 skills in this repo
  • Cve Remediation

    rundeck/rundeck

    Verify if a CVE affects the project and remediate it. An agent skill from rundeck/rundeck.

    6.3k GitHub stars~2.9k tokensUpdated today
    Auto-check passed
  • Generate standardized CONTEXT.md files for features. An agent skill from rundeck/rundeck.

    6.3k GitHub stars~2k tokensUpdated today
    Auto-check passed
  • I18n Vue Template

    rundeck/rundeck

    Internationalize Vue component templates by replacing all hardcoded strings with $t() calls and adding translations to i18n.ts or enUS.js.

    6.3k GitHub stars~523 tokensUpdated today
    Auto-check: notes
  • Onboard Contributor

    rundeck/rundeck

    Guide a new contributor through the rundeck OSS repo. An agent skill from rundeck/rundeck.

    6.3k GitHub stars~848 tokensUpdated today
    Auto-check passed
  • Write Jest Tests

    rundeck/rundeck

    Write Vue component unit tests. An agent skill from rundeck/rundeck.

    6.3k GitHub stars~486 tokensUpdated today
    Auto-check: notes
  • Create API Endpoint

    rundeck/rundeck

    Create REST API endpoints with proper OpenAPI annotations, API versioning, and testing following Rundeck standards.

    6.3k GitHub stars~2k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Backport PR

What does Backport PR do?

Backport commits from an existing GitHub Pull Request to a target branch and open a new backport PR. Backport PR is an agent skill from rundeck/rundeck. Backport commits from an existing GitHub Pull Request to a target branch and open a new backport PR.

When should I use Backport PR?

Backport PR fits situations like: the user asks to backport a PR; cherry-pick a merged PR into a release/maintenance branch; port a fix to an older version; mentions backport.

How do I install Backport PR in Claude Code?

Run `npx skills add rundeck/rundeck --skill backport-pr -a claude-code`. Or copy the skill folder (.claude/skills/backport-pr in rundeck/rundeck) into .claude/skills/backport-pr in your project. Claude Code loads it when a task matches its description.

How do I install Backport PR in Codex?

Run `npx skills add rundeck/rundeck --skill backport-pr -a codex`. Or copy the skill folder (.claude/skills/backport-pr in rundeck/rundeck) into .agents/skills/backport-pr in your project. Codex loads it when a task matches its description.

Can I use Backport PR in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add rundeck/rundeck --skill backport-pr -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/backport-pr, .gemini/skills/backport-pr, .github/skills/backport-pr and .opencode/skills/backport-pr in your project.

What does Backport PR need to run?

Going by SKILL.md and its folder, Backport PR needs the command-line tools its instructions call (git and gh).

Does Backport PR access the network?

SKILL.md contains no URLs. Its commands use git and gh, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Backport PR safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Backport PR use?

Backport PR is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Backport PR use?

About 3k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Backport PR?

Skills that share tags, products or a category with Backport PR: Azure Pipelines Log Downloader (ansible/ansible, 71k stars), Nushell (ccusage/ccusage, 19k stars), Make GitHub Actions Workflow (dotnet/efcore, 15k stars) and AI News Radar (LearnPrompt/ai-news-radar, 1.8k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Backport PR?

rundeck (a GitHub organization) maintains it in rundeck/rundeck, which has 6,330 GitHub stars. The repository holds 10 skills in this directory. The repository was last updated on October 9, 2026.

Source: rundeck/rundeck on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.