Skip to content

Commit 5114372

Browse files
committed
docs: add AGENTS.md and CLAUDE.md for AI coding agents
Motivation: AI coding agents benefit from project-specific instructions to follow conventions, run correct validation, and produce consistent PRs. Modification: Add AGENTS.md with comprehensive rules (worktree, licensing, PR, formatting, validation, test, code, CI, commit format) and CLAUDE.md with a pre-PR verification checklist. Result: AI agents working on this repository will follow established conventions and produce higher-quality contributions. Tests: Not run - docs only References: None - AI agent configuration
1 parent 3fb7983 commit 5114372

2 files changed

Lines changed: 168 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# Agent Rules for Apache Pekko Samples
2+
3+
If this file conflicts with community conventions, update this file.
4+
5+
## Worktree Rules
6+
7+
- Base new work on `origin/main` unless the user or maintainer requests another branch.
8+
- Keep every PR scoped to one change.
9+
- Do not mix behavior changes, formatting churn, dependency updates, and unrelated cleanup.
10+
- Do not revert user changes or unrelated local changes.
11+
- Use `rg` or `rg --files` for repository searches.
12+
- Read neighboring code before editing.
13+
- Preserve existing license and copyright notices.
14+
- Do not add `@author` tags.
15+
- Follow the Licensing Rules below for every new file.
16+
17+
## Project Structure
18+
19+
- Each sample is a standalone sbt project in its own directory (e.g., `pekko-sample-cluster-java/`).
20+
- Each sample has its own `build.sbt` and `README.md`.
21+
- Samples come in Java and Scala variants where applicable.
22+
- The `docs-gen/` directory generates documentation from samples.
23+
24+
## Licensing Rules
25+
26+
- Do not hand-write or invent license headers. Let sbt manage them.
27+
- For new files, run `sbt headerCreateAll` to add the correct header. Do not manually paste header text.
28+
- Existing files with copyright statements must keep those copyright statements intact. Never delete or rewrite an existing copyright notice; only add information.
29+
- New files containing new code must use the standard Apache license header.
30+
31+
## PR Rules
32+
33+
- Every sample change must keep the sample compilable and runnable.
34+
- Sample changes must update the corresponding `README.md`.
35+
- Java and Scala variants of the same sample must stay in sync.
36+
- Dependency changes must verify Apache-compatible licenses.
37+
- Do not break the `docs-gen` build when changing samples referenced by documentation.
38+
39+
## Formatting Rules
40+
41+
- Prefer native scalafmt for changed Scala and SBT files when it is available.
42+
43+
```shell
44+
git fetch origin main
45+
scalafmt --mode diff-ref=origin/main
46+
scalafmt --list --mode diff-ref=origin/main
47+
```
48+
49+
- If native scalafmt is not installed, use the sbt scalafmt tasks or record that scalafmt could not be run.
50+
51+
```shell
52+
sbt scalafmtAll scalafmtSbt
53+
sbt scalafmtCheckAll scalafmtSbtCheck
54+
```
55+
56+
- Use JDK 17 for Java formatter tasks.
57+
58+
```shell
59+
export JAVA_HOME=$(/usr/libexec/java_home -v 17)
60+
export PATH="$JAVA_HOME/bin:$PATH"
61+
sbt javafmtAll
62+
```
63+
64+
- Run header generation before PR.
65+
66+
```shell
67+
sbt headerCreateAll
68+
```
69+
70+
- Do not rely on IDE formatting alone.
71+
- Do not commit unrelated formatting changes.
72+
73+
## Validation Rules
74+
75+
- Run the sample's tests.
76+
77+
```shell
78+
cd pekko-sample-name
79+
sbt test
80+
```
81+
82+
- Compile the sample to verify it remains valid.
83+
84+
```shell
85+
cd pekko-sample-name
86+
sbt compile
87+
```
88+
89+
- Run docs-gen to verify documentation generation.
90+
91+
```shell
92+
cd docs-gen
93+
sbt run
94+
```
95+
96+
- Always run `git diff --check`.
97+
- Do not assume local tools such as `sbt` or `scalafmt` are installed; if a required tool is missing, record the missing tool and skipped command in `Tests`.
98+
- Skipped or environment-failed commands must be recorded in `Tests`.
99+
100+
## Code Rules
101+
102+
- Samples must be self-contained and easy to understand.
103+
- Prefer clarity over cleverness in sample code.
104+
- Each sample should demonstrate a specific Pekko feature or pattern.
105+
- Keep Java and Scala variants functionally equivalent.
106+
- Use `scala.jdk.*` converters for Java/Scala interop in Scala samples.
107+
108+
## Commit and PR Format
109+
110+
- Use this body format for non-trivial commits.
111+
112+
```text
113+
Motivation:
114+
Problem or requirement.
115+
116+
Modification:
117+
Change summary.
118+
119+
Result:
120+
New outcome.
121+
122+
Tests:
123+
- command/result or Not run - docs only
124+
125+
References:
126+
Fixes #1234, Refs #1234, or None - <short context>
127+
```
128+
129+
- Use this PR body format.
130+
131+
```markdown
132+
### Motivation
133+
Problem or requirement.
134+
135+
### Modification
136+
Change summary.
137+
138+
### Result
139+
New outcome.
140+
141+
### Tests
142+
- command/result or Not run - docs only
143+
144+
### References
145+
Fixes #1234, Refs #1234, or None - <short context>
146+
```
147+
148+
- Never omit `Tests`.
149+
- Never omit `References`.
150+
- Use `Refs #...`, `Fixes #...`, or `None - <short context>`.
151+
- Do not add `Co-authored-by` or AI-assistant trailers to commits or PR descriptions.

CLAUDE.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Claude Rules for Apache Pekko Samples
2+
3+
Follow `AGENTS.md`.
4+
5+
Before opening or updating a PR, verify:
6+
7+
- Changed samples compile and run successfully.
8+
- Java and Scala variants of the same sample stay in sync.
9+
- `README.md` is updated for any sample behavior changes.
10+
- Native `scalafmt` or the sbt scalafmt tasks were run for changed Scala/SBT files, or the missing tool is recorded in `Tests`.
11+
- `sbt javafmtAll` was run with JDK 17 when relevant.
12+
- `sbt headerCreateAll` was run to add headers for new files. Never hand-write or invent license headers; let sbt manage them, and preserve existing copyright notices intact.
13+
- `docs-gen` still builds correctly if samples referenced by documentation were changed.
14+
- Commit messages follow the `AGENTS.md` format.
15+
- PR bodies follow the `AGENTS.md` format.
16+
- `Tests` and `References` are present.
17+
- No `Co-authored-by` or AI-assistant trailers are added to commits or PR descriptions.

0 commit comments

Comments
 (0)