agentleFS
MongoDBKnown publishermongodb/mongo-go-driver/AGENTS.md

mongo-go-driver

AGENTS.md8.5k starsChanged 7 months agoApache-2.0View on GitHub

Official MongoDB Go Driver (go.mongodb.org/mongo-driver/v2). Correctness, backward compatibility, and conformance to MongoDB Driver Specifications are top priorities. Uses Task, not make. Tests require a running mongod on localhost:27017 (or MONGODB_URI). The full test suite is serial (-p 1) — integration tests share server state. Do not parallelize. Evergreen's project configuration lives in .evergreen/config.yml, where every task, variant, and expansion is declared; supporting CI scripts live alongside it. Validate any change with evergreen validate -p mongo-go-driver -f .evergreen/config.yml (authenticate with evergreen…

Trending

Quiet since July.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 7 mentionsJul 2026: 11 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the mongodb/mongo-go-driver repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about mongodb/mongo-go-driver

The biggest 5 of 29 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 29

Talked about on GitHub and Hacker News (29 times).

On GitHub · 28

23 more on GitHub

On Hacker News · 1

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository2 other files it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Add a value at the top of the version axis (id/display_name/variables: VERSION:).

    line 43
  2. Distinctive:

    CSOT timeouts: Use context deadlines; do not introduce per-call wall-clock timers that race with the user's context.

    line 64
  3. Very specific:

    Command monitoring redacts credentials: When adding commands that handle credentials (authenticate, saslStart, etc.), add them to the …

    line 65
  4. Very specific:

    Context: Every blocking public method takes context.Context as its first argument.

    line 72
  5. Very specific:

    New options: Follow the setter pattern: func (o *XxxOptionsBuilder) SetFoo(v T) *XxxOptionsBuilder.

    line 75
  6. Very specific:

    Use internal/assert (wraps testify) for assertions.

    line 79
  7. Very specific:

    Run task (default target) before every PR.

    line 89

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md

This file provides guidance to AI agents when working with code in this repository.

Project

Official MongoDB Go Driver (go.mongodb.org/mongo-driver/v2). Correctness, backward compatibility, and conformance to MongoDB Driver Specifications are top priorities.

  • Module: go.mongodb.org/mongo-driver/v2
  • Issue tracker: JIRA GODRIVER project — GitHub Issues is not used for bugs/features
  • Active major version: v2 on master. v1 lives on release/1.x branches.

Build, test, and lint

Uses Task, not make.

task                 # default: build + check-license + check-fmt + check-modules + lint + test-short
task fmt             # gofumpt -w . — use this, not plain gofmt
task build           # includes compilecheck (all supported Go versions, needs Docker)
task lint            # golangci-lint across linux/{386,arm,arm64,amd64,ppc64le,s390x}
task test-short      # race detector, ~60s timeout — fast feedback
task test            # full suite, serial (-p 1), 1800s timeout, requires mongod
task api-report      # required when public API changes — include output in PR description

Tests require a running mongod on localhost:27017 (or MONGODB_URI). The full test suite is serial (-p 1) — integration tests share server state. Do not parallelize.

Go version requirements

  • Go 1.25: minimum to compile/use the driver. The Go Driver supports the last two Go minor versions. Public packages (mongo/, bson/, event/, tag/) must build on 1.25. The compilecheck task enforces this at build time, compiling against every version in goVersions (internal/test/compilecheck/compile_check_test.go).
  • Go 1.26+: required to run the test suite and develop the driver.

CI (Evergreen)

Evergreen's project configuration lives in .evergreen/config.yml, where every task, variant, and expansion is declared; supporting CI scripts live alongside it. Validate any change with evergreen validate -p mongo-go-driver -f .evergreen/config.yml (authenticate with evergreen login, not an API key). Warnings about unused tasks and merge-queue aliases are pre-existing.

Two submodules, both pinned by commit. .evergreen/drivers-evergreen-tools (DET) provides every server-provisioning script; testdata/specifications provides spec-test fixtures. CI checks out the pinned commits (git submodule update --init in the setup-system function) — it does not track DET master. So a fix that has landed upstream in DET is not live here until the pin moves. Run task init-submodule locally before inspecting DET; it is often left uninitialized.

