mongodb-rules

mongodb-rules is a skill for Claude Code, Codex from TheDecipherist/claude-code-mastery-project-starter-kit. It costs 63 tokens per session (1,536 once invoked), scanned A, original, MIT.

A set of rules for writing MongoDB data-access code with the native driver or StrictDB, including queries, writes, indexes, aggregations, upserts, connections, and data models.

In plain words
What is it for?
Use it when modifying MongoDB queries or schemas, building adapters, handling ObjectId values, managing shared connections, writing indexes, or implementing reads and writes.
Why use it?
It prevents common database bugs and operational problems, such as mismatched ID types, too many client connections, hardcoded credentials, and data-access logic scattered through application code.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/thedecipherist/claude-code-mastery-project-starter-kit/mongodb-rules
Any agent
npx skills add TheDecipherist/claude-code-mastery-project-starter-kit --skill mongodb-rules
Clone the repo
git clone --depth 1 https://github.com/TheDecipherist/claude-code-mastery-project-starter-kit

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mongodb-rules

README.md
[![agentmods](https://agentmods.dev/badge/skills/thedecipherist/claude-code-mastery-project-starter-kit/mongodb-rules.svg)](https://agentmods.dev/skills/thedecipherist/claude-code-mastery-project-starter-kit/mongodb-rules)
Your own site
<a href="https://agentmods.dev/skills/thedecipherist/claude-code-mastery-project-starter-kit/mongodb-rules"><img src="https://agentmods.dev/badge/skills/thedecipherist/claude-code-mastery-project-starter-kit/mongodb-rules.svg" alt="Measured on agentmods" height="20"></a>
Per session 63 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,536 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00063 $0.01536
Opus 5 $0.00032 $0.00768
Sonnet 5 $0.00013 $0.00307
Haiku 4.5 $0.00006 $0.00154

Measured 5d ago against content hash bd2f50271a86, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

mongodb-rules scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/mongodb-rules/SKILL.md · 66 lines

How it starts

The opening of the file, as written. The whole thing — 66 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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.

Read the full file on GitHub · 66 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 66 lines · 63 tokens per session scan A bd2f50271a86

Subscribe to this mod's changes

mongodb-rules is a skill published in the GitHub repository TheDecipherist/claude-code-mastery-project-starter-kit (337 stars, last pushed 2mo ago), licensed MIT. It adds 63 tokens to every session and 1,536 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

dbx

DBX CLI for database schema exploration and read-only queries. When the user needs to list connections, explore tables, describe schemas, run queries, or generate AI-friendly schema context from DBX-managed databases. Do NOT use for write operations unless the user explicitly confirms with --allow-writes.

t8y2/dbx · 61 tokens

azure-mgmt-mongodbatlas-dotnet

Manage MongoDB Atlas Organizations as Azure ARM resources using Azure.ResourceManager.MongoDBAtlas SDK. Use when creating, updating, listing, or deleting MongoDB Atlas organizations through Azure Marketplace integration. This SDK manages the Azure-side organization resource, not Atlas clusters/databases directly.

microsoft/skills · 64 tokens

evergreen

Evergreen CI infrastructure, configuration validation. Use when modifying .evergreen/ config, preparing to submit changes or understanding the Evergreen test matrix.

mongodb/mongo-java-driver · 31 tokens

nosqli

NoSQL injection — MongoDB operator injection ($ne, $gt, $where, $regex), CouchDB / Firebase / Redis attack patterns, auth bypass, blind extraction.

PurpleAILAB/Decepticon · 38 tokens

prisma-mongodb-upgrade

Decision and migration guide for Prisma ORM MongoDB projects on v6, which have no upgrade path to v7. Use when a MongoDB project asks about upgrading Prisma, when "upgrade to prisma 7" comes up in a project with provider = "mongodb", or when evaluating a move to Prisma Next. Triggers on "upgrade prisma mongodb"…

nitrocloudofficial/nitrostack · 95 tokens

byted-volcengine-mongodb

使用火山引擎 MongoDB Skill,帮助用户完成 MongoDB 相关的实例管理、备份恢复、参数等运维任务,可直接调用 uv run ./scripts/callmongodb.py 脚本获取实时结果。当需要访问管理在火山引擎 MongoDB 实例详细信息时,此 Skill 可以提供方便的接口。.

bytedance/agentkit-samples · 82 tokens