Skip to content

Commit 022bff8

Browse files
committed
Updated to move towards the open standard for AI agent instructions
1 parent 9d29132 commit 022bff8

51 files changed

Lines changed: 506 additions & 289 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/skills/api-design/SKILL.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
name: api-design
3+
description: API stability annotations, design principles, and patterns for the MongoDB Java Driver. Use when adding or modifying public API surface — new classes, methods, interfaces, or changing method signatures.
4+
---
5+
6+
# API Design
7+
8+
## API Stability Annotations
9+
10+
- `@Alpha` — Early development, may be removed. Not for production use.
11+
- `@Beta` — Subject to change or removal. Libraries should not depend on these.
12+
- `@Evolving` — May add abstract methods in future releases. Safe to use, but implementing/extending bears upgrade risk.
13+
- `@Sealed` — Must not be extended or implemented by consumers. Safe to use, but not to subclass.
14+
- `@Deprecated` — Supported until next major release but should be migrated away from.
15+
16+
## Design Principles
17+
18+
- **Deep modules:** Prefer simple interfaces with powerful implementations over shallow wrappers.
19+
- **Information hiding:** Bury complexity behind simple interfaces.
20+
- **Pull complexity downward:** Make the implementer work harder so callers work less.
21+
- **General-purpose over special-case:** Fewer flexible methods over many specialized ones.
22+
- **Define errors out of existence:** Design APIs so errors cannot happen rather than detecting and handling them.
23+
24+
## Search Before Implementing
25+
26+
Before writing new code, search the codebase for existing implementations:
27+
28+
- Check if a utility method already exists in `com.mongodb.internal.*`
29+
- Check if a similar pattern is established elsewhere in the module
30+
- Reuse existing well-tested infrastructure over creating duplicates
31+
32+
## Key Patterns
33+
34+
- Static factory methods: `Filters.eq()`, `Updates.set()`, `Aggregates.match()`
35+
- Fluent builders: `MongoClientSettings.builder()` is the primary entry point
36+
- Abstract core with pluggable transports
37+
38+
## Public API Rules
39+
40+
- Breaking changes require a major version bump - ALWAYS warn if breaking binary compatibility
41+
- All `com.mongodb.internal.*` / `org.bson.internal.*` is private API — never expose in public APIs
42+
- Every public package must have a `package-info.java`

