TerminalSkills/skills

mongodb

Assists with designing document schemas, building aggregation pipelines, managing indexes, and operating MongoDB clusters.

View source

How to use

  1. Copy the installation command and review the source package before installing it in your own agent environment.
  2. Check the source document for required tools, credentials and supported hosts.
  3. Describe your input and desired deliverable; review the output against the source material.
npx skills add https://github.com/TerminalSkills/skills --skill mongodb

Before you start

  • Installation does not include a model subscription, API allowance or permission to access your files.
  • Repository stars and installation counts describe activity, not an independent quality or security test.
Original skill document

Rendered from the source repository. Headings, examples, code, tables, links, and referenced images are preserved.

MongoDB

Overview

MongoDB is a document database that stores JSON-like (BSON) documents with flexible schemas, nested objects, and arrays. It provides a rich query language, aggregation pipelines for data transformation, multiple index types (text, TTL, wildcard, geospatial), ACID transactions, and horizontal scaling via sharding. MongoDB Atlas adds managed cloud hosting with full-text search ($search) and vector search ($vectorSearch); those two stages are Atlas features and are not part of a plain mongod.

Instructions

  • When designing schemas, embed data that is read together and reference data that is shared across documents, optimizing for read patterns rather than normalization since MongoDB penalizes joins ($lookup).
  • When querying, use dot notation for nested fields, array operators ($in, $elemMatch, $all) for array queries, and projection to return only needed fields.
  • When transforming data, use aggregation pipelines with stages like $match, $group, $project, $lookup, and $unwind rather than pulling data to application code for processing.
  • When creating indexes, add indexes for every production query pattern, use explain("executionStats") to verify usage, and choose TTL indexes for auto-expiring data like sessions and logs.
  • When enforcing data integrity, use JSON Schema validation on collections (db.createCollection(name, { validator: { $jsonSchema: {...} } }); a violating insert fails with DocumentValidationFailure), and use multi-document transactions only when atomicity across documents is required. Transactions need a replica set or sharded cluster, not a standalone server. Since MongoDB 5.0 the implicit write concern is majority for most deployments, so you only set it explicitly to override a changed default.
  • When scaling, choose shard keys with high cardinality and even distribution, set up replica sets for high availability, and configure read preferences based on consistency requirements. A shard key can be changed later with reshardCollection (MongoDB 5.0+), which rewrites the collection in the background, so it is possible but expensive.
  • Store money as Decimal128 (NumberDecimal("89.90") in mongosh), not doubles.
bash
mongosh "mongodb://localhost:27017/shop" --eval 'db.products.getIndexes()'

A multi-document transaction in mongosh (replica set required; verified on 8.2.6):

javascript
const session = db.getMongo().startSession()
const shop = session.getDatabase("shop")
session.startTransaction({ writeConcern: { w: "majority" } })
shop.orders.insertOne({ sku: "KB-1", qty: 1 })
shop.products.updateOne({ sku: "KB-1" }, { $inc: { stock: -1 } })
session.commitTransaction()   // or session.abortTransaction()

Examples

Example 1: Build an e-commerce product catalog

User request: "Design a MongoDB schema for products with variants, reviews, and categories"

Actions:

  1. Embed variants and pricing as arrays within the product document for single-query reads
  2. Reference categories as ObjectIds for shared data and embed review summaries
  3. Create compound indexes for filtering by category, price range, and rating
  4. Build aggregation pipeline for faceted search with $facet and $bucket
javascript
// mongosh: validated collection, compound index, facets
db.createCollection("products", { validator: { $jsonSchema: {
  bsonType: "object", required: ["sku", "price"],
  properties: { sku: { bsonType: "string" }, price: { bsonType: "decimal" } } } } })
db.products.createIndex({ category: 1, price: 1, rating: -1 })
db.products.find({ category: "keyboards", price: { $lt: NumberDecimal("100") } })
  .explain("executionStats")       // winning plan should be IXSCAN, not COLLSCAN
