agentsclimarketplace

Mongodb query builder

Skill hoqo/claude-plugins/plugins/mongodb/skills/mongodb-query-builder

Claude Code plugins & skills

Install
npx -y skills add hoqo/claude-plugins --skill mongodb-query-builder

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Build and optimize MongoDB queries, aggregation pipelines, and CRUD operations. Use when the user asks to query data, filter documents, join collections, aggregate results, update documents, or work with MongoDB data in any way.

SKILL.md

3.9 KB, ~1.0k tokens by cl100k_base, as published. Nobody here has run it

MongoDB Query Builder

You are an expert MongoDB query builder. When asked to work with MongoDB data, build efficient queries following these guidelines.

Query Building Process

  1. Understand the data model: Ask about or infer the collection schema
  2. Choose the right operation: find, aggregate, updateOne/Many, deleteOne/Many
  3. Build incrementally: Start simple, add stages/operators as needed
  4. Optimize: Use indexes, avoid full collection scans, limit results

Aggregation Pipeline Stages Reference

StagePurposeExample
$matchFilter documents{ $match: { status: "active" } }
$groupGroup and aggregate{ $group: { _id: "$category", total: { $sum: "$price" } } }
$lookupJoin collections{ $lookup: { from: "orders", localField: "_id", foreignField: "userId", as: "orders" } }
$projectReshape documents{ $project: { name: 1, total: { $multiply: ["$price", "$qty"] } } }
$sortOrder results{ $sort: { createdAt: -1 } }
$limitCap output{ $limit: 20 }
$unwindFlatten arrays{ $unwind: "$tags" }
$addFieldsAdd computed fields{ $addFields: { fullName: { $concat: ["$first", " ", "$last"] } } }
$facetMultiple pipelines{ $facet: { byStatus: [...], byDate: [...] } }
$bucketRange grouping{ $bucket: { groupBy: "$price", boundaries: [0, 50, 100, 500] } }
$outReplace collection with results{ $out: "reports" }
$mergeMerge results into collection{ $merge: { into: "reports" } }

Common Operators

Comparison: $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin Logical: $and, $or, $not, $nor Array: $all, $elemMatch, $size, $push, $pull, $addToSet String: $regex, $text, $concat, $substr, $toLower, $toUpper Date: $dateToString, $year, $month, $dayOfMonth, $dateFromString

Pattern: Join with $lookup

// Simple join
db.orders.aggregate([
  {
    $lookup: {
      from: "customers",
      localField: "customerId",
      foreignField: "_id",
      as: "customer"
    }
  },
  { $unwind: "$customer" }
])

// Correlated subquery join (more powerful)
db.orders.aggregate([
  {
    $lookup: {
      from: "products",
      let: { items: "$lineItems" },
      pipeline: [
        { $match: { $expr: { $in: ["$_id", "$$items"] } } },
        { $project: { name: 1, price: 1 } }
      ],
      as: "products"
    }
  }
])

Pattern: Pagination

// Offset-based (simple but slow for large offsets)
db.collection.find(query).sort({ _id: 1 }).skip(page * size).limit(size)

// Cursor-based (efficient for large datasets)
db.collection.find({ _id: { $gt: lastSeenId } }).sort({ _id: 1 }).limit(size)

Pattern: Full-text Search

// Create text index first
db.articles.createIndex({ title: "text", body: "text" })

// Search
db.articles.find(
  { $text: { $search: "mongodb aggregation" } },
  { score: { $meta: "textScore" } }
).sort({ score: { $meta: "textScore" } })

Pattern: Transactions

const session = db.getMongo().startSession()
session.startTransaction()
try {
  db.accounts.updateOne({ _id: from }, { $inc: { balance: -amount } }, { session })
  db.accounts.updateOne({ _id: to }, { $inc: { balance: amount } }, { session })
  session.commitTransaction()
} catch (e) {
  session.abortTransaction()
  throw e
}

Execution

Always execute queries via mongosh:

mongosh "$MONGODB_URI" --quiet --eval "<query>"

See examples/ for more complete query patterns.

What ships with it: 1 file

1.9 KB alongside SKILL.md

examples/

Keep looking

Skills are one crate of 327,069. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.