.agents/skills/evergreen/SKILL.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: evergreen
3+
description: Evergreen CI infrastructure, configuration validation. Use when modifying .evergreen/ config, preparing to submit changes or understanding the Evergreen test matrix.
4+
---
5+
6+
# Evergreen
7+
8+
## Evergreen (MongoDB Internal CI)
9+
10+
Primary CI runs on MongoDB's Evergreen system. Configuration lives in `.evergreen/`.
11+
12+
- Do not modify `.evergreen/` configuration without review
13+
- Evergreen runs the full test matrix across MongoDB versions, OS platforms, and JDK versions
14+
15+
## Validating Evergreen Configuration
16+
17+
After modifying `.evergreen/` files, validate the config locally:
18+
19+
```bash
20+
evergreen validate $PROJECT_PATH/.evergreen/.evg.yml
21+
```
22+
23+
Always run this before submitting changes to `.evergreen/` to catch syntax errors and invalid task definitions.
24+
25+
## Testing with a Patch Build
26+
27+
To test your changes on Evergreen before merging, create a patch build:
28+
29+
```bash
30+
evergreen patch -u
31+
```
32+
33+
This uploads your uncommitted and committed local changes as a patch build on Evergreen, allowing you to run the full CI test matrix against your branch.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
name: project-guide
3+
description: Project structure, dependency graph, and guide for finding the right project to work in. Use when starting a task and unsure which project owns the relevant code, or when you need to understand cross-project dependencies.
4+
---
5+
6+
# Project Guide
7+
8+
## Project Structure
9+
10+
| Project | Purpose |
11+
| --- | --- |
12+
| `bson` | BSON library (core serialization) |
13+
| `bson-kotlin` | Kotlin BSON extensions |
14+
| `bson-kotlinx` | Kotlin serialization BSON codec |
15+
| `bson-record-codec` | Java record codec support |
16+
| `bson-scala` | Scala BSON extensions |
17+
| `driver-core` | Core driver internals (connections, protocol, operations) |
18+
| `driver-sync` | Synchronous Java driver |
19+
| `driver-legacy` | Legacy MongoDB Java driver API |
20+
| `driver-reactive-streams` | Reactive Streams driver |
21+
| `driver-kotlin-coroutine` | Kotlin Coroutines driver |
22+
| `driver-kotlin-extensions` | Kotlin driver extensions |
23+
| `driver-kotlin-sync` | Kotlin synchronous driver |
24+
| `driver-scala` | Scala driver |
25+
| `mongodb-crypt` | Client-side field-level encryption |
26+
| `bom` | Bill of Materials for dependency management |
27+
| `testing` | Shared test resources and MongoDB specifications |
28+
| `buildSrc` | Gradle convention plugins and build infrastructure |
29+
| `driver-benchmarks` | JMH and custom performance benchmarks (not published) |
30+
| `driver-lambda` | AWS Lambda test application (not published) |
31+
| `graalvm-native-image-app` | GraalVM Native Image compatibility testing (not published) |
32+
33+
## Dependency Graph (simplified)
34+
35+
```
36+
bson
37+
├── bson-kotlin
38+
├── bson-kotlinx
39+
├── bson-record-codec
40+
├── bson-scala
41+
└── driver-core
42+
├── driver-sync
43+
│ ├── driver-legacy
44+
│ ├── driver-kotlin-sync
45+
│ └── driver-lambda
46+
├── driver-reactive-streams
47+
│ ├── driver-kotlin-coroutine
48+
│ └── driver-scala
49+
└── driver-kotlin-extensions
50+
```
51+
52+
## Finding the Right Module
53+
54+
- **BSON serialization/codecs:** `bson` (or `bson-kotlin`/`bson-kotlinx`/`bson-scala` for language-specific)
55+
- **Query builders, filters, aggregates:** `driver-core` (`com.mongodb.client.model`)
56+
- **Sync Java API:** `driver-sync`
57+
- **Reactive API:** `driver-reactive-streams`
58+
- **Kotlin coroutines:** `driver-kotlin-coroutine`
59+
- **Kotlin DSL builders:** `driver-kotlin-extensions`
60+
- **Scala driver:** `driver-scala`
61+
- **Connection, protocol, auth internals:** `driver-core` (`com.mongodb.internal.*`)
62+
- **Build plugins, formatting, test infra:** `buildSrc`
63+
64+
Each module has its own `AGENTS.md` with module-specific packages, patterns, and notes.

