/db-mongodb:mongodb-codingfrom db-mongodb
Use when writing or reviewing MongoDB code — enforces document design patterns (embed vs reference), schema validation, aggregation pipelines, indexing strategies (ESR rule), change streams, transactions, and security best practices
Ships in db-mongodb. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
orders, orderItems, userSessions, auditLogs| Pattern | Use When | Example |
|---|---|---|
| Embed (subdocument) | 1:1 or 1:few, data always read together | Order → items array |
| Reference (ObjectId) | 1:many, many:many, data read independently | Order → customerId ref |
| Bucket | Time-series, high-volume events | Group events by hour/day |
| Outlier | Mostly small arrays, rare large ones | Most users have <10 addresses |
// Single collection for polymorphic types
{ type: "creditCard", cardNumber: "****1234", expiry: "12/26" }
{ type: "bankTransfer", accountNumber: "****5678", routingNumber: "****9012" }
additionalProperties: false cautiously (breaks additive migrations)db.orders.aggregate([
{ $match: { status: { $in: ["confirmed", "shipped"] } } },
{ $unwind: "$items" },
{ $group: {
_id: "$items.productId",
totalQuantity: { $sum: "$items.quantity" },
totalRevenue: { $sum: { $multiply: ["$items.price", "$items.quantity"] } }
}},
{ $sort: { totalRevenue: -1 } },
{ $limit: 10 }
]);
$match as early as possible to reduce documents in pipeline$project after $match to reduce document size$lookup with let and pipeline for complex joins$group on unindexed fields// Equality, Sort, Range — in that order
db.orders.createIndex({ status: 1, createdAt: -1, total: 1 });
db.products.createIndex({ name: "text", description: "text" });
db.sessions.createIndex({ expiresAt: 1 }, { expireAfterSeconds: 0 });
const session = client.startSession();
try {
session.startTransaction();
await orders.insertOne(order, { session });
await inventory.updateOne(
{ productId: order.items[0].productId },
{ $inc: { quantity: -order.items[0].quantity } },
{ session }
);
await session.commitTransaction();
} catch (error) {
await session.abortTransaction();
throw error;
} finally {
session.endSession();
}
const changeStream = orders.watch([
{ $match: { operationType: { $in: ["insert", "update"] } } }
]);
changeStream.on("change", (change) => {
console.log("Order changed:", change.documentKey._id);
});
const ops = items.map(item => ({
updateOne: {
filter: { _id: item._id },
update: { $set: { price: item.newPrice } },
upsert: false
}
}));
await collection.bulkWrite(ops, { ordered: false });
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
4 skills in this plugin
/mongodb-frameworksUse when implementing MongoDB code with frameworks — enforces patterns for Mongoose (schemas, middleware, virtuals, populate), Motor (async cursors), MongoDB .NET Driver (BSON, LINQ), and migrate-mongo (migration scripts)/mongodb-project-structureUse when scaffolding or reviewing MongoDB project layout — collection organization, migration script conventions, model/schema file layout, and index definition patterns/mongodb-testingUse when writing tests for MongoDB code — Jest with mongodb-memory-server for Node.js, pytest with mongomock for Python, .NET integration tests with test containers, and seed data managementnpx claudepluginhub gagandeepp/software-agent-teams --plugin db-mongodb