From mongodb-agent-skills
Provides MongoDB schema design patterns and anti-patterns for data modeling, schema reviews, SQL migrations, and troubleshooting performance issues from bad schemas.
npx claudepluginhub romiluz13/mongodb-agent-skillsThis skill uses the workspace's default tool permissions.
Data modeling patterns and anti-patterns for MongoDB, maintained by MongoDB. Contains **33 rules across 5 categories**, prioritized by impact. Bad schema is the root cause of most MongoDB performance and cost issues—queries and indexes cannot fix a fundamentally wrong model.
AGENTS.mdREADME.mdmetadata.jsonrules/_sections.mdrules/_template.mdrules/antipattern-bloated-documents.mdrules/antipattern-excessive-lookups.mdrules/antipattern-massive-arrays.mdrules/antipattern-schema-drift.mdrules/antipattern-unbounded-arrays.mdrules/antipattern-unnecessary-collections.mdrules/antipattern-unnecessary-indexes.mdrules/fundamental-16mb-awareness.mdrules/fundamental-data-together.mdrules/fundamental-document-model.mdrules/fundamental-embed-vs-reference.mdrules/fundamental-schema-validation.mdrules/pattern-approximation.mdrules/pattern-archive.mdrules/pattern-attribute.mdProvides MongoDB schema design patterns and anti-patterns for data modeling, schema reviews, SQL migrations, and performance troubleshooting from schema issues.
Designs NoSQL schemas for MongoDB and DynamoDB including document modeling, collection/table design, indexing, denormalization, and query optimization.
Designs scalable SQL and NoSQL database schemas from entity descriptions, with normalization, indexing, constraints, migrations, and performance best practices.
Share bugs, ideas, or general feedback.
Data modeling patterns and anti-patterns for MongoDB, maintained by MongoDB. Contains 33 rules across 5 categories, prioritized by impact. Bad schema is the root cause of most MongoDB performance and cost issues—queries and indexes cannot fix a fundamentally wrong model.
Reference these guidelines when:
| Priority | Category | Impact | Prefix | Rules |
|---|---|---|---|---|
| 1 | Schema Anti-Patterns | CRITICAL | antipattern- | 7 |
| 2 | Schema Fundamentals | HIGH | fundamental- | 5 |
| 3 | Relationship Patterns | HIGH | relationship- | 6 |
| 4 | Design Patterns | MEDIUM | pattern- | 12 |
| 5 | Schema Validation | MEDIUM | validation- | 3 |
antipattern-unbounded-arrays - Never allow arrays to grow without limitantipattern-bloated-documents - Keep documents under 16KB for working setantipattern-massive-arrays - Arrays over 1000 elements hurt performanceantipattern-unnecessary-collections - Fewer collections, more embeddingantipattern-excessive-lookups - Reduce $lookup by denormalizingantipattern-schema-drift - Enforce consistent structure across documentsantipattern-unnecessary-indexes - Audit and remove unused or redundant indexesfundamental-embed-vs-reference - Decision framework for relationshipsfundamental-data-together - Data accessed together stored togetherfundamental-document-model - Embrace documents, avoid SQL patternsfundamental-schema-validation - Enforce structure with JSON Schemafundamental-16mb-awareness - Design around BSON document limitrelationship-one-to-one - Embed for simplicity, reference for independencerelationship-one-to-few - Embed bounded arrays (addresses, phone numbers)relationship-one-to-many - Reference for large/unbounded relationshipsrelationship-one-to-squillions - Reference massive child sets, store summariesrelationship-many-to-many - Two-way referencing for bidirectional accessrelationship-tree-structures - Parent/child/materialized path patternspattern-archive - Move historical data to separate storage for performancepattern-attribute - Collapse many optional fields into key-value attributespattern-bucket - Group time-series or IoT data into bucketspattern-time-series-collections - Use native time series collections when availablepattern-extended-reference - Cache frequently-accessed related datapattern-subset - Store hot data in main doc, cold data elsewherepattern-computed - Pre-calculate expensive aggregationspattern-outlier - Handle documents with exceptional array sizespattern-polymorphic - Store heterogeneous documents with a type discriminatorpattern-schema-versioning - Evolve schemas safely with version fieldsvalidation-json-schema - Validate data types and structure at database levelvalidation-action-levels - Choose warn vs error mode for validationvalidation-rollout-strategy - Introduce validation safely in production"Data that is accessed together should be stored together."
This is MongoDB's core philosophy. Embedding related data eliminates joins, reduces round trips, and enables atomic updates. Reference only when you must.
| Relationship | Cardinality | Access Pattern | Recommendation |
|---|---|---|---|
| One-to-One | 1:1 | Always together | Embed |
| One-to-Few | 1:N (N < 100) | Usually together | Embed array |
| One-to-Many | 1:N (N > 100) | Often separate | Reference |
| Many-to-Many | M:N | Varies | Two-way reference |
Read individual rule files for detailed explanations and code examples:
rules/antipattern-unbounded-arrays.md
rules/relationship-one-to-many.md
rules/_sections.md
Each rule file contains:
Every rule in this skill provides:
I analyze code patterns, but I can't see your actual data without a database connection. This means I might suggest:
Always verify before implementing. Each rule includes verification commands.
For automatic verification, connect the MongoDB MCP Server:
Option 1: Connection String
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": ["-y", "mongodb-mcp-server", "--readOnly"],
"env": {
"MDB_MCP_CONNECTION_STRING": "mongodb+srv://user:pass@cluster.mongodb.net/mydb"
}
}
}
}
Option 2: Local MongoDB
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": ["-y", "mongodb-mcp-server", "--readOnly"],
"env": {
"MDB_MCP_CONNECTION_STRING": "mongodb://localhost:27017/mydb"
}
}
}
}
⚠️ Security: Use --readOnly for safety. Remove only if you need write operations.
When connected, I can automatically:
mcp__mongodb__collection-schemamcp__mongodb__aggregatemcp__mongodb__db-statsI will NEVER execute write operations without your explicit approval.
| Operation Type | MCP Tools | Action |
|---|---|---|
| Read (Safe) | find, aggregate, collection-schema, db-stats, count | I may run automatically to verify |
| Write (Requires Approval) | update-many, insert-many, create-collection | I will show the command and wait for your "yes" |
| Destructive (Requires Approval) | delete-many, drop-collection, drop-database | I will warn you and require explicit confirmation |
When I recommend schema changes or data modifications:
Your database, your decision. I'm here to advise, not to act unilaterally.
If you're not sure about a recommendation:
We're a team—let's get this right together.
For the complete guide with all rules expanded: AGENTS.md