Backport PR to Next.js release branch

VerifiedCaution

Backport a merged Next.js PR from canary to a release branch using git cherry-pick and open a draft PR with the correct base.

Sby Skills Guide Bot
DevelopmentIntermediate
8/29/2026
Claude Code
#backport#cherry-pick#git#release-branches#pull-requests

Recommended for

Automated summary

Automates backporting an already-merged Next.js pull request from canary onto an older release branch by cherry-picking the landed commit and opening the backport PR.

Strengths

  • Lays out a complete, ordered git workflow: inspect worktree, fetch, locate the merge commit, branch off the release branch, cherry-pick with -x, validate, then open the PR
  • Explicitly protects the user's git state (no overwrite, reset, or stash without consent) and asks for the target branch when it cannot be inferred confidently
  • Handles edge cases: empty cherry-pick (change already present), conflict resolution favoring release-branch compatibility, unusable GitHub merge commit fallback via git log --grep
  • Specifies narrowest-fit verification per touched files and forces the PR base to the release branch instead of canary

Limitations

  • Tightly coupled to the vercel/next.js repository and its conventions (canary, pnpm build-all, next-16-2 branches), so it is not directly reusable elsewhere
  • Assumes gh is authenticated and the user can push branches and open PRs
  • Relies on the $create-pr skill, which is not described here
When to use it

Use it when a merged Next.js PR on canary must be ported to an existing release branch such as next-16-2.

When not to use it

Avoid it for backports in other repositories, or when the cherry-pick cannot be validated with the branch's build and tests.

Security analysis

Caution
Quality score85/100

The instructions are limited to standard, transparent git/gh workflow steps for backporting a merged PR. There is no destructive command, no credential or secret handling, no obfuscated payload, and no attempt to disable safety. It explicitly tells the agent to inspect `git status` and not to overwrite, reset, or stash unrelated user changes without consent. The residual risk is ordinary: it mutates git/remote state and opens PRs, which warrants a caution rather than safe rating, but nothing here is malicious or exfiltrating.

Findings
  • •Skill drives mutating git operations on the user's worktree and remote: branch creation, cherry-pick, and (via $create-pr) pushing a branch and opening a PR
  • •Uses network-fetching CLIs (git fetch, gh pr view) against vercel/next.js
  • •No allowed-tools declared, so an agent may treat arbitrary shell commands as in scope
How this analysis is made

Examples

Backport to next-16-2
Backport PR #74219 to next-16-2: cherry-pick it from canary, run the relevant checks, and open a draft backport PR against the release branch.
Backport without tests
Cherry-pick merged PR #73980 onto next-16-3 and open the draft backport PR — skip the integration tests, just prepare the cherry-pick and PR.
Check for duplicate backport
Can you backport PR #74502 to next-16-2? If the change is already on that release branch, tell me instead of opening a PR.

name: backport-pr description: > Backport a merged Next.js pull request from canary to a previous release branch such as next-16-2. Use when the user asks to backport, cherry-pick, or open a backport PR from a PR number to an older Next.js version. Covers finding the merged PR commit, creating a backport branch from the target release branch, cherry-picking from canary, validating, and opening the PR with the release branch as the base. metadata: internal: true

Backport PR

Use this skill when a user asks to backport a merged Next.js PR to a release branch.

Inputs

  • Require a PR number and a target release branch, for example next-16-2.
  • If the target branch is not provided and cannot be inferred confidently from the user's request, ask before mutating git state.
  • Treat the target branch as variable; do not hard-code next-16-2 except when the user explicitly asks for it.

Workflow

  1. Inspect the current worktree before changing branches:

    git status --short
    git branch --show-current
    

    Preserve unrelated user changes. Do not overwrite, reset, or stash them without the user's consent.

  2. Sync the source and target branches:

    git fetch origin canary:refs/remotes/origin/canary <target-branch>:refs/remotes/origin/<target-branch>
    
  3. Identify the commit that landed the PR on canary:

    gh pr view <pr-number> --repo vercel/next.js --json number,title,state,url,mergeCommit,baseRefName,headRefName
    git log origin/canary --oneline --fixed-strings --grep="(#<pr-number>)"
    

    Prefer mergeCommit.oid when the PR is MERGED and the commit is contained in origin/canary. If GitHub does not return a usable merge commit, use the git log --grep result and verify the commit subject references the PR number.

  4. Create the backport branch from the release branch:

    git switch -c backport-<pr-number>-to-<target-branch> origin/<target-branch>
    

    After switching branches in this repo, run pnpm build-all before Next.js integration tests unless the user explicitly limits the task to preparing the cherry-pick or PR.

  5. Cherry-pick the landed commit with provenance:

    git cherry-pick -x <merged-commit-sha>
    

    Resolve conflicts in favor of preserving the release branch's compatibility constraints. If the cherry-pick is empty, verify whether the change is already present on the release branch and report that instead of opening a duplicate PR.

  6. Verify with the narrowest commands that cover the touched files. Prefer focused tests, pnpm types for TypeScript-only risk, and the relevant integration test mode for behavior changes.

  7. Open the backport PR using $create-pr.

    Override the normal $create-pr base branch: use --base <target-branch>, not canary. Keep the PR as a draft unless the user explicitly asks otherwise.

PR Shape

Use a title like:

[backport] <original PR title>

Use a concise PR body:

Backports <original PR title/link> to `<target-branch>`.

<!-- NEXT_JS_LLM -->

Related Skills

  • $create-pr - Create the branch commit, push it, and open the draft PR.
  • $pr-status-triage - Check CI failures or review feedback after the PR exists.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/backport-pr-to-next-js-release-branch-mte1lkjw/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/backport-pr-to-next-js-release-branch-mte1lkjw' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/backport-pr-to-next-js-release-branch-mte1lkjw/download' --output '.skill-downloads/backport-pr-to-next-js-release-branch-mte1lkjw/SKILL.md.part' && mv '.skill-downloads/backport-pr-to-next-js-release-branch-mte1lkjw/SKILL.md.part' '.skill-downloads/backport-pr-to-next-js-release-branch-mte1lkjw/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/backport-pr-to-next-js-release-branch-mte1lkjw/SKILL.md' && test -s '.skill-downloads/backport-pr-to-next-js-release-branch-mte1lkjw/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/backport-pr' && cp -R '.skill-downloads/backport-pr-to-next-js-release-branch-mte1lkjw' '.claude/skills/backport-pr'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/backport-pr-to-next-js-release-branch-mte1lkjw'

openskills read 'backport-pr-to-next-js-release-branch-mte1lkjw'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/backport-pr-to-next-js-release-branch-mte1lkjw/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills