mongodb avatar

Mongodb Schema Design

MongoDB performance problems usually trace back to schema design, not queries or indexes. This skill helps you decide between embedding and referencing data, avoid common anti-patterns like unnecessary collections and excessive lookups, and apply proven patterns like bucketing for time series or the extended reference pattern for caching frequently accessed fields. It's especially useful when migrating from SQL where the instinct to normalize everything will hurt you, or when you're hitting the 16MB document limit from unbounded arrays. The core principle is simple: data accessed together should be stored together. If you're doing a lot of lookups or your queries span multiple collections, your schema probably needs rethinking.

skills.sh installs
7.2K
GitHub stars
197
last updated
Aug 21, 2026

Install

$ npx -y skills add mongodb/agent-skills --skill mongodb-schema-design --agent claude-code

Installs into .claude/skills of the current project.

Files

MongoDB Schema Design

Data modeling patterns and anti-patterns for MongoDB, maintained by MongoDB. Bad schema is the root cause of most MongoDB performance and cost issues—queries and indexes cannot fix a fundamentally wrong model.

When to Apply

Reference these guidelines when:

  • Designing a new MongoDB schema from scratch
  • Migrating from SQL/relational databases to MongoDB
  • Reviewing existing data models for performance issues
  • Troubleshooting slow queries or growing document sizes
  • Deciding between embedding and referencing
  • Modeling relationships (one-to-one, one-to-many, many-to-many)
  • Implementing tree/hierarchical structures
  • Seeing Atlas Schema Suggestions or Performance Advisor warnings
  • Hitting the 16MB document limit
  • Adding schema validation to existing collections

Quick Reference

1. Schema Anti-Patterns - 3 rules

Sponsors

Details

Repository
github.com/mongodb/agent-skills
Categories
Git & Pull Requests, Code Review & Quality, AI & Agent Building, Debugging, Marketing & SEO, Design & UI/UX, Databases
First seen
May 16, 2026

More from mongodb/agent-skills

All 8
1trailofbits avataragentic-actions-auditortrailofbits/skillsAudits GitHub Actions workflows for security vulnerabilities in AI agent integrations including Claude Code Action, Gemini CLI, OpenAI Codex, and GitHub AI Infe7.1Kskills.sh installs
2benjitaylor avataragentation-self-drivingbenjitaylor/agentationAutonomous design critique mode using the Agentation annotation toolbar. Use when the user asks to "critique this page," "add design annotations," "review the U7.1Kskills.sh installs
3cursor avatarblast-radiuscursor/pluginsFind what a change could break somewhere else before it ships, beyond the diff, and prove the one fact it's safe because of by running real code instead of writ7.1Kskills.sh installs
4trailofbits avatargh-clitrailofbits/skillsEnforces authenticated gh CLI workflows over unauthenticated curl/WebFetch patterns. Use when working with GitHub URLs, API access, pull requests, or issues.7.1Kskills.sh installs
5lijigang avatarljg-paperlijigang/ljg-skillsPaper reader for non-academics. Finds the load-bearing concepts the reader does not yet truly have, rebuilds them through relations and cases, and turns one pap7Kskills.sh installs
6affaan-m avatarcoding-standardsaffaan-m/eccBaseline cross-project coding conventions for naming, readability, immutability, and code-quality review. Use detailed frontend or backend skills for framework-7Kskills.sh installs