Native-driver, StrictDB, and data-modeling rules for MongoDB.

MITAuto-check passedDatabases

Install Mongodb Rules

skills CLI
$ npx skills add TheDecipherist/claude-code-mastery-project-starter-kit --skill mongodb-rules -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install TheDecipherist/claude-code-mastery-project-starter-kit mongodb-rules --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/TheDecipherist/claude-code-mastery-project-starter-kit.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/mongodb-rules .claude/skills/mongodb-rules && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
mongodb-rules
GitHub stars
338
Token cost
~1.7k tokens
SKILL.md length
923 words
Files
1
Skills in repo
24
Repo updated
First seen
Licence
MIT

At a glance

Native-driver, StrictDB, and data-modeling rules for MongoDB.

  • Modifying queries
  • SKILL.md covers Driver and connection, Identity and types, Querying and Writes, plus 5 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Schema against MongoDB

What it does

Mongodb Rules is an agent skill from TheDecipherist/claude-code-mastery-project-starter-kit. Native-driver, StrictDB, and data-modeling rules for MongoDB. Use whenever writing or modifying queries, writes, indexes, aggregations, upserts, connections, or schema against MongoDB, or any code that touches the data layer. Loads inline so it shapes code as it's written.

Its SKILL.md is about 1.7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases, covering NoSQL databases. It works with MongoDB. The repository describes itself as: The definitive starting point for Claude Code projects. Based on Claude Code Mastery Guides V1-V5. The licence is MIT.

When your agent uses it

  • Modifying queries
  • Schema against MongoDB
  • Any code that touches the data layer

Example prompts

  • “/mongodb-rules”

What it can do on your machine

Read from SKILL.md and the folder at commit 61fbb99. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Mongodb Rules loads about 1.7k tokens when it runs. Until then it costs about 72 tokens; SKILL.md has 923 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~72
When it runs · the whole SKILL.md, loaded when a task matches
~1.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from TheDecipherist/claude-code-mastery-project-starter-kit at commit 61fbb99, republished under its MIT licence (© TheDecipherist). 923 words, ~1,664 tokens.

