mongodb

Designs and tunes MongoDB document models, indexes, aggregation pipelines, and cluster operations.

22|Updated Sep 10, 2026
One-click install
npx skills add https://github.com/Lynricsy/HyperSkills --skill mongodb-lynricsy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mongodb
Source: https://github.com/Lynricsy/HyperSkills/tree/main/skills/mongodb
Command: npx skills add https://github.com/Lynricsy/HyperSkills --skill mongodb-lynricsy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? MongoDB applications fail in predictable ways: unbounded embedded arrays that hit the 16 MB document limit, indexes ordered wrong for the query shape, aggregation pipelines that scan millions of documents, and writes lost or duplicated during failovers. This Skill gives an AI assistant the measured, version-gated rules to diagnose and fix these problems instead of guessing. ## Core Features & Use Cases - Document modeling and migration: Decide embed-versus-reference from access patterns, bound every array, split hot and cold fields, and run online schema migrations with versioned documents and staged $jsonSchema validation. - Query and index tuning: Read explain() counters (totalKeysExamined, totalDocsExamined, nReturned), design compound indexes in Equality-Sort-Range order, and remove indexes safely with hideIndex before dropIndex. - Aggregation and durability: Fix $lookup fan-out, blocking-stage spills, and unbounded $group accumulators; configure retryable writes, write concern, and withTransaction so writes survive elections. - Use Case: A team's chat backend slows as threads grow. The Skill identifies the unbounded messages array as the root cause, prescribes a child collection keyed by thread, fixes the sidebar's missing projection, and lays out a batched online migration. ## Quick Start Ask the assistant to review your MongoDB data model, slow query, or aggregation pipeline using the mongodb skill and paste the relevant code or explain output.

Frequently Asked Questions about mongodb

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix a slow MongoDB query or aggregation pipeline?

Run explain("executionStats") and compare nReturned, totalKeysExamined, and totalDocsExamined. A COLLSCAN, a SORT stage, a FETCH with a filter, or usedDisk: true each names its own fix, usually a compound index in Equality-Sort-Range order or an earlier $match.

When should I embed versus reference documents in MongoDB?

Embed only when the child is meaningless without the parent, the hot read needs it, and the array has an enforceable bound. Unbounded append-only data belongs in a child collection or buckets, because every $push rewrites the whole document and the 16 MB limit ends it.

Why does my MongoDB compound index fail with cannot index parallel arrays?

A compound index may contain at most one array field. The error surfaces on the write, not at createIndex time, so applications hit it months later when a second field first receives an array. Split the fields into separate indexes.

Does MongoDB retryable writes prevent duplicate operations after failover?

Yes. With retryWrites enabled the driver retries once using a transaction number the server deduplicates, so a retry after a primary stepdown cannot apply the write twice. An application-level retry cannot know whether the first attempt committed.

How do I safely drop an unused MongoDB index?

Check $indexStats for zero accesses over a full business cycle, then call hideIndex so the planner ignores it while it stays maintained. Confirm no plan regressed, and only then dropIndex; unhiding is instant while rebuilding is not.

Can I use $vectorSearch or $search outside MongoDB Atlas?

No. $search and $vectorSearch require Atlas or a deployment with mongot; a plain self-managed mongod rejects those stages. On self-managed deployments only the older $text operator with a text index is available.