Skip to content

Commit 7e97735

Browse files
authored
docs(agents): Add comment, merge, test scope and PR target rules (#6745)
* docs(agents): Add comment, merge, test scope and PR target rules * docs(agents): Drop --info from test skill and dedupe post-merge checks
1 parent d34bf12 commit 7e97735

3 files changed

Lines changed: 47 additions & 7 deletions

File tree

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ default body shape — it is the single source of truth for the sections and che
112112
reproduce it from memory. Fill in each section based on the changes being PR'd, drop the HTML
113113
comment hints, and check any checklist items that apply.
114114
115+
Before you create the PR, check which repository `gh` targets:
116+
117+
```bash
118+
gh repo set-default --view
119+
```
120+
121+
If it prints anything other than `getsentry/sentry-java`, or nothing, ask the user which repository
122+
to target. Don't let `gh` pick a community fork.
123+
115124
Write the body to `/tmp/pr-body-<branch>.md`, with each `/` in the branch name replaced by `-`, not
116125
to pr-writer's `/tmp/pr-body.md`: that file outlives sessions and can still hold another PR's body.
117126
Only after the write succeeds, pass that file to `gh pr create` in place of pr-writer's:
@@ -169,7 +178,7 @@ Add an entry to `CHANGELOG.md` under the `## Unreleased` section.
169178
170179
Create the subsection under `## Unreleased` if it does not already exist.
171180
172-
**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.
181+
**When rebasing or merging `main`:** Your branch can land after a release was cut, where the `## Unreleased` heading your entry lived under has since been renamed to that version number. A merge does this without a conflict, sometimes with a duplicate subsection heading, so check the `## ` headings, not only the diff. 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.
173182
174183
#### Entry format
175184

‎.claude/skills/test/SKILL.md‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,23 @@ If the user picks a specific method, use `--tests="*ClassName.methodName"` as th
5757

5858
With a test class filter:
5959
```bash
60-
./gradlew ':<module>:<task>' --tests="*<filter>*" --info
60+
./gradlew ':<module>:<task>' --tests="*<filter>*"
6161
```
6262

63-
Without a filter:
63+
Without a filter, only when the user asks for the whole module (CI runs full suites):
6464
```bash
65-
./gradlew ':<module>:<task>' --info
65+
./gradlew ':<module>:<task>'
6666
```
6767

68+
When you choose the tests yourself, filter to the classes or packages the change touches, plus the
69+
tests of direct callers. Pass `--tests` once per pattern:
70+
```bash
71+
./gradlew ':<module>:<task>' --tests="io.sentry.foo.*" --tests="*BarTest*"
72+
```
73+
74+
Don't add `--rerun` or `--no-build-cache` by default. An `UP-TO-DATE` test task already passed on the
75+
same inputs. Use them only for a named doubt, such as a suspected flaky test.
76+
6877
## Step 3b: Run an Integration Test Suite
6978

7079
The suite's task is named after its source set directory: `src/integrationTestWebflux/...` runs

‎AGENTS.md‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ resolves the per-module test task, including integration test suites, for you.
8080
3. **Use todo tracking**: Work through todo items, marking them as complete as you go
8181
4. **High-level communication**: Give high-level explanations of changes made, not step-by-step descriptions
8282
5. **Simplicity first**: Make every task and code change as simple as possible. Avoid massive or complex changes. Impact as little code as possible.
83-
6. **Format and regenerate**: Once done, format code and regenerate .api files: `make format api`
84-
7. **Propose commit**: As final step, git stage relevant files and propose (but not execute) a single git commit command. This applies to implementation work; when the task is to open a PR, the `create-java-pr` skill takes over from here and does commit, push, and open it.
83+
6. **Don't code for impossible states**: Before you add state tracking or heuristics around a framework object, find out its real lifecycle.
84+
7. **Format and regenerate**: Once done, format code and regenerate .api files: `make format api`
85+
8. **Propose commit**: As final step, git stage relevant files and propose (but not execute) a single git commit command. This applies to implementation work; when the task is to open a PR, the `create-java-pr` skill takes over from here and does commit, push, and open it.
8586

8687
## Repository Skills
8788

@@ -133,6 +134,21 @@ The repository is organized into multiple modules:
133134
- **Formatting**: Enforced via Spotless
134135
- **API Compatibility**: Binary compatibility is enforced. `.api` files are generated, never hand-edited
135136

137+
### Comments
138+
139+
The default is no comment. Add one only when it gives a reason that the code, the names, and the
140+
class Javadoc don't, in one short sentence: a rationale, a gotcha, the meaning of a magic number,
141+
why an empty catch is safe, or a comment this file requires (for example on a broad catch).
142+
143+
- Don't describe what the next line does, in production code or in tests.
144+
- Don't repeat what a method Javadoc already describes.
145+
- Existing narrating comments are not a pattern to copy.
146+
147+
**Javadoc of an interface, callback, or model class describes only the type itself**, in general
148+
terms. Requirements on the implementer are fine ("Must be fast, no I/O."). Don't name who calls it,
149+
when, or on which thread: a type can't promise how others use it. A thread contract belongs on the
150+
methods of the component that owns the thread.
151+
136152
### Exception Handling
137153

138154
The following section applies only in cases where the spec (sentry-docs) do not define an exception
@@ -281,7 +297,13 @@ gh pr view --json url -q '.url'
281297

282298
User-facing changes get an entry under the `## Unreleased` section of `CHANGELOG.md`. The
283299
`create-java-pr` skill is the source of truth for the full changelog and PR workflow, including
284-
subsection selection and the rebase caveat when a release renames `## Unreleased`.
300+
subsection selection and the rebase and merge caveat when a release renames `## Unreleased`.
301+
302+
### After Merging `main` or Resolving Conflicts
303+
304+
Before you commit the merge, format and regenerate (workflow rule 7) and check the changelog entry
305+
(the `create-java-pr` rebase and merge caveat). Then compile and run the tests of the modules you
306+
changed: `main` adds build checks over time, so code that passed before the merge can fail after it.
285307

286308
## Useful Resources
287309

0 commit comments

Comments
 (0)