db.products.aggregate([{ $facet: {
  byCategory: [{ $group: { _id: "$category", n: { $sum: 1 } } }],
  priceBands: [{ $bucket: { groupBy: "$price",
    boundaries: [NumberDecimal("0"), NumberDecimal("50"), NumberDecimal("100"), NumberDecimal("200")], default: "other",
    output: { n: { $sum: 1 } } } }]
} }])

Output: A product catalog with embedded variants, referenced categories, faceted search, and optimized indexes.

Example 2: Set up full-text search with Atlas Search

User request: "Add search functionality to my app using MongoDB Atlas Search"

Actions:

  1. Create an Atlas Search index with analyzers for the title, description, and tags fields
  2. Build a $search aggregation stage with fuzzy matching and highlighting
  3. Add autocomplete search with the autocomplete data type
  4. Implement relevance scoring and boosting for title matches

Note: $search only runs on Atlas (or a deployment with Atlas Search enabled); on a local mongod use a text index and $text instead.

Output: A search feature with fuzzy matching, autocomplete, relevance ranking, and highlighting.

Guidelines

  • Embed when data is read together; reference when data is shared across documents.
  • Design schemas for your query patterns, not for normalization.
  • Create indexes for every production query pattern and verify with explain().
  • Use TTL indexes for session data, logs, and temporary documents for automatic cleanup.
  • Use aggregation pipelines instead of pulling data to application code for transformation.
  • Rely on the default majority write concern for data that must survive failover; never lower it for critical writes.
  • Choose shard keys carefully: resharding with reshardCollection works (5.0+) but moves all the data.
  • Keep transactions short; they need a replica set and hold resources until commit.
  • Do not expose mongod on a public interface without authentication and TLS.
from this repository

More skills

All skills
TerminalSkills
Community

3dsmax-rendering

Scripts and configures production rendering in Autodesk 3ds Max with the V-Ray and Corona renderers: output size and files, render elements, denoising, light mix, batch and command-line rendering, and network rendering. Use when a user asks to set up a production render, render several cameras in one batch, render from the command line or on a render farm, add render passes for compositing, or cut render time for archviz and product shots.

installs
0
GitHub stars
180
Updated
Oct 25
TerminalSkills
Community

3dsmax-scripting

Covers scripting Autodesk 3ds Max, the 3D modeling and rendering application, with MAXScript and Python (pymxs): scene manipulation, object creation, material assignment, camera and light setup, batch operations, and file I/O. Use when tasks involve automating repetitive 3ds Max workflows, batch processing scenes, running scripts headless with 3dsmaxbatch, creating custom tools, or scripting scene setup for archviz, product visualization, or VFX.

installs
0
GitHub stars
180
Updated
Oct 25
TerminalSkills
Community

3proxy

3proxy is a small open-source proxy server that runs HTTP/HTTPS, SOCKS4/5, SNI and TCP/UDP port-mapping proxies from one config file. Use when a user asks to set up an HTTP or SOCKS5 proxy, add proxy users and passwords, write 3proxy access rules, chain or rotate upstream (parent) proxies, limit bandwidth, connections or monthly traffic per user, run 3proxy in Docker, or fix a 3proxy.cfg that will not start.

installs
0
GitHub stars
180
Updated
Oct 25
TerminalSkills
Community

a2a-protocol

Builds Agent2Agent (A2A) servers and clients, the open protocol (originally from Google, now under the Linux Foundation) that lets AI agents from different frameworks call each other. Use when the user wants to create an A2A-compliant agent, build an Agent Card, implement task management, connect agents across frameworks, set up agent discovery, handle streaming responses, implement push notifications, or orchestrate multi-agent workflows. Trigger words: a2a, agent to agent, agent2agent, a2a pro

installs
0
GitHub stars
180
Updated
Oct 25