You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: Add stacked PR support to create-java-pr skill and PR rules (#5151)
* chore: Add stacked PR support to create-java-pr skill and PR rules
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: Use --body-file to avoid shell quoting issues in PR body edits
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: .claude/skills/create-java-pr/SKILL.md
+55-6Lines changed: 55 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,24 @@
1
1
---
2
2
name: create-java-pr
3
-
description: Create a pull request in sentry-java. Use when asked to "create pr", "prepare pr", "prep pr", "open pr", "ready for pr", "prepare for review", "finalize changes". Handles branch creation, code formatting, API dump, committing, pushing, PR creation, and changelog.
3
+
description: Create a pull request in sentry-java. Use when asked to "create pr", "prepare pr", "prep pr", "open pr", "ready for pr", "prepare for review", "finalize changes". Handles branch creation, code formatting, API dump, committing, pushing, PR creation, changelog, and stacked PRs.
4
4
---
5
5
6
6
# Create Pull Request (sentry-java)
7
7
8
8
Prepare local changes and create a pull request for the sentry-java repo.
9
9
10
+
**Required reading:** Before proceeding, read `.cursor/rules/pr.mdc` for the full PR and stacked PR workflow details. That file is the source of truth for PR conventions, stack comment format, branch naming, and merge strategy.
11
+
12
+
## Step 0: Determine PR Type
13
+
14
+
Ask the user (or infer from context) whether this is:
15
+
16
+
-**Standalone PR** — a regular PR targeting `main`. Follow Steps 1–6 as written.
17
+
-**First PR of a new stack** — ask for a topic name (e.g. "Global Attributes"). Create a collection branch from `main`, then branch the first PR off it. The first PR targets the collection branch.
18
+
-**Next PR in an existing stack** — identify the previous stack branch and topic. This PR targets the previous stack branch.
19
+
20
+
If the user mentions "stack", "stacked PR", or provides a topic name with a number (e.g. `[Topic 2]`), treat it as a stacked PR. See `.cursor/rules/pr.mdc` § "Stacked PRs" for full details.
Derive the branch name from the changes being made. Use `feat/`, `fix/`, `ref/`, etc. matching the commit type conventions.
23
35
36
+
**For stacked PRs:** For the first PR in a new stack, first create and push the collection branch (see `.cursor/rules/pr.mdc` § "Creating the Collection Branch"), then branch the PR off it. For subsequent PRs, branch off the previous stack branch. Use the naming conventions from `.cursor/rules/pr.mdc` § "Branch Naming".
37
+
24
38
## Step 2: Format Code and Regenerate API Files
25
39
26
40
```bash
@@ -92,13 +106,38 @@ Invoke the `sentry-skills:create-pr` skill to create a draft PR. When providing
92
106
93
107
Fill in each section based on the changes being PR'd. Check any checklist items that apply.
94
108
95
-
Then continue to Step 6.
109
+
**For stacked PRs:**
110
+
111
+
- Pass `--base <previous-stack-branch>` so the PR targets the previous branch (first PR in a stack targets the collection branch).
112
+
- Use the stacked PR title format: `<type>(<scope>): [<Topic> <N>] <Subject>` (see `.cursor/rules/pr.mdc` § "PR Title Naming").
113
+
- Include the stack list at the top of the PR body, before the `## :scroll: Description` section (see `.cursor/rules/pr.mdc` § "Stack List in PR Description" for the format).
114
+
115
+
Then continue to Step 5.5 (stacked PRs only) or Step 6.
116
+
117
+
## Step 5.5: Update Stack List on All PRs (stacked PRs only)
118
+
119
+
Skip this step for standalone PRs.
120
+
121
+
After creating the PR, update the PR description on **every other PR in the stack** so all PRs have the same up-to-date stack list. Follow the format and commands in `.cursor/rules/pr.mdc` § "Stack List in PR Description".
96
122
97
123
## Step 6: Update Changelog
98
124
99
-
After the PR is created, add an entry to `CHANGELOG.md` under the `## Unreleased` section.
125
+
First, determine whether a changelog entry is needed. **Skip this step** (and go straight to "No changelog needed" below) if the changes are not user-facing, for example:
126
+
127
+
- Test-only changes (new tests, test refactors, test fixtures)
128
+
- CI/CD or build configuration changes
129
+
- Documentation-only changes
130
+
- Code comments or formatting-only changes
131
+
- Internal refactors with no behavior change visible to SDK users
132
+
- Sample app changes
133
+
134
+
If unsure, ask the user.
135
+
136
+
### If changelog is needed
137
+
138
+
Add an entry to `CHANGELOG.md` under the `## Unreleased` section.
100
139
101
-
### Determine the subsection
140
+
####Determine the subsection
102
141
103
142
| Change Type | Subsection |
104
143
|---|---|
@@ -109,15 +148,15 @@ After the PR is created, add an entry to `CHANGELOG.md` under the `## Unreleased
109
148
110
149
Create the subsection under `## Unreleased` if it does not already exist.
Use the PR number returned by `sentry-skills:create-pr`. Match the style of existing entries — sentence case, ending with the PR link, no trailing period.
119
158
120
-
### Commit and push
159
+
####Commit and push
121
160
122
161
Stage `CHANGELOG.md`, commit with message `changelog`, and push:
123
162
@@ -126,3 +165,13 @@ git add CHANGELOG.md
126
165
git commit -m "changelog"
127
166
git push
128
167
```
168
+
169
+
### No changelog needed
170
+
171
+
If no changelog entry is needed, add `#skip-changelog` to the PR description to disable the changelog CI check:
172
+
173
+
```bash
174
+
gh pr view <PR_NUMBER> --json body --jq '.body'> /tmp/pr-body.md
- The first PR in the stack targets `main` as its base branch.
126
+
- A **collection branch** is created from `main` and targets `main`. It serves as the base for the entire stack.
127
+
- The first PR in the stack targets the collection branch (not `main`).
127
128
- Each subsequent PR targets the previous stack PR's branch as its base.
128
129
- Each PR contains only incremental changes on top of the previous one.
129
130
131
+
The collection branch exists so that individual stack PRs can be **merge-committed** (not squashed). PRs targeting `main` use squash merging, but that causes repeated merge conflicts when syncing the stack. Merge commits on non-`main` branches avoid this. The collection branch itself is squash-merged into `main` at the end.
132
+
130
133
### Branch Naming
131
134
132
-
Prefer a shared prefix for the feature, with descriptive suffixes per PR. The type prefix (`feat/`, `fix/`, etc.) may vary depending on the nature of each PR's changes:
135
+
Prefer a shared prefix for the feature, with descriptive suffixes per PR. The collection branch uses the shared prefix. The type prefix (`feat/`, `fix/`, etc.) may vary depending on the nature of each PR's changes:
133
136
134
137
```
135
-
feat/scope-attributes # PR 1
136
-
feat/scope-attributes-logger # PR 2
137
-
fix/attribute-type-detection # PR 3 (fix, different name — that's fine)
138
+
feat/scope-attributes # collection branch → targets main
2. Read the stack comment on that PR — it lists every PR in the stack.
162
-
3. If there is no stack comment yet, walk the chain in both directions:
165
+
2. Read the PR description — the stack list is at the top of the body.
166
+
3. If there is no stack list yet, walk the chain in both directions:
163
167
```bash
164
168
# Find the PR whose head branch is the current PR's base (go up)
165
169
gh pr list --head <baseRefName> --json number,title,baseRefName
166
170
167
171
# Find PRs whose base branch is the current PR's head (go down)
168
172
gh pr list --base <currentBranch> --json number,title,headRefName
169
173
```
170
-
Repeat until you reach `main` going up and find no more PRs going down.
174
+
Repeat until you reach the collection branch going up and find no more PRs going down.
175
+
176
+
### Creating the Collection Branch
177
+
178
+
Before the first stacked PR, create the collection branch with an empty commit (so GitHub allows opening a PR) and create the collection PR:
179
+
180
+
```bash
181
+
git checkout main
182
+
git checkout -b feat/<topic>
183
+
git commit --allow-empty -m "collection: <topic>"
184
+
git push -u origin HEAD
185
+
gh pr create --base main --draft --title "<type>(<scope>): <Topic>" --body "Collection PR for the <Topic> stack. Squash-merge this once all stack PRs are merged."
186
+
```
171
187
172
188
### Creating a New Stacked PR
173
189
174
-
1. Start from the tip of the previous stack branch (or `main` for the first PR).
190
+
1. Start from the tip of the previous stack branch (or the collection branch for the first PR).
175
191
2. Create a new branch, make changes, format, commit, and push.
176
-
3. Create the PR with `--base <previous-branch>`:
192
+
3. Create the PR with `--base <previous-branch>` (the collection branch for the first PR):
4. Add the stack comment to the new PR and update it on all existing PRs in the stack (see below).
196
+
4. Add the stack list to the top of the new PR's description and update it on all existing PRs in the stack (see below).
181
197
182
-
### Stack Comment
198
+
### Stack List in PR Description
183
199
184
-
Every PR in the stack must have a comment listing all PRs in the stack. When a new PR is added, update the comment on **all** PRs in the stack.
200
+
Every PR in the stack must have a stack list **at the top of its description** (before the `## :scroll: Description` section). When a new PR is added, update the description on **all** PRs in the stack.
185
201
186
202
Format:
187
203
@@ -191,26 +207,33 @@ Format:
191
207
- [#5118](https://github.com/getsentry/sentry-java/pull/5118) — Add scope-level attributes API
192
208
- [#5120](https://github.com/getsentry/sentry-java/pull/5120) — Wire scope attributes into LoggerApi and MetricsApi
193
209
- [#5121](https://github.com/getsentry/sentry-java/pull/5121) — Showcase scope attributes in Spring Boot 4 samples
210
+
211
+
---
194
212
```
195
213
196
-
No status column — GitHub already shows that.
214
+
No status column — GitHub already shows that. The `---` separates the stack list from the rest of the PR description.
197
215
198
-
To add or update the stack comment on a PR:
216
+
To update the PR description, use `--body-file` to avoid shell quoting issues with special characters in the body:
### Merging Stacked PRs (done by the user, not the agent)
231
+
232
+
Individual stack PRs are merged in order from bottom to top (PR 1 first, then PR 2, etc.) using **merge commits** (not squash). After each merge, the next PR's base automatically becomes the merged branch's target. GitHub handles rebasing onto the new base.
233
+
234
+
Once all stack PRs are merged into the collection branch, the collection PR is **squash-merged** into `main`. This gives `main` a clean single commit for the entire feature.
212
235
213
-
Merge in order from bottom to top (PR 1 first, then PR 2, etc.). After each merge, the next PR's base automatically becomes the merged branch's target. GitHub handles rebasing onto the new base. Verify each PR's diff still looks correct after the previous one merges.
0 commit comments