Skip to content

Commit 9d29132

Browse files
committed
Updated to AGENTS.md
1 parent 935f140 commit 9d29132

22 files changed

Lines changed: 168 additions & 78 deletions

File tree

CLAUDE.md renamed to AGENTS.md

Lines changed: 62 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,50 @@
1-
# CLAUDE.md - MongoDB Java Driver
1+
# AGENTS.md - MongoDB Java Driver
22

33
Guidelines for AI agents working on the MongoDB Java Driver codebase.
44

55
## Project Overview
66

77
This is the official MongoDB JVM driver monorepo, providing Java, Kotlin, and Scala
88
drivers for MongoDB. The driver implements the
9-
[MongoDB Driver Specifications](https://github.com/mongodb/specifications)
10-
and follows semantic versioning.
9+
[MongoDB Driver Specifications](https://github.com/mongodb/specifications) and follows
10+
semantic versioning.
1111

1212
### Module Structure
1313

14-
| Module | Purpose |
15-
|----------------------------|-----------------------------------------------------------|
16-
| `bson` | BSON library (core serialization) |
17-
| `bson-kotlin` | Kotlin BSON extensions |
18-
| `bson-kotlinx` | Kotlin serialization BSON codec |
19-
| `bson-record-codec` | Java record codec support |
20-
| `bson-scala` | Scala BSON extensions |
21-
| `driver-core` | Core driver internals (connections, protocol, operations) |
22-
| `driver-sync` | Synchronous Java driver |
23-
| `driver-legacy` | Legacy MongoDB Java driver API |
24-
| `driver-reactive-streams` | Reactive Streams driver |
25-
| `driver-kotlin-coroutine` | Kotlin Coroutines driver |
26-
| `driver-kotlin-extensions` | Kotlin driver extensions |
27-
| `driver-kotlin-sync` | Kotlin synchronous driver |
28-
| `driver-scala` | Scala driver |
29-
| `mongodb-crypt` | Client-side field-level encryption |
30-
| `testing` | Shared test resources and MongoDB specifications |
14+
| Module | Purpose |
15+
| --- | --- |
16+
| `bson` | BSON library (core serialization) |
17+
| `bson-kotlin` | Kotlin BSON extensions |
18+
| `bson-kotlinx` | Kotlin serialization BSON codec |
19+
| `bson-record-codec` | Java record codec support |
20+
| `bson-scala` | Scala BSON extensions |
21+
| `driver-core` | Core driver internals (connections, protocol, operations) |
22+
| `driver-sync` | Synchronous Java driver |
23+
| `driver-legacy` | Legacy MongoDB Java driver API |
24+
| `driver-reactive-streams` | Reactive Streams driver |
25+
| `driver-kotlin-coroutine` | Kotlin Coroutines driver |
26+
| `driver-kotlin-extensions` | Kotlin driver extensions |
27+
| `driver-kotlin-sync` | Kotlin synchronous driver |
28+
| `driver-scala` | Scala driver |
29+
| `mongodb-crypt` | Client-side field-level encryption |
30+
| `testing` | Shared test resources and MongoDB specifications |
3131

3232
### Internal API Convention
3333

34-
All code in `com.mongodb.internal.*` and `org.bson.internal.*` is private API.
35-
It can change at any time without notice. Never expose internal types in
36-
public APIs, and never advise users to depend on them.
34+
All code in `com.mongodb.internal.*` and `org.bson.internal.*` is private API. It can
35+
change at any time without notice.
36+
Never expose internal types in public APIs, and never advise users to depend on them.
3737

3838
### API Stability Annotations
3939

40-
- `@Alpha` - Early development, may be removed. Not for production use.
41-
- `@Beta` - Subject to change or removal. Libraries should not depend on these.
42-
- `@Evolving` - May add abstract methods in future releases. Safe to use, but implementing/extending bears upgrade risk.
43-
- `@Sealed` - Must not be extended or implemented by consumers. Safe to use, but not to subclass.
40+
- `@Alpha` - Early development, may be removed.
41+
Not for production use.
42+
- `@Beta` - Subject to change or removal.
43+
Libraries should not depend on these.
44+
- `@Evolving` - May add abstract methods in future releases.
45+
Safe to use, but implementing/extending bears upgrade risk.
46+
- `@Sealed` - Must not be extended or implemented by consumers.
47+
Safe to use, but not to subclass.
4448
- `@Deprecated` - Supported until next major release but should be migrated away from.
4549

4650
## General
@@ -60,7 +64,7 @@ public APIs, and never advise users to depend on them.
6064
### Essential Build Commands
6165

6266
```bash
63-
# Full validation (static checks + unit tests + integration tests)
67+
# Full validation (spotlessApply + static checks + unit tests + integration tests)
6468
./gradlew check
6569

6670
# Integration tests (requires running MongoDB)
@@ -69,22 +73,16 @@ public APIs, and never advise users to depend on them.
6973
# Single module tests
7074
./gradlew :driver-core:test
7175

72-
# Format check only
73-
./gradlew spotlessCheck
74-
75-
# Auto-fix formatting
76-
./gradlew spotlessApply
77-
7876
# Test with alternative JDK
7977
./gradlew test -PjavaVersion=11
8078
```
8179

8280
## Code Style and Formatting
8381

8482
Formatting is enforced automatically because the Gradle `check` task depends on
85-
`./gradlew spotlessApply`, which formats sources. To run a check without modifying
86-
files, invoke `./gradlew spotlessCheck` manually. Do not manually reformat files
87-
outside the scope of your changes.
83+
`./gradlew spotlessApply`, which formats sources.
84+
To run a check without modifying files, invoke `./gradlew spotlessCheck` manually.
85+
Do not manually reformat files outside the scope of your changes.
8886

8987
### Style Rules
9088

@@ -96,7 +94,8 @@ outside the scope of your changes.
9694
- **Final parameters:** Required (FinalParameters checkstyle rule)
9795
- **Braces:** Required for all control structures (NeedBraces)
9896
- **Else placement:** On its own line (not cuddled)
99-
- **Copyright header:** Every Java / Kotlin / Scala file must contain `Copyright 2008-present MongoDB, Inc.`
97+
- **Copyright header:** Every Java / Kotlin / Scala file must contain
98+
`Copyright 2008-present MongoDB, Inc.`
10099

101100
### Prohibited Patterns
102101

@@ -114,28 +113,35 @@ outside the scope of your changes.
114113

115114
### Writing Tests
116115

117-
- **Every code change must include tests.** New code needs new tests; modified code needs updated tests. Do not reduce test coverage.
116+
- **Every code change must include tests.** New code needs new tests; modified code
117+
needs updated tests. Do not reduce test coverage.
118118
- Extend existing test patterns in the module you are modifying
119119
- Unit tests should not require a running MongoDB instance
120-
- Test methods should be descriptive:
121-
prefer `shouldReturnEmptyListWhenNoDocumentsMatch()` over `test1()`,
122-
use `@DisplayName` for a human readable name
120+
- Test methods should be descriptive: prefer
121+
`shouldReturnEmptyListWhenNoDocumentsMatch()` over `test1()`, use `@DisplayName` for a
122+
human readable name
123123
- Clean up test data in `@AfterEach` / `cleanup()` to prevent test pollution
124124

125125
### MongoDB Specifications and Specification Tests
126126

127-
The driver implements the [MongoDB Specifications](https://github.com/mongodb/specifications). Specification test data files live in
128-
`testing/resources/specifications/` — a git submodule for test resources. When modifying driver specification-related behavior: do
129-
not modify existing specification tests unless they test incorrect behavior. Create new tests instead.
127+
The driver implements the
128+
[MongoDB Specifications](https://github.com/mongodb/specifications).
129+
Specification test data files live in `testing/resources/specifications/` — a git
130+
submodule for test resources.
131+
When modifying driver specification-related behavior: do not modify existing
132+
specification tests unless they test incorrect behavior.
133+
Create new tests instead.
130134

131135
## Core Development Principles
132136

133137
### Essential Rules
134138

135-
- **Read before modifying.** Understand existing code and patterns before making changes.
139+
- **Read before modifying.** Understand existing code and patterns before making
140+
changes.
136141
- **Minimal changes only.** No drive-by refactoring.
137142
- **Preserve existing comments.** Only remove comments that are provably incorrect.
138-
- **No unrelated changes.** Do not fix formatting or refactor code outside the scope of the task.
143+
- **No unrelated changes.** Do not fix formatting or refactor code outside the scope of
144+
the task.
139145
- **No rewrites** without explicit permission.
140146

141147
### Search Before Implementing
@@ -148,20 +154,19 @@ Before writing new code, search the codebase for existing implementations:
148154

149155
### API Design
150156

151-
- **Deep modules:** Prefer simple interfaces with powerful implementations over shallow wrappers.
157+
- **Deep modules:** Prefer simple interfaces with powerful implementations over shallow
158+
wrappers.
152159
- **Information hiding:** Bury complexity behind simple interfaces.
153160
- **Pull complexity downward:** Make the implementer work harder so callers work less.
154-
- **General-purpose over special-case:** Fewer flexible methods over many specialized ones.
155-
- **Define errors out of existence:** Design APIs so errors cannot happen rather than detecting and handling them.
161+
- **General-purpose over special-case:** Fewer flexible methods over many specialized
162+
ones.
163+
- **Define errors out of existence:** Design APIs so errors cannot happen rather than
164+
detecting and handling them.
156165

157166
## Dependency Management
158167

159168
Dependencies are managed centrally via `gradle/libs.versions.toml`.
160-
161-
- **Never add dependencies without justification.** Dependencies are liabilities.
162-
- **Use dependencies for:** Security/crypto, complex protocols, battle-tested algorithms.
163-
- **Write it yourself for:** fewer than 100 LOC of straightforward code, project-specific logic, performance-critical paths.
164-
- Optional dependencies (Netty, Snappy, Zstd, AWS SDK, SLF4J) use `optionalImplementation` and must not be required at runtime.
169+
Optional dependencies (Netty, Snappy, Zstd, AWS SDK, SLF4J) use `optionalImplementation` and must not be required at runtime.
165170

166171
## Safety Rules - Do Not Modify Without Review
167172

@@ -177,7 +182,8 @@ Dependencies are managed centrally via `gradle/libs.versions.toml`.
177182

178183
### Evergreen (MongoDB Internal CI)
179184

180-
Primary CI runs on MongoDB's Evergreen system. Configuration is in `.evergreen/`.
185+
Primary CI runs on MongoDB’s Evergreen system.
186+
Configuration is in `.evergreen/`.
181187

182188
### Before Submitting
183189

bom/AGENTS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# AGENTS.md - bom
2+
3+
Bill of Materials (BOM) POM for the MongoDB Java Driver, simplifying dependency version management.
4+
5+
**Depends on:** All published driver modules (transitive version constraints only)
6+
7+
## Notes
8+
9+
- Java Platform plugin — no source code, only version constraints
10+
- Automatically includes all supported Scala version variants for `bson-scala` and `driver-scala`
11+
- Validates generated POM: all dependencies must be `org.mongodb`, no `<scope>` or `<optional>` elements
12+
- Do not add non-MongoDB dependencies to this module
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# CLAUDE.md - bson-kotlin
1+
# AGENTS.md - bson-kotlin
22

33
Kotlin extensions for the BSON library, providing idiomatic Kotlin codec support.
44

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# CLAUDE.md - bson-kotlinx
1+
# AGENTS.md - bson-kotlinx
22

33
Kotlinx serialization integration for BSON, providing a pluggable serialization format.
44

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# CLAUDE.md - bson-record-codec
1+
# AGENTS.md - bson-record-codec
22

33
Java record codec support for BSON serialization. **Requires Java 17+.**
44

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# CLAUDE.md - bson-scala
1+
# AGENTS.md - bson-scala
22

33
Scala extensions for the BSON library, providing Scala-idiomatic wrappers and macro-based codecs.
44

bson/CLAUDE.md renamed to bson/AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# CLAUDE.md - bson
1+
# AGENTS.md - bson
22

33
Core BSON (Binary JSON) library. This is the foundation module — all other modules depend on it.
44

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# CLAUDE.md - buildSrc
1+
# AGENTS.md - buildSrc
22

33
Gradle build infrastructure providing convention plugins and shared configuration for all modules.
44

@@ -49,12 +49,12 @@ Gradle build infrastructure providing convention plugins and shared configuratio
4949
- `check` depends on `spotlessCheck` in buildSrc itself
5050
- Java toolchain is set to Java 17
5151

52-
## Keeping CLAUDE.md Files in Sync
52+
## Keeping AGENTS.md Files in Sync
5353

54-
When modifying buildSrc, you **must** update the relevant CLAUDE.md files if your changes affect:
54+
When modifying buildSrc, you **must** update the relevant AGENTS.md files if your changes affect:
5555

56-
- **Formatting conventions** (e.g., changes to `spotless.gradle.kts`) — update the root `CLAUDE.md` "Code Style and Formatting" section and any module CLAUDE.md files that reference formatting rules
57-
- **Convention plugins added or removed** — update this file's plugin table and the root `CLAUDE.md` if the change affects build commands or developer workflow
58-
- **Testing conventions** (e.g., changes to `testing-*.gradle.kts`) — update the root `CLAUDE.md` "Testing" section and affected module CLAUDE.md files
56+
- **Formatting conventions** (e.g., changes to `spotless.gradle.kts`) — update the root `AGENTS.md` "Code Style and Formatting" section and any module AGENTS.md files that reference formatting rules
57+
- **Convention plugins added or removed** — update this file's plugin table and the root `AGENTS.md` if the change affects build commands or developer workflow
58+
- **Testing conventions** (e.g., changes to `testing-*.gradle.kts`) — update the root `AGENTS.md` "Testing" section and affected module AGENTS.md files
5959
- **Project plugins added or removed** — update this file's project plugin table
60-
- **Build commands or task names changed** — update the root `CLAUDE.md` "Essential Build Commands" and "Before Submitting" sections, and any module "Before Submitting" sections
60+
- **Build commands or task names changed** — update the root `AGENTS.md` "Essential Build Commands" and "Before Submitting" sections, and any module "Before Submitting" sections

driver-benchmarks/AGENTS.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# AGENTS.md - driver-benchmarks
2+
3+
Performance benchmarks for the MongoDB Java Driver using JMH and a custom benchmark framework.
4+
5+
**Depends on:** `driver-sync`, `mongodb-crypt`
6+
7+
## Key Packages
8+
9+
- `com.mongodb.benchmark.benchmarks` — Benchmark suite and individual benchmarks (BSON, single/multi-doc, bulk operations)
10+
- `com.mongodb.benchmark.benchmarks.bulk` — Bulk write benchmarks
11+
- `com.mongodb.benchmark.benchmarks.netty` — Netty transport benchmarks
12+
- `com.mongodb.benchmark.framework` — Custom benchmark harness
13+
- `com.mongodb.benchmark.jmh` — JMH microbenchmarks
14+
15+
## Notes
16+
17+
- Not published — internal testing only
18+
- Non-standard source layout: `src/main` (no `java` subdirectory)
19+
- Run benchmarks: `./gradlew :driver-benchmarks:run` or `./gradlew :driver-benchmarks:jmh`
20+
- Requires `-Dorg.mongodb.benchmarks.data` and `-Dorg.mongodb.benchmarks.output` system properties
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# CLAUDE.md - driver-core
1+
# AGENTS.md - driver-core
22

33
Core driver internals shared by all driver variants (sync, reactive, Kotlin, Scala). Largest and most complex module.
44

0 commit comments

Comments
 (0)