Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions .agents/skills/backport-pr/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
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.
---

# 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:

```bash
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:

```bash
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`:

```bash
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:

```bash
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:

```bash
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:

```text
[backport] <original PR title>
```

Use a concise PR body:

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

<!-- NEXT_JS_LLM_PR -->
```

## 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.
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ Use skills for conditional, deep workflows. Keep baseline iteration/build/test p

- `$pr-status-triage` - CI failure and PR review triage with `scripts/pr-status.js`
- `$create-pr` - branch, commit, push, and draft PR creation workflow
- `$backport-pr` - cherry-pick merged PRs from `canary` to release branches
- `$flags` - feature-flag wiring across config/schema/define-env/runtime env
- `$dce-edge` - DCE-safe `require()` patterns and edge/runtime constraints
- `$react-vendoring` - `entry-base.ts` boundaries and vendored React type/runtime rules
Expand Down
6 changes: 6 additions & 0 deletions contributing/core/developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ Or without running the build:
pnpm pack-next --no-js-build --tar && pnpm unpack-next path/to/project
```

To create tarballs inside the project directory with deployable relative `file:` references:

```bash
pnpm pack-next --project path/to/project --deployable-tar
```

Without going through a tarball (only works if you've added the overrides from `pack-next`):

```bash
Expand Down
9 changes: 9 additions & 0 deletions contributing/core/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,15 @@ On Linux, this generates stripped `@next/swc` binaries to avoid exceeding 2 GiB,
known to cause problems with `pnpm`](https://github.com/libuv/libuv/pull/1501). That behavior can be
overridden with `--compress objcopy-zstd` on Linux (which is slower, but retains debuginfo).

To create tarballs that can be deployed with a project, use:

```bash
pnpm pack-next --project ~/my-project/ --deployable-tar
```

This writes the tarballs to a `tarballs` directory next to the patched project `package.json` and
uses relative `file:` references so the tarballs can be included with the project.

These tarballs can be extracted directly into a project's `node_modules` directory (bypassing the
package manager) by using:

Expand Down
4 changes: 4 additions & 0 deletions packages/next/src/next-devtools/server/launch-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ const COMMON_EDITORS_MACOS = {
'/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl',
'/Applications/Visual Studio Code.app/Contents/MacOS/Electron':
'/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code',
'/Applications/Visual Studio Code.app/Contents/MacOS/Code':
'/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code',
'/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron':
'/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code',
'/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Code - Insiders':
'/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code',
'/Applications/VSCodium.app/Contents/MacOS/Electron':
'/Applications/VSCodium.app/Contents/Resources/app/bin/code',
'/Applications/AppCode.app/Contents/MacOS/appcode':
Expand Down
Loading
Loading