Download SKILL.mdSave it as .claude/skills/mongodb-rules/SKILL.md (or your agent's skills folder).
name
mongodb-rules
description
Native-driver, StrictDB, and data-modeling rules for MongoDB. Use whenever writing or modifying queries, writes, indexes, aggregations, upserts, connections, or schema against MongoDB, or any code that touches the data layer. Loads inline so it shapes code as it's written.

MongoDB Data-Access Rules

Non-negotiable for this codebase. From production, not preference.

Driver and connection

  • Prefer StrictDB; fall back to the native driver. Use StrictDB when it's installed, otherwise the native MongoDB driver directly. Never Mongoose, either way.
  • Data access stays in the adapter, never raw collections scattered through feature code.
  • One shared MongoClient for the whole app, created once at startup and reused everywhere. The client is the pool. Never create one per request, that exhausts connections and looks like "MongoDB went down" under load. In serverless, declare the client at module scope, outside the handler, so warm invocations reuse it.
  • URI comes from an env var, never hardcoded. Close the client on SIGTERM/SIGINT.

Identity and types

  • _id is an ObjectId, not a string. A string _id against an ObjectId document matches nothing, silently. This is the number-one "my id query returns nothing" bug. Wrap incoming ids with new ObjectId(id); for an $in list, convert every element.
  • Never put _id in the body of any write. Identity goes in the filter; on insert MongoDB generates it. Restating it after a JSON round-trip throws code 66 (immutable field altered).
  • JSON strips both ObjectId and Date to strings. Re-hydrate at the boundary before you query or save, or lookups match nothing and date filters break. Use a parse-time reviver (parseMongo) or a bounded post-parse walk (rehydrateTypes, maxDepth=3). Never patch the global JSON.parse. Guard with ObjectId.isValid and a skipKeys list.
  • Consider a natural string _id (email, SKU, slug) to sidestep the type dance entirely, then ids are strings end to end.
  • Only _id is indexed by default. Sorting by _id gives roughly creation order for free, but store an explicit createdAt when creation time matters; don't rely on the ObjectId's embedded timestamp.

Querying

  • null is not "missing". { field: null } matches both explicit null AND absent documents. Use { field: { $exists: false } } for missing, and { field: { $ne: null } } for "has a real value" (which excludes both null and missing).
  • Reads are aggregation pipelines, not find().
  • Arrays-within-arrays aren't queryable past about three levels (maxDepth=3). If you need to, the model is wrong, flatten it.

Writes

  • Multi-document writes use bulkWrite. Build the ops array in the loop, execute one bulkWrite after it. Never call the database inside a loop.
  • Choose ordered vs unordered deliberately. ordered (default) stops at the first error; { ordered: false } attempts all and collects errors, and is faster. On partial failure, triage transient vs permanent: retry only transient ops with backoff, never blind-retry a duplicate-key or validation failure.
  • Make writes idempotent (stable keys, set-to-value over blind increments) so retry is safe.
  • Upsert is updateOne with upsert: true. Use $setOnInsert for insert-only fields, and pair it with a unique index so concurrent upserts can't duplicate.

Indexing

  • createIndex is idempotent but not free, each call is a round trip. Declare indexes near the queries that need them, but create them once in startup or a migration, never in a handler or hot loop.
  • A compound index serves only a left-to-right prefix of its fields. Order fields to match how you query; equality-matched fields lead.
  • For filter-plus-sort, follow ESR: Equality, Sort, Range. Index direction must match the sort or be its exact inverse. An in-memory SORT stage in explain means the index isn't serving the sort.
  • Filter early ($match first), and put $limit before $lookup. Diagnose with explain("executionStats"): examined far exceeding returned means a missing index.
Show full SKILL.md (364 more words)Show less

Modeling

  • Embed bounded, read-together data; reference unbounded data (comments, events, logs, anything that accumulates). A document is rewritten and moved as a whole, so an unbounded array degrades writes long before the 16MB hard limit.
  • $elemMatch usually signals a modeling problem. A field you query independently belongs on the document or in its own collection.

Concurrency and integrity

  • MongoDB has full ACID transactions, but a single-document write is already atomic. Reach for session.withTransaction only for genuine cross-document atomicity (transfer between accounts, decrement stock while creating an order). Frequent transactions are a modeling smell, the data probably wanted to be one document.
  • Unique values are enforced by a unique index, not app-level checks. Use a partial unique index for optional fields (a plain unique index treats missing as null and collides). Use a compound unique index for "this combination is unique". The duplicate-key error is the guarantee that makes concurrent upserts safe.

Reads at scale

  • Counting is a choice. countDocuments is exact (index the filter to keep it fast); estimatedDocumentCount is instant but approximate and whole-collection only, use it for rough dashboard totals. distinct on a high-cardinality field at scale should be a $group so the result streams.
  • $skip doesn't scale, it walks past every skipped document. For deep or endless paging, use range/keyset pagination: $match on the last-seen value of an indexed sort key, with _id as a unique tie-breaker so pages don't shift as data changes.

Schema

Collections enforce no structure by default, so validate in two layers.

  • Parse before every write. Validate each document against its Zod schema right before it hits the database, so a malformed shape never lands. The schema itself isn't Mongo-specific, it's the same contract the API and frontend use, see the schema-source-of-truth skill for defining it once and deriving every layer from one base.
  • Keep a $jsonSchema collection validator as the floor. Zod only guards writes that go through your app, so the DB validator is the last line that also catches mongosh, scripts, and other services. Add it as a collection stabilizes and more code depends on its shape. Roll out safely: validationAction: "warn" to observe first, then error; validationLevel: "moderate" to spare existing nonconforming documents.

© TheDecipherist, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .claude/skills/mongodb-rules of TheDecipherist/claude-code-mastery-project-starter-kit.

Open the folder on GitHubat commit 61fbb99

Compare with similar skills

Mongodb Rules next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Mongodb Rules compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Mongodb Rules this skillTheDecipherist/claude-code-mastery-project-starter-kit338—~1.7kAutomated safety check: PassMIT
Mongodbsickn33/agentic-awesome-skills47k2 repos~2.7kAutomated safety check: NotesMIT
Mongodb Qe Size Estimationmongodb/agent-skills190—~4.2kAutomated safety check: PassApache-2.0
MongodbRightNow-AI/openfang18k—~821Automated safety check: PassApache-2.0
415 Frameworks Quarkus Mongodbjabrena/plinth445—~528Automated safety check: PassApache-2.0
416 Frameworks Quarkus Mongodb Migrations Mongockjabrena/plinth445—~1kAutomated safety check: PassApache-2.0

Similar skills

  • Mongodb

    sickn33/agentic-awesome-skills

    Administer MongoDB databases. An agent skill from sickn33/agentic-awesome-skills.

    47k GitHub starsUsed in 2 repos~2.7k tokens
    DatabasesAuto-check: notes
  • Mongodb Qe Size Estimation

    mongodb/agent-skills

    Official

    Estimates the storage and memory impact of encrypting fields in collections with Queryable Encryption (QE) enabled.

    190 GitHub stars~4.2k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Mongodb

    RightNow-AI/openfang

    MongoDB operations expert for queries, aggregation pipelines, indexes, and schema design

    18k GitHub stars~821 tokensUpdated 3 mo ago
    DatabasesAuto-check passed
  • A skill your agent uses when you need MongoDB persistence in Quarkus — including Panache Mongo entities/repositories, document design, indexes, transactions where applicable, and error handling.

    445 GitHub stars~528 tokensUpdated today
    DatabasesAuto-check passed
  • A skill your agent uses when you need to add or review Mongock MongoDB data migrations in a Quarkus application — including the Quarkiverse Mongock extension, Quarkus MongoDB client configuration…

    445 GitHub stars~1k tokensUpdated today
    DatabasesAuto-check passed
  • A skill your agent uses when you need MongoDB persistence in Micronaut — including @MongoRepository design, document modeling, indexes, query patterns, and error handling.

    445 GitHub stars~525 tokensUpdated today
    DatabasesAuto-check passed

More from TheDecipherist/claude-code-mastery-project-starter-kit

All 24 skills in this repo
  • Create Service

    TheDecipherist/claude-code-mastery-project-starter-kit

    Scaffold a new microservice that follows the project's server/handlers/adapters architecture.

    338 GitHub stars~1.8k tokensUpdated 3 mo ago
    Auto-check: notes
  • CSS Structure

    TheDecipherist/claude-code-mastery-project-starter-kit

    Where CSS should live. An agent skill from TheDecipherist/claude-code-mastery-project-starter-kit.

    338 GitHub stars~1k tokensUpdated 3 mo ago
    Auto-check passed
  • Docker

    TheDecipherist/claude-code-mastery-project-starter-kit

    Production Docker best practices for writing Dockerfiles, Compose files, and Swarm stacks.

    338 GitHub stars~1.6k tokensUpdated 3 mo ago
    Auto-check: notes
  • Docker Swarm

    TheDecipherist/claude-code-mastery-project-starter-kit

    Production Docker Swarm deployment rules: what changes when a compose file goes from a single node to a multi-node Swarm.

    338 GitHub stars~1.8k tokensUpdated 3 mo ago
    Auto-check passed
  • Mongodb Backups

    TheDecipherist/claude-code-mastery-project-starter-kit

    Production MongoDB backup and restore practices that the documentation gets wrong.

    338 GitHub stars~1.3k tokensUpdated 3 mo ago
    Auto-check passed
  • Mongodb Replica Sets

    TheDecipherist/claude-code-mastery-project-starter-kit

    Production MongoDB replica-set operation: topology, durability, host tuning, and the container-specific gotchas Claude gets wrong.

    338 GitHub stars~1.6k tokensUpdated 3 mo ago
    Auto-check passed

Works with

Categories

Questions about Mongodb Rules

What does Mongodb Rules do?

Native-driver, StrictDB, and data-modeling rules for MongoDB. Mongodb Rules is an agent skill from TheDecipherist/claude-code-mastery-project-starter-kit. Native-driver, StrictDB, and data-modeling rules for MongoDB.

When should I use Mongodb Rules?

Mongodb Rules fits situations like: modifying queries; schema against MongoDB; any code that touches the data layer.

How do I install Mongodb Rules in Claude Code?

Run `npx skills add TheDecipherist/claude-code-mastery-project-starter-kit --skill mongodb-rules -a claude-code`. Or copy the skill folder (.claude/skills/mongodb-rules in TheDecipherist/claude-code-mastery-project-starter-kit) into .claude/skills/mongodb-rules in your project. Claude Code loads it when a task matches its description.

How do I install Mongodb Rules in Codex?

Run `npx skills add TheDecipherist/claude-code-mastery-project-starter-kit --skill mongodb-rules -a codex`. Or copy the skill folder (.claude/skills/mongodb-rules in TheDecipherist/claude-code-mastery-project-starter-kit) into .agents/skills/mongodb-rules in your project. Codex loads it when a task matches its description.

Can I use Mongodb Rules in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add TheDecipherist/claude-code-mastery-project-starter-kit --skill mongodb-rules -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/mongodb-rules, .gemini/skills/mongodb-rules, .github/skills/mongodb-rules and .opencode/skills/mongodb-rules in your project.

What does Mongodb Rules need to run?

SKILL.md names no scripts, command-line tools or credentials: Mongodb Rules is instructions for the agent only.

Does Mongodb Rules access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Mongodb Rules safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Mongodb Rules use?

Mongodb Rules is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Mongodb Rules use?

About 1.7k tokens (SKILL.md is roughly 6.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Mongodb Rules?

Skills that share tags, products or a category with Mongodb Rules: Mongodb (sickn33/agentic-awesome-skills, 47k stars), Mongodb Qe Size Estimation (mongodb/agent-skills, 190 stars), Mongodb (RightNow-AI/openfang, 18k stars) and 415 Frameworks Quarkus Mongodb (jabrena/plinth, 445 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Mongodb Rules?

TheDecipherist (a GitHub user) maintains it in TheDecipherist/claude-code-mastery-project-starter-kit, which has 338 GitHub stars. The repository holds 24 skills in this directory. The repository was last updated on June 29, 2026.

Source: TheDecipherist/claude-code-mastery-project-starter-kit on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.