js-bson
AGENTS.md1.2k starsChanged 4 months agoApache-2.0View on GitHub
Instructions for AI coding agents working in this repository. This file is the source of truth; tool-specific files (e.g. CLAUDE.md) should only import it. bson is the BSON codec library for JavaScript (Node.js and browser), implementing the BSON specification. It provides BSON type classes, serialization/deserialization to and from BSON bytes, and Extended JSON (EJSON) support. It is the codec used by the node-mongodb-native driver, and also a standalone library external users depend on. All benchmark runs first measure a CPU…
Trending
Quiet since October.about the whole repository
Who's talking about mongodb/js-bson
- DataDog/dd-trace-js“chore(deps): bump bson from 7.3.2 to 7.3.3 in /packages/dd-trace/test/plugins/versions in the databases …”GitHub · Sep 21, 2026 · 2 reactions
- DataDog/dd-trace-js“chore(deps): bump the databases group across 1 directory with 3 updates”GitHub · Aug 17, 2026 · 2 reactions
- graphql/graphql-js“Call 'toJSON' if present for ID and String serialize”GitHub · Sep 11, 2018 · 2 reactions
- typestack/class-transformer“databaseToClass”GitHub · Mar 22, 2018 · 2 reactions
- RocketChat/Rocket.Chat“chore(deps): bump bson from 6.10.4 to 7.3.3”GitHub · Sep 23, 2026 · 1 reactions
The biggest 5 of 23 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 23
Talked about on GitHub (23 times).
On GitHub · 23
- Sep 21, 2026chore(deps): bump bson from 7.3.2 to 7.3.3 in /packages/dd-trace/test/plugins/versions in the databases group across 1 directory — DataDog/dd-trace-js2 reactions · 3 comments
- Aug 17, 2026chore(deps): bump the databases group across 1 directory with 3 updates — DataDog/dd-trace-js2 reactions · 3 comments
- Sep 11, 2018Call 'toJSON' if present for ID and String serialize — graphql/graphql-js2 reactions · 9 comments
- Mar 22, 2018databaseToClass — typestack/class-transformer2 reactions · 8 comments
- Sep 23, 2026chore(deps): bump bson from 6.10.4 to 7.3.3 — RocketChat/Rocket.Chat1 reaction · 4 comments
18 more on GitHub
- Jun 29, 2026chore(deps): bump the databases group across 1 directory with 17 updates — DataDog/dd-trace-js1 reaction · 4 comments
- Dec 8, 2025deps(deps): bump the security-updates group with 31 updates — koushik369mondal/WanderLust1 reaction · 4 comments
- Nov 24, 2025deps(deps): bump the security-updates group with 26 updates — koushik369mondal/WanderLust1 reaction · 5 comments
- Nov 17, 2025deps(deps): bump the security-updates group with 21 updates — koushik369mondal/WanderLust1 reaction · 5 comments
- Nov 10, 2025deps(deps): bump the security-updates group with 20 updates — koushik369mondal/WanderLust1 reaction · 5 comments
- Sep 25, 2023chore(deps): bump mongodb from 4.17.0 to 6.1.0 — openwhyd/openwhyd1 reaction · 6 comments
- Apr 8, 2021Timestamp.ONE is not defined — meteor/meteor1 reaction · 3 comments
- Oct 1, 2026chore(deps): bump bson from 7.3.1 to 7.3.3 — BiancoRoyal/node-red-contrib-modbus0 reactions
- Oct 1, 2026ci(deps): bump the prod-dependencies group with 2 updates — mongodb/node-mongodb-native0 reactions
- Sep 28, 2026chore(deps-dev): bump bson from 7.3.2 to 7.3.3 — aeria-org/aeria0 reactions
- Sep 28, 2026deps: bump bson from 7.2.0 to 7.3.3 — DiogoRibeiro7/nosql-databases-labs0 reactions · 2 comments
- Sep 1, 2026chore(deps): bump bson from 6.10.4 to 7.3.2 in /backend — zylelabs/zydock0 reactions
- Sep 1, 2026chore: Bump bson from 6.10.4 to 7.3.2 — mongodb-js/mongodb-client-encryption0 reactions
- Aug 31, 2026Bump bson from 0.5.7 to 7.3.2 in the npm_and_yarn group across 1 directory — bitpay/wallet-cli-tools0 reactions
- Aug 17, 2026chore(deps): bump bson from 7.3.1 to 7.3.2 — emmansun/lightcrypto-link-node0 reactions
- Jul 28, 2026chore(deps): bump bson from 6.10.4 to 7.3.1 — mkaragoz01/TechBazaar0 reactions
- Jul 22, 2026chore(deps): bump bson from 6.9.0 to 7.3.1 — Sevio-HQ/node-red-contrib-modbus0 reactions
- May 9, 2021Bump bson from 1.1.0 to 1.1.6 in /api — musamaUet/mern-stack-crud-app0 reactions
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,736 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 repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
We split this AGENTS.md into the rules it gives an agent
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 20
Run a single test file: npx mocha test/node/<file>.test.ts.
- Very specific: line 25
All benchmark runs first measure a CPU baseline (check:baseline-bench) so results are normalized across machines.
- Very specific: line 33
Use these to validate perf-tagged changes — run before and after on the same machine and compare.
- Very specific: line 58
Before making key changes to anything within src/parser/*, consider performance implications and run benchmark test passes to ensure no …
≈ “Common” is an estimate: at least 1 in 5 of the 16,597 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.
Files
AGENTS.md
Instructions for AI coding agents working in this repository. This file is the source of truth; tool-specific files (e.g. CLAUDE.md) should only import it.
Project Overview
bson is the BSON codec library for JavaScript (Node.js and browser), implementing the BSON specification. It provides BSON type classes, serialization/deserialization to and from BSON bytes, and Extended JSON (EJSON) support. It is the codec used by the node-mongodb-native driver, and also a standalone library external users depend on.
Commands
npm run build # tsc + api-extractor (bson.d.ts) + rollup bundles into lib/
npm run check:lint # eslint + api-extractor + tsd type tests
npm run format # attempts to automatically fix lint errors
npm run check:node # mocha test/node (Node target). Run `build` first
npm run check:web # same suite with WEB=true (browser code paths)
npm test # builds (pretest), then check:node + check:web- Run a single test file:
npx mocha test/node/<file>.test.ts; filter cases with--grep. - Tests use mocha + chai + sinon. Type-level tests live in
test/types(tsd).
Benchmarks
All benchmark runs first measure a CPU baseline (check:baseline-bench) so results are normalized across machines. Sources live in test/bench/.
npm run check:granular-bench # per-BSON-type micro-benchmarks (test/bench/granular)
npm run check:spec-bench # cross-driver spec benchmark suite (test/bench/spec)
npm run check:custom-bench # ad-hoc/scenario benchmarks (test/bench/custom)Use these to validate perf-tagged changes — run before and after on the same machine and compare.
Structure
- src/index.ts — the public API surface. api-extractor rolls it into
bson.d.ts. src/*.ts— BSON type classes (ObjectId,Long,Decimal128,Binary, …), all extendingBSONValue;extended_json.tsfor EJSON.src/parser/— the eager codec: recursive serializer/deserializer that converts whole JS objects to/from BSON bytes in one pass, plus size calculation used to pre-allocate output buffers.src/parser/on_demand— the lazy path: scans a BSON buffer into document metadata without materializing JS values, so they can be independently decoded.src/utils/— shared helpers (byte utils, number parsing, platform detection).test/node/— main test suite;bson_corpus*tests run the cross-driver BSON corpus spec.
Code Conventions
- Public API stability — Everything exported from
src/index.tslands in the publishedbson.d.ts. Renaming, removing, or narrowing exported types/signatures is a breaking change; confirm with a maintainer first. - No
export default— all exports named. No TypeScript enums — useas constobjects or string unions. - No
Bufferinsrc/— useUint8Array. Code must run in browsers. - No
node:import prefix insrc/. Tests may use it. - Null checks — loose equality (
== null), not=== null/=== undefined. - Type imports — inline:
import { type Foo }. - Errors — throw
BSONErroror its subclasses (BSONRuntimeError,BSONOffsetError, …) fromsrc/error.ts; messages in sentence case, no trailing period. - Formatting — Prettier: single quotes, 2-space indent, 100-char width, no trailing commas.
Other Important Information
- Changes must be compliant with bson spec, and should conform to specification tests for bson (e.g: bson-corpus).
- Before making key changes to anything within
src/parser/*, consider performance implications and run benchmark test passes to ensure no significant performance degradation.
Commit Messages
Conventional Commits optionally with a Jira ticket: <type>(NODE-XXXX): <subject> — types: feat, fix, docs, style, refactor, perf, test, chore; breaking changes use ! (e.g. feat(NODE-XXXX)!: …). This rule is mandatory for PR descriptions, because that is what ends up in the history. The individual commits inside a PR do not have to follow this convention, because we squash PR commits.
Further Reading
- CONTRIBUTING.md — contributor workflow
- docs/ — upgrade guides (v4, v5)
Related Repositories
MongoDB-maintained repos with a direct dependency relationship to bson. Changes here ripple into these; check them when altering public API or serialization behavior.
| Repo | Relationship | Used in | Why it matters |
| node-mongodb-native | imports bson | source | The Node.js driver; primary consumer. Every public API and wire-format behavior change surfaces there. |
| mongodb-client-encryption | imports bson | source | CSFLE/QE bindings; serializes/deserializes BSON when talking to libmongocrypt. |
| mongosh | imports bson | source | The MongoDB shell; exposes BSON type classes (ObjectId, Long, …) directly to end users. |
| compass | imports bson | source | Compass GUI; consumes via the compass:exports condition in package.json. |
| specifications | consumed by bson | tests | Source of the bson-corpus spec tests run by test/node/bson_corpus*. Behavior changes must stay conformant. |
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
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.

