Skip to content

Commit e5fb27c

Browse files
jamisCopilotcomandeo-mongo
authored
RUBY-3795 Add AGENTS.md (mongodb#3012)
* RUBY-3795 Add AGENTS.md * Update AGENTS.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add more instructions --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Dmitry Rybakov <dmitry.rybakov@mongodb.com>
1 parent 02014e1 commit e5fb27c

3 files changed

Lines changed: 105 additions & 0 deletions

File tree

.github/code-review.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Code Reviews
2+
3+
When reviewing code, focus on:
4+
5+
## Security Critical Issues
6+
- Check for hardcoded secrets, API keys, or credentials
7+
- Check for instances of potential method call injection, dynamic code execution, symbol injection or other code injection vulnerabilities.
8+
9+
## Performance Red Flags
10+
- Spot inefficient loops and algorithmic issues.
11+
- Check for memory leaks and resource cleanup.
12+
13+
## Code Quality Essentials
14+
- Methods should be focused and appropriately sized. If a method is doing too much, suggest refactorings to split it up.
15+
- Use clear, descriptive naming conventions.
16+
- Avoid encapsulation violations and ensure proper separation of concerns.
17+
- All public classes, modules, and methods should have clear documentation in YARD format.
18+
- If `method_missing` is implemented, ensure that `respond_to_missing?` is also implemented.
19+
- Rubocop is used by this project to enforce code style. Always refer to the project's .rubocop.yml file for guidance on the project's style preferences.
20+
21+
## Driver-specific Concerns
22+
- Look for code that might cause issues in a multi-threaded (or multi-fiber) environment.
23+
24+
## Review Style
25+
- Be specific and actionable in feedback
26+
- Explain the "why" behind recommendations
27+
- Acknowledge good patterns when you see them
28+
- Ask clarifying questions when code intent is unclear
29+
- When possible, suggest that the pull request be labeled as a `bug`, a `feature`, or a `bcbreak` (a "backwards-compatibility break").
30+
- PR's with no user-visible effect do not need to be labeled.
31+
- Do not review or suggest changes to YAML files under the `spec/` directory; these are test fixtures shared between all drivers and are not owned by this repository.
32+
- Flag any new Ruby specs that appear to duplicate behavior already covered by YAML spec tests in `spec/spec_tests/data/`.
33+
34+
Always prioritize security vulnerabilities and performance issues that could impact users.
35+
36+
Always suggest changes to improve readability and testability.
37+
38+
When reviewing code, be encouraging.

AGENTS.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Project Description
2+
3+
This is the Ruby driver for the MongoDB database. It provides a Ruby interface for connecting to MongoDB, performing CRUD operations, and managing database connections. The API is standardized across all MongoDB drivers, via the specifications defined in the MongoDB Specifications repository: https://github.com/mongodb/specifications. The driver targets Ruby 2.7+. Do not use syntax or stdlib features unavailable in Ruby 2.7.
4+
5+
# Project Structure
6+
7+
The project is organized into the following directories:
8+
9+
- `lib/`: the main codebase
10+
- `spec/`: RSpec tests for the project, and shared test data
11+
- `bin/`: executable scripts
12+
- `examples/`: example usage of the library
13+
- `gemfiles/`: Gemfile files for different usage scenarios (primarily testing, aside from `standard.rb` which is used for development and production)
14+
- `profile/`: profiling scripts and results
15+
16+
17+
# Development Workflow
18+
19+
## Running tests
20+
21+
Tests require a running MongoDB instance. Set the URI via the `MONGODB_URI` environment variable:
22+
23+
```
24+
MONGODB_URI="mongodb://localhost:27017,localhost:27018,localhost:27019/" bundle exec rspec spec/path/to/spec.rb
25+
```
26+
27+
A replica set is typically available locally at `localhost:27017,27018,27019`.
28+
29+
## Linting
30+
31+
Run RuboCop after making changes, and always before committing:
32+
33+
```
34+
bundle exec rubocop lib/mongo/changed_file.rb spec/mongo/changed_file_spec.rb
35+
```
36+
37+
Pass the specific files you modified.
38+
39+
RuboCop is configured with performance, rake, and rspec plugins (`.rubocop.yml`).
40+
41+
## Commit convention
42+
43+
Prefix commit messages with the JIRA ticket: `RUBY-#### Short description`. The ticket number is typically in the branch name (e.g., branch `3795-foo` means `RUBY-3795`).
44+
45+
## Prose style
46+
47+
When writing prose — commit messages, code comments, documentation — be concise, write as a human would, avoid overly complicated sentences, and use no emojis.
48+
49+
## Definition of done
50+
51+
Always run the relevant spec file(s) against the local cluster before considering a task complete. Running tests is not optional. "Relevant" means: the spec file for each class you changed, plus any integration specs in `spec/integration/` that exercise the affected feature. If MongoDB is not reachable, report this to the user rather than trying to work around it.
52+
53+
## Thread and fiber safety
54+
55+
This driver runs in multi-threaded and multi-fiber environments. When writing or modifying code that touches connection pools, server monitors, or any shared state, always consider concurrent access. Use existing synchronization primitives in the codebase rather than introducing new ones.
56+
57+
## Spec fixtures
58+
59+
Unified test format YAML fixtures live in `spec/spec_tests/data/<suite_name>/`. To add new fixtures, copy YAML files from `specifications/source/<spec-name>/tests/unified/` into that directory. The runner loads all `*.yml` files automatically — no runner changes needed.
60+
61+
Do not write Ruby specs that duplicate behavior already covered by YAML spec tests. New Ruby specs should cover behavior that cannot be expressed in the unified test format.
62+
63+
64+
# Code Reviews
65+
66+
See [.github/code-review.md](.github/code-review.md) for code review guidelines.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@AGENTS.md

0 commit comments

Comments
 (0)