Adding a new server version:

  1. Add a value at the top of the version axis (id/display_name/variables: VERSION:).
  2. Append it to each relevant matrix_spec version list. Matrices tagged pullrequest run on every PR; untagged ones are waterfall-only. Convention is that the newest version gets the PR-tagged matrix and the previous newest falls back to the waterfall matrix.
  3. Variants not expanded across the version axis need editing by hand — notably testoidc_task_group, which hardcodes MONGODB_VERSION. Task groups cannot take a matrix axis, and a task may appear only once per buildvariant.

When a version won't download, the fix usually belongs in DET, not here. VERSION flows to mongodl unchanged (bootstrap-mongo-orchestration → run-orchestration.sh → drivers_orchestration.py), and mongodl resolves a bare X.Y to the newest X.Y.* in full.json, release candidates included. Pre-GA versions are often absent from full.json, and DET carries the workaround (e.g. UNPUBLISHED_VERSIONS maps such a version to its branch nightly). Prefer bumping the DET pin over adding driver-side overrides such as MONGODB_DOWNLOAD_SOURCE:

cd .evergreen/drivers-evergreen-tools
git fetch origin
git checkout <upstream-commit>      # or origin/master
cd -
git add .evergreen/drivers-evergreen-tools

Dependabot bumps this pin routinely, so prefer waiting for its PR when the fix is not urgent. Bumping by hand pulls in every intervening upstream commit — review git log <old>..<new> for unrelated CI changes and validate in a patch build (evergreen patch -p mongo-go-driver -u), not just evergreen validate.

Gotchas

  1. x/ packages are importable but not semver-covered. Users do import x/mongo/driver etc. Flag breaking changes explicitly in PR descriptions even though semver doesn't require it.
  2. Atomic alignment on 32-bit. int64/uint64 fields accessed via sync/atomic must be at struct start or use atomic.Int64. The lint pass on GOARCH=386 catches this — don't skip cross-arch lint.
  3. GridFS lives in mongo/. v2 merged gridfs.Bucket into mongo.GridFSBucket. Don't resurrect the old gridfs import path.
  4. CSOT timeouts. Use context deadlines; do not introduce per-call wall-clock timers that race with the user's context.
  5. Command monitoring redacts credentials. When adding commands that handle credentials (authenticate, saslStart, etc.), add them to the redaction list.
  6. libmongocrypt required for CSFLE/QE tests. Install with task install-libmongocrypt. CSFLE code requires the cse build tag.

Code conventions

  • Formatter: gofumpt (stricter superset of gofmt). Always use task fmt, never plain gofmt.
  • Errors: fmt.Errorf("…: %w", err) for wrapping. Use errors.Is/errors.As for comparisons — never strings.Contains on error messages. Sentinel errors live in the mongo package (mongo.ErrNoDocuments, etc.).
  • Context: Every blocking public method takes context.Context as its first argument. Use mongo.SessionFromContext(ctx) (v2 pattern) — not the old mongo.SessionContext.
  • BSON: bson.D for ordered documents and commands. bson.M only when order genuinely doesn't matter. bsoncore.Document in hot paths (zero-copy, byte-slice-backed).
  • Exported names: Full words, not abbreviations (ClientBulkWriteResult, not CBWResult). Doc comments required on all exported identifiers using the "name is subject" convention.
  • New options: Follow the setter pattern: func (o *XxxOptionsBuilder) SetFoo(v T) *XxxOptionsBuilder.

Tests

  • Use internal/assert (wraps testify) for assertions. Prefer assert.ErrorIs over assert.ErrorContains.
  • Integration tests: use internal/integration/mtest for topology-aware setup, fail-point injection, and event capture.
  • Spec tests: JSON/YAML fixtures under testdata/ (git submodule — run task init-submodule after cloning if missing).
  • Prose tests: number them to match the spec (e.g., "3. bulkWrite batch splits…") for cross-referencing.
  • Unit tests live next to the code (foo.go ↔ foo_test.go). Integration tests live in internal/integration/.

PR and commit conventions

  • JIRA prefix required: GODRIVER-1234 Short description for all commit messages and PR titles.
  • Features → master. Bug fixes → latest stable release branch (e.g., release/2.5). The "Merge up" GitHub Action propagates fixes to newer branches automatically.
  • Run task (default target) before every PR.
  • Changed public API (mongo/, bson/, event/, tag/)? Run task api-report and include the output in the PR description.
  • User-visible breaking change? Update docs/migration-2.0.md.
  • Spec compliance changes? Quote the relevant spec requirement in the PR description.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.