mongodb-schema-and-indexing

mongodb-schema-and-indexing is a skill for Claude Code, Codex from hamzabellouch/agent-skills. It costs 54 tokens per session (1,510 once invoked), scanned A, original, MIT.

A guide to designing MongoDB, a document database, including document structure, indexes, aggregation queries, and sharding across servers.

In plain words
What is it for?
Use it to choose between embedded and referenced data, tune indexes and aggregation pipelines, and plan scalable MongoDB clusters.
Why use it?
Good document structure and indexes make queries faster and help avoid inefficient joins or scans as data grows.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to choose between embedded and referenced data, tune indexes and aggregation pipelines, and plan scalable MongoDB clusters.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hamzabellouch/agent-skills/mongodb-schema-and-indexing
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.

Any agent
npx skills add hamzabellouch/agent-skills --skill mongodb-schema-and-indexing
Clone the repo
git clone --depth 1 https://github.com/hamzabellouch/agent-skills

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-schema-and-indexing

README.md
[![agentmods](https://agentmods.dev/badge/skills/hamzabellouch/agent-skills/mongodb-schema-and-indexing/github.svg)](https://agentmods.dev/skills/hamzabellouch/agent-skills/mongodb-schema-and-indexing)
Your own site
<a href="https://agentmods.dev/skills/hamzabellouch/agent-skills/mongodb-schema-and-indexing"><img src="https://agentmods.dev/badge/skills/hamzabellouch/agent-skills/mongodb-schema-and-indexing/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for mongodb-schema-and-indexing

Your own site · 80×15
<a href="https://agentmods.dev/skills/hamzabellouch/agent-skills/mongodb-schema-and-indexing"><img src="https://agentmods.dev/badge/skills/hamzabellouch/agent-skills/mongodb-schema-and-indexing.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 54 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,510 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00054 $0.01510
Opus 5.5 $0.00022 $0.00604
Sonnet 5.5 $0.00011 $0.00302
Haiku 4.5 $0.00005 $0.00151

Measured 1mo ago against content hash bc3b74db6a4a, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

mongodb-schema-and-indexing 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 1mo 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.

Databases and Caching/mongodb-schema-and-indexing/SKILL.md · 165 lines

How it starts

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

MongoDB Schema Design & Indexing Optimization Guide

Comprehensive architectural reference for MongoDB schema modeling, high-performance indexing, aggregation pipeline tuning, and cluster sharding strategies.


1. Schema Modeling Framework: Embedding vs. Referencing

Decision Matrix

                      Do entities have a 1:1 or 1:Few relationship?
                                     /             \
                                  YES               NO
                                  /                   \
           Embed data inside parent document         Do child documents grow unbounded?
                                                            /             \
                                                         YES               NO
                                                         /                   \
                                            Use Two-Way Referencing      Embed with Subset Pattern
Factor Embedded Subdocuments Referenced Documents (Normalized)
Query Performance Fast ($O(1)$ single read, no joins) Requires $lookup or application-side joins
Atomicity Atomic updates across whole document Requires Multi-Document Transactions (session)
Document Size Limit Subject to 16 MB BSON hard limit Multi-document architecture bypasses limit
Data Redundancy Possible duplication across documents Single source of truth

2. Advanced MongoDB Design Patterns

2.1 Subset Pattern

  • Problem: Large embedded array (e.g., 5,000 product reviews) causes huge document size and slow memory loading.
  • Solution: Keep only the 10 most recent reviews in the main product document; store all historical reviews in a separate reviews collection.

2.2 Extended Reference Pattern

  • Problem: Frequent joins ($lookup) just to fetch 1 or 2 fields (e.g., customerName and customerEmail on an Order).
  • Solution: Copy immutable or rarely changed target fields directly into the order document:
    {
      "_id": ObjectId("6697a4..."),
      "totalAmount": 149.99,
      "customer": {
        "id": ObjectId("6697a2..."),
        "name": "Jane Doe",
        "email": "[email protected]"
      }
    }
    

Read the full file on GitHub · 165 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. 1mo ago First seen · 165 lines · 54 tokens per session scan A bc3b74db6a4a

Subscribe to this mod's changes

mongodb-schema-and-indexing is a skill published in the GitHub repository hamzabellouch/agent-skills (8 stars, last pushed 11d ago), licensed MIT. It adds 54 tokens to every session and 1,510 once invoked, about $0.0002 per session on Opus 5.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-09-03.

Related

Other skills, from other repositories

mongodb

Expert MongoDB document database assistance covering aggregation pipelines, compound indexes, replica sets, and sharding. Use when designing flexible JSON schemas, querying geospatial data, or scaling document stores.

G1Joshi/Agent-Skills · 39 tokens

mongodb-connection

Optimize MongoDB client connection configuration (pools, timeouts, patterns) for any supported driver language. Use this skill when working/updating/reviewing on functions that instantiate or configure a MongoDB client (eg, when calling connect()), configuring connection pools, troubleshooting connection errors…

fcakyon/claude-codex-settings · 122 tokens

mongodb-schema-design

MongoDB schema design patterns and anti-patterns. Use when designing data models, reviewing schemas, migrating from SQL, or troubleshooting performance issues caused by schema problems. Triggers on "design schema", "embed vs reference", "MongoDB data model", "schema review", "unbounded arrays", "one-to-many", "tree…

fcakyon/claude-codex-settings · 127 tokens

mongodb-query-optimizer

Help with MongoDB query optimization and indexing. Use only when the user asks for optimization or performance: "How do I optimize this query?", "How do I index this?", "Why is this query slow?", "Can you fix my slow queries?", "What are the slow queries on my cluster?", etc. Do not invoke for general MongoDB query…

fcakyon/claude-codex-settings · 98 tokens

mongodb-search-and-ai

Covers everything about search in MongoDB: Atlas Search (full-text), Vector Search (semantic), and Hybrid Search. Use this skill for ANY question about MongoDB search, including open-ended and explanatory ones asked before the user has any data or use case — 'how does search work in MongoDB?', 'I'm new to MongoDB…

fcakyon/claude-codex-settings · 210 tokens

qdrant-migration-tool

Guides use of the Qdrant Migration Tool CLI to move vectors, metadata, and sparse embeddings from another vector database into Qdrant. Use when someone asks 'how do I migrate from Pinecone/Weaviate/Milvus/Elasticsearch/OpenSearch/pgvector/s3/Azure/Chroma/Redis/MongoDB/FAISS/Solr to Qdrant', 'move my vector database to…

qdrant/skills · 156 tokens