Skip to content

Commit 79f1f2f

Browse files
runningcodeclaude
andauthored
docs(agents): Fold pr.mdc into the create-java-pr skill (#5936)
* docs(agents): Fold pr.mdc into the create-java-pr skill The pr.mdc rule file and the create-java-pr skill described the same six-step PR workflow, and both inlined a copy of the PR template and the changelog subsection table. Nobody on the team uses Cursor, so the rule/skill split earned nothing and the two copies had already drifted: both inlined templates were missing the "Public API changes reviewed by another Mobile SDK team member" checklist item that .github/pull_request_template.md has gained since. Delete pr.mdc and give its content one home each. The conventions the skill was missing (allowed commit types, PR title format, changelog rebase caveat) move into the skill. The stacked-PR workflow moves to a references file the skill loads on demand, so the common standalone-PR path no longer carries 150 lines that only apply to stacks. The skill now reads .github/pull_request_template.md instead of reproducing it, leaving one copy that cannot drift. #skip-changelog * docs(agents): Trim generic stacking guidance from stacked-prs.md The reference file mixed two kinds of content: the standard Graphite-style stacking workflow, which any agent can reconstruct from general knowledge and `gh` usage, and the parts specific to this repo. The generic half diluted the half that matters. Drop the chain-walking recipe, the branch naming convention, the generic create/merge/sync steps, and the restatement of the stack shape. Keep what is not derivable: why the collection branch exists (`main` is squash-only, which conflicts repeatedly when syncing a stack), the title and stack list formats, and the permission-pattern constraint on editing PR bodies. Collect the four destructive-operation warnings under one heading instead of leaving them scattered across three sections, and point SKILL.md at the surviving section names. #skip-changelog * docs(agents): Fix defects found by dry-running the PR skill Ran fresh agents through "create a PR" and "create a stacked PR" against the deduped docs, stopping each before the first mutating action. Both paths loaded the intended files, but four defects surfaced: - SKILL.md named stacked-prs.md the source of truth for branch naming, which that file never covered. Corrected to title naming; the branch rule stays in Step 1, where the branch is created. - Four passages referenced the collection branch PR, but no step ever opened it. Added next to the branch creation, with its title and merge-reminder exceptions. - The PR-description editing rule was stated three times and had already drifted. It now lives once in SKILL.md, which both the standalone and stacked paths read, and stacked-prs.md points back to it. - AGENTS.md rule 7 told agents to propose but not execute a commit while the create-java-pr skill commits, pushes, and opens the PR, leaving two terminal states for one request. Scoped rule 7 to implementation work. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 4fb69af commit 79f1f2f

4 files changed

Lines changed: 128 additions & 305 deletions

File tree

.claude/skills/create-java-pr/SKILL.md

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ description: Create a pull request in sentry-java. Use when asked to "create pr"
77

88
Prepare local changes and create a pull request for the sentry-java repo.
99

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.
10+
**For stacked PRs:** read `references/stacked-prs.md` before proceeding. It is the source of truth for
11+
stack structure, title naming, stack list format, and merge strategy.
1112

1213
## Step 0: Determine PR Type From Git Branch Context
1314

@@ -66,7 +67,7 @@ git checkout -b <type>/<short-description>
6667

6768
Derive the branch name from the changes being made. Use `feat/`, `fix/`, `ref/`, etc. matching the commit type conventions.
6869

69-
**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".
70+
**For stacked PRs:** For the first PR in a new stack, first create and push the collection branch (see `references/stacked-prs.md` § "Why a Collection Branch"), then branch the PR off it. For subsequent PRs, branch off the previous stack branch. Give every branch in the stack a shared prefix naming the feature, with a descriptive suffix per PR.
7071

7172
**CRITICAL: Never merge, fast-forward, or push commits into the collection branch.** It stays at its initial position until the user merges stack PRs through GitHub. Updating it will auto-merge and destroy the entire PR stack.
7273

@@ -88,7 +89,13 @@ Check for uncommitted changes:
8889
git status --porcelain
8990
```
9091

91-
If there are uncommitted changes, invoke the `sentry-skills:commit` skill to stage and commit them following Sentry conventions.
92+
If there are uncommitted changes, invoke the `sentry-skills:commit` skill to stage and commit them following [Sentry commit message conventions](https://develop.sentry.dev/engineering-practices/commit-messages/):
93+
94+
```
95+
<type>(<scope>): <subject>
96+
```
97+
98+
Allowed types: `feat`, `fix`, `ref`, `chore`, `docs`, `test`, `perf`, `build`, `ci`, `style`, `meta`, `license`
9299

93100
**Important:** When staging, ignore changes that are only relevant for local testing and should not be part of the PR. Common examples:
94101

@@ -114,53 +121,38 @@ If the push fails due to diverged history, ask the user how to proceed rather th
114121

115122
## Step 5: Create PR
116123

117-
Invoke the `sentry-skills:create-pr` skill to create a draft PR. When providing the PR body, use the repo's PR template structure from `.github/pull_request_template.md`:
124+
Invoke the `sentry-skills:create-pr` skill to create a draft PR.
125+
126+
Read `.github/pull_request_template.md` and use it as the PR body structure — it is the single source
127+
of truth for the sections and checklist, so never reproduce it from memory. Fill in each section based
128+
on the changes being PR'd, drop the HTML comment hints, and check any checklist items that apply.
129+
130+
**PR title format** — same as the commit subject (Step 3):
118131
119132
```
120-
## :scroll: Description
121-
<Describe the changes in detail>
122-
123-
## :bulb: Motivation and Context
124-
<Why is this change required? What problem does it solve?>
125-
126-
## :green_heart: How did you test it?
127-
<Describe how you tested>
128-
129-
## :pencil: Checklist
130-
- [ ] I added GH Issue ID _&_ Linear ID
131-
- [ ] I added tests to verify the changes.
132-
- [ ] No new PII added or SDK only sends newly added PII if `sendDefaultPII` is enabled.
133-
- [ ] I updated the docs if needed.
134-
- [ ] I updated the wizard if needed.
135-
- [ ] Review from the native team if needed.
136-
- [ ] No breaking change or entry added to the changelog.
137-
- [ ] No breaking change for hybrid SDKs or communicated to hybrid SDKs.
138-
139-
## :crystal_ball: Next steps
133+
<type>(<scope>): <Subject>
140134
```
141135
142-
Fill in each section based on the changes being PR'd. Check any checklist items that apply.
136+
Examples:
137+
- `feat(core): Add structured logging support`
138+
- `fix(android): Prevent crash on API 21 when registering receiver`
143139
144140
**For stacked PRs:**
145141
146142
- Pass `--base <previous-stack-branch>` so the PR targets the previous branch (first PR in a stack targets the collection branch).
147-
- Use the stacked PR title format: `<type>(<scope>): [<Topic> <N>] <Subject>` (see `.cursor/rules/pr.mdc` § "PR Title Naming").
148-
- 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).
149-
- Add a merge method reminder at the very end of the PR body (see `.cursor/rules/pr.mdc` § "Stack List in PR Description" for the exact text). This only applies to stack PRs, not the collection branch PR.
143+
- Use the stacked PR title format: `<type>(<scope>): [<Topic> <N>] <Subject>` (see `references/stacked-prs.md` § "PR Title Naming").
144+
- Include the stack list at the top of the PR body, before the `## :scroll: Description` section (see `references/stacked-prs.md` § "Stack List in PR Description" for the format).
145+
- Add a merge method reminder at the very end of the PR body (see `references/stacked-prs.md` § "Stack List in PR Description" for the exact text). This only applies to stack PRs, not the collection branch PR.
150146
151147
Then continue to Step 5.5 (stacked PRs only) or Step 6.
152148
153149
## Step 5.5: Update Stack List on All PRs (stacked PRs only)
154150
155151
Skip this step for standalone PRs.
156152
157-
After creating the PR, update the PR description on **every other PR in the stack — including the collection branch PR** — 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".
153+
After creating the PR, update the PR description on **every other PR in the stack — including the collection branch PR** — so all PRs have the same up-to-date stack list. Follow the format and commands in `references/stacked-prs.md` § "Stack List in PR Description".
158154
159-
**Important:** When updating PR bodies, never use shell redirects (`>`, `>>`) or pipes (`|`) or compound commands (`&&`). These create compound shell expressions that won't match permission patterns. Instead:
160-
- Use `gh pr view <NUMBER> --json body --jq '.body'` to get the body (output returned directly)
161-
- Use the `Write` tool to save it to a temp file
162-
- Use the `Edit` tool to modify the temp file
163-
- Use `gh pr edit <NUMBER> --body-file /tmp/pr-body.md` to update
155+
Edit each body using the procedure in § "Editing PR Descriptions" below.
164156
165157
## Step 6: Update Changelog
166158
@@ -190,6 +182,8 @@ Add an entry to `CHANGELOG.md` under the `## Unreleased` section.
190182
191183
Create the subsection under `## Unreleased` if it does not already exist.
192184
185+
**When rebasing:** A rebase onto `main` can land your branch after a release was cut, where the `## Unreleased` heading your entry lived under has since been renamed to that version number. If that happens, move your new entry into an `## Unreleased` section at the top of `CHANGELOG.md` (create the section if it no longer exists) so it is not left under an already-released version.
186+
193187
#### Entry format
194188
195189
```markdown
@@ -210,8 +204,14 @@ git push
210204
211205
### No changelog needed
212206
213-
If no changelog entry is needed, add `#skip-changelog` to the PR description to disable the changelog CI check:
207+
If no changelog entry is needed, append `#skip-changelog` to the end of the PR description to disable
208+
the changelog CI check, using the procedure in § "Editing PR Descriptions" below.
209+
210+
## Editing PR Descriptions
211+
212+
Do not use shell redirects (`>`, `>>`), pipes (`|`), or compound commands (`&&`, `||`). These create
213+
compound shell expressions that won't match permission patterns. Instead:
214214

215-
1. Get the current body: `gh pr view <PR_NUMBER> --json body --jq '.body'`
216-
2. Use the `Write` tool to save the output to `/tmp/pr-body.md`, appending `\n#skip-changelog\n` at the end
217-
3. Update: `gh pr edit <PR_NUMBER> --body-file /tmp/pr-body.md`
215+
1. Read the body with `gh pr view <PR_NUMBER> --json body --jq '.body'` (output is returned directly)
216+
2. Use the `Write` tool to save it to `/tmp/pr-body.md`, and the `Edit` tool to modify it
217+
3. Update with `gh pr edit <PR_NUMBER> --body-file /tmp/pr-body.md`
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Stacked PRs
2+
3+
Stacked PRs split a large feature into small, easy-to-review PRs where each builds on the previous
4+
one. The general mechanics are the standard [Graphite](https://graphite.dev/) stacking workflow —
5+
this file covers only what is specific to sentry-java.
6+
7+
## Why a Collection Branch
8+
9+
```
10+
main ← collection-branch ← stack-pr-1 ← stack-pr-2 ← stack-pr-3 ← ...
11+
```
12+
13+
A **collection branch** is created from `main` and targets `main`. The first stack PR targets it
14+
rather than `main`, and each later PR targets the previous stack PR's branch.
15+
16+
It exists because PRs targeting `main` are **squash**-merged, which causes repeated merge conflicts
17+
when syncing a stack. Stack PRs are therefore **merge-committed** into the collection branch, and
18+
only the collection branch is squash-merged into `main` at the end — giving `main` one clean commit
19+
for the whole feature.
20+
21+
Create it with an empty commit, so GitHub allows opening a PR:
22+
23+
```bash
24+
git commit --allow-empty -m "collection: <topic>"
25+
```
26+
27+
Push it and open its PR against `main` right away — it is the PR the whole stack is eventually
28+
squash-merged through, and it carries the stack list like every other PR. Give it a plain title
29+
(`<type>(<scope>): <Topic>`, no `[<Topic> <N>]` bracket) and no merge method reminder.
30+
31+
## Rules That Will Destroy a Stack If Broken
32+
33+
**Never update the collection branch yourself.** Never merge, fast-forward, or push stack branch
34+
commits into it. It stays at its initial position (the empty commit on `main`) until the user merges
35+
stack PRs through GitHub one by one. Fast-forwarding it makes GitHub auto-merge and delete every
36+
stack PR branch, destroying the entire stack.
37+
38+
**Never amend or force-push a stack branch.** No `git commit --amend`, `--force`, or
39+
`--force-with-lease` on a branch that is part of a stack — a force-push can cause GitHub to
40+
auto-merge or auto-close the other PRs in the stack. If a commit needs fixing, add a fixup commit.
41+
42+
**Sync only between adjacent stack branches**, by merging forward — never into the collection branch.
43+
Prefer merge over rebase; only rebase if explicitly requested.
44+
45+
**Do not merge PRs.** Only the user merges them, bottom to top.
46+
47+
## PR Title Naming
48+
49+
Include the topic name and a sequential number in brackets:
50+
51+
```
52+
<type>(<scope>): [<Topic> <N>] <Subject>
53+
```
54+
55+
Examples:
56+
- `feat(core): [Global Attributes 1] Add scope-level attributes API`
57+
- `feat(core): [Global Attributes 2] Wire scope attributes into LoggerApi and MetricsApi`
58+
59+
## Stack List in PR Description
60+
61+
Every PR in the stack — **including the collection branch PR** — must have a stack list **at the top
62+
of its description**, before the `## :scroll: Description` section. When a PR is added, update the
63+
description on **all** PRs in the stack. The stack list is also how you enumerate a stack: read it
64+
off any PR body rather than guessing from branch names, which may use different prefixes.
65+
66+
```markdown
67+
## PR Stack (<Topic>)
68+
69+
- #5118
70+
- #5120
71+
- #5121
72+
73+
---
74+
```
75+
76+
No status column — GitHub already shows that. The `---` separates the stack list from the rest of
77+
the description.
78+
79+
**Merge method reminder:** on stack PRs (not the collection branch PR), end the description with:
80+
81+
```markdown
82+
> ⚠️ **Merge this PR using a merge commit** (not squash). Only the collection branch is squash-merged into main.
83+
```
84+
85+
Updating every PR's stack list means editing several descriptions — follow the procedure in
86+
`SKILL.md` § "Editing PR Descriptions".

0 commit comments

Comments
 (0)