mongodb

Guide MongoDB schema design, query writing, aggregation pipelines, and index optimization.

4|1|Updated Mar 3, 2026
One-click install
npx skills add https://github.com/aegntic/clawreform --skill mongodb-aegntic
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mongodb
Source: https://github.com/aegntic/clawreform/tree/main/crates/clawreform-skills/bundled/mongodb
Command: npx skills add https://github.com/aegntic/clawreform --skill mongodb-aegntic

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps users efficiently manage and interact with MongoDB databases, from designing schemas and writing queries to optimizing performance and understanding best practices.

Core Features & Use Cases

  • Schema Design: Guidance on embedding vs. referencing, subset pattern, bucket pattern, and schema versioning.
  • Query Optimization: Advice on projections, $elemMatch, $in, $exists, $type, and avoiding slow operators.
  • Aggregation Framework: Best practices for building pipelines, using $match, $project, $group, $lookup, $facet, $merge, and $out.
  • Index Management: Strategies for creating compound indexes, auditing index usage, partial indexes, TTL indexes, and dropping unused indexes.
  • Pitfall Avoidance: Warnings against unbounded arrays, unindexed queries, leading wildcard regex, and frequent updates to indexed fields.

Quick Start

Use the mongodb skill to explain how to create a compound index for equality, sort, and range fields.

Frequently Asked Questions about mongodb

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

FAQPage Schema
How do I optimize slow MongoDB queries and avoid common performance pitfalls?

Optimize MongoDB query performance by using projections, applying operators like $elemMatch and $in efficiently, and avoiding leading wildcard regex or unindexed queries to prevent slow database operations.

What's the best way to design a MongoDB schema for scalability?

Design MongoDB schemas by choosing between embedding and referencing, applying subset and bucket patterns, and implementing schema versioning to maintain performance and scalability as data grows.

How do I build an efficient MongoDB aggregation pipeline?

Build efficient MongoDB aggregation pipelines by sequencing operators like $match, $project, $group, $lookup, $facet, $merge, and $out, while following best practices to process data effectively.

When should I create compound indexes in MongoDB?

Create compound indexes in MongoDB for equality, sort, and range fields to optimize query performance, and audit index usage to drop unused indexes or implement partial and TTL indexes.

What MongoDB operations should I avoid to prevent performance degradation?

Avoid unbounded arrays, unindexed queries, leading wildcard regex patterns, and frequent updates to indexed fields in MongoDB to prevent performance degradation and maintain database efficiency.