.agents/skills/spec-tests/SKILL.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
name: spec-tests
3+
description: How to work with MongoDB specification tests — structure, rules, and adding new spec test support. Use when implementing or modifying behavior defined by the MongoDB Driver Specifications, or when working with the test data in testing/resources/specifications/.
4+
---
5+
6+
# MongoDB Specification Tests
7+
8+
## Overview
9+
10+
The driver implements the
11+
[MongoDB Driver Specifications](https://github.com/mongodb/specifications). Specification
12+
test data files live in `testing/resources/specifications/` — a git submodule.
13+
14+
## Rules
15+
16+
- **Do not modify existing specification tests** unless they test incorrect behavior
17+
- **Do not modify spec test data** — it is managed upstream
18+
- Create new tests instead of modifying existing ones
19+
- Update the submodule via `git submodule update`
20+
21+
## Structure
22+
23+
Spec test data is organized by specification area:
24+
25+
- CRUD, SDAM, auth, CSFLE, retryable operations, and more
26+
- Each spec area has JSON/YAML test data files defining inputs and expected outputs
27+
- Driver test runners parse these files and execute against the driver
28+
29+
## Test Data Location
30+
31+
```
32+
testing/
33+
resources/
34+
specifications/ # Git submodule — do not edit directly
35+
logback-test.xml # Shared logback configuration for tests
36+
```
37+
38+
## Adding Spec Test Support
39+
40+
1. Check `testing/resources/specifications/` for the relevant spec test data
41+
2. Find existing test runners in the module (look for `*SpecificationTest*` or similar)
42+
3. Extend existing patterns — each module handles spec tests slightly differently
43+
4. Ensure tests run with `./gradlew check` or the module's test task
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
name: style-reference
3+
description: Detailed code style rules for Java, Kotlin, Scala, and Groovy in the MongoDB Java Driver. Use when you need specific formatting rules beyond the basics in root AGENTS.md — e.g., line length, import ordering, brace style, or language-specific formatter configuration. Spotless auto-enforces most rules.
4+
---
5+
6+
# Style Reference
7+
8+
## Java Style Rules
9+
10+
- **Max line length:** 140 characters
11+
- **Indentation:** 4 spaces (no tabs)
12+
- **Line endings:** LF (Unix)
13+
- **Charset:** UTF-8
14+
- **Star imports:** Prohibited (AvoidStarImport)
15+
- **Final parameters:** Required (FinalParameters checkstyle rule)
16+
- **Braces:** Required for all control structures (NeedBraces)
17+
- **Else placement:** On its own line (not cuddled)
18+
- **Copyright header:** Every Java / Kotlin / Scala file must contain `Copyright 2008-present MongoDB, Inc.`
19+
- **Formatter:** Palantir Java Format
20+
21+
## Kotlin Style Rules
22+
23+
- **Formatter:** ktfmt dropbox style, max width 120
24+
- **Static analysis:** detekt
25+
26+
## Scala Style Rules
27+
28+
- **Formatter:** scalafmt
29+
- **Supported versions:** 2.11, 2.12, 2.13, 3 (default: 2.13)
30+
31+
## Groovy Style Rules
32+
33+
- **Static analysis:** CodeNarc
34+
35+
## Prohibited Patterns
36+
37+
- `System.out.println` / `System.err.println` — Use SLF4J logging
38+
- `e.printStackTrace()` — Use proper logging/error handling
39+
40+
## Formatting Commands
41+
42+
```bash
43+
./gradlew spotlessApply # Auto-fix all formatting
44+
./gradlew spotlessCheck # Check without modifying
45+
```
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
name: testing-guide
3+
description: Testing frameworks, conventions, and commands for the MongoDB Java Driver. Use when writing or running tests — covers framework selection per module, test naming conventions, integration test setup, and how to run specific test subsets.
4+
---
5+
6+
# Testing Guide
7+
8+
## Frameworks
9+
10+
| Framework | Usage | Notes |
11+
| --- | --- | --- |
12+
| JUnit 5 (Jupiter) | Primary unit test framework | All new tests |
13+
| Spock (Groovy) | Legacy tests | Do not add new Spock tests |
14+
| Mockito | Mocking | Use `mockito-junit-jupiter` integration |
15+
| ScalaTest | Scala module testing | FlatSpec + ShouldMatchers |
16+
| Project Reactor | Reactive test utilities | `driver-reactive-streams` tests |
17+
18+
## Writing Tests
19+
20+
- Every code change must include tests
21+
- Extend existing test patterns in the module you are modifying
22+
- Unit tests must not require a running MongoDB instance
23+
- Descriptive method names: `shouldReturnEmptyListWhenNoDocumentsMatch()` not `test1()`
24+
- Use `@DisplayName` for human-readable names
25+
- Clean up test data in `@AfterEach` / `cleanup()` to prevent pollution
26+
27+
## Running Tests
28+
29+
```bash
30+
# All tests (unit + integration)
31+
./gradlew check
32+
33+
# Single module
34+
./gradlew :driver-core:test
35+
36+
# Integration tests (requires MongoDB)
37+
./gradlew integrationTest -Dorg.mongodb.test.uri="mongodb://localhost:27017"
38+
39+
# Specific test class
40+
./gradlew :driver-core:test --tests "com.mongodb.internal.operation.FindOperationTest"
41+
42+
# Alternative JDK
43+
./gradlew test -PjavaVersion=11
44+
45+
# Scala tests (all versions)
46+
./gradlew scalaCheck
47+
```
48+
49+
## Module-Specific Notes
50+
51+
- **driver-core:** Largest test suite — JUnit 5 + Spock + Mockito
52+
- **driver-sync:** JUnit 5 + Spock (heavy Spock usage, but don't add new)
53+
- **driver-reactive-streams:** JUnit 5 + Spock + Project Reactor
54+
- **bson-scala / driver-scala:** ScalaTest, test per Scala version
55+
- **Kotlin modules:** JUnit 5 + mockito-kotlin
56+
57+
## Integration Tests
58+
59+
- Require a running MongoDB instance
60+
- Set connection URI: `-Dorg.mongodb.test.uri="mongodb://localhost:27017"`
61+
- Integration test source set configured via `conventions/testing-integration.gradle.kts`

.claude/skills

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.agents/skills

0 commit comments

Comments
 (0)