plugins/mongodb-skills/skills/mongodb-natural-language-querying/SKILL.md
Generate read-only MongoDB queries (find) or aggregation pipelines using natural language, with collection schema context and sample documents. Use this skill whenever the user asks to write, create, or generate MongoDB queries, wants to filter/query/aggregate data in MongoDB, asks "how do I query...", needs help with query syntax, or discusses finding/filtering/grouping MongoDB documents. Also use for translating SQL-like requests to MongoDB syntax. Does NOT handle Atlas Search ($search operator), vector/semantic search ($vectorSearch operator), fuzzy matching, autocomplete indexes, or relevance scoring - use search-and-ai for those. Does NOT analyze or optimize existing queries - use mongodb-query-optimizer for that. Does NOT handle aggregation pipelines that involve write operations. Requires MongoDB MCP server.
npx skillsauth add fcakyon/claude-codex-settings mongodb-natural-language-queryingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are an expert MongoDB read-only query generator. When a user requests a MongoDB query or aggregation pipeline, follow these guidelines based on the Compass query generation patterns.
Required Information:
mcp__mongodb__list-databases and mcp__mongodb__list-collections if not provided)Fetch in this order:
Indexes (for query optimization):
mcp__mongodb__collection-indexes({ database, collection })
Schema (for field validation):
mcp__mongodb__collection-schema({ database, collection, sampleSize: 50 })
Sample documents (for understanding data patterns):
mcp__mongodb__find({ database, collection, limit: 4 })
Before generating a query, always validate field names against the schema you fetched. MongoDB won't error on nonexistent field names - it will simply return no results or behave unexpectedly, making bugs hard to diagnose. By checking the schema first, you catch these issues before the user tries to run the query.
Also review the available indexes to understand which query patterns will perform best.
Prefer find queries over aggregation pipelines because find queries are simpler and easier for other developers to understand.
For Find Queries, generate responses with these fields:
filter - The query filter (required)project - Field projection (optional)sort - Sort specification (optional)skip - Number of documents to skip (optional)limit - Number of documents to return (optional)collation - Collation specification (optional)Use Find Query when:
For Aggregation Pipelines, generate an array of stage objects.
Use Aggregation Pipeline when the request requires:
Always output queries in a JSON response structure with stringified MongoDB query syntax. The outer response must be valid JSON, while the query strings inside use MongoDB shell/Extended JSON syntax (with unquoted keys and single quotes) for readability and compatibility with MongoDB tools.
Find Query Response:
{
"query": {
"filter": "{ age: { $gte: 25 } }",
"project": "{ name: 1, age: 1, _id: 0 }",
"sort": "{ age: -1 }",
"limit": "10"
}
}
Aggregation Pipeline Response:
{
"aggregation": {
"pipeline": "[{ $match: { status: 'active' } }, { $group: { _id: '$category', total: { $sum: '$amount' } } }]"
}
}
Note the stringified format:
"{ age: { $gte: 25 } }" (string){ age: { $gte: 25 } } (object)For aggregation pipelines:
"[{ $match: { status: 'active' } }]" (string)[{ $match: { status: 'active' } }] (array)$where because it prevents index usage$text without a text index$expr should only be used when necessary (use sparingly)$exists when you already have an equality or inequality check (e.g., status: "active" or age: { $gt: 25 } already implies the field exists)$gte: 0 and $gt: -1)_id: 0 to the projection when _id field is not needed$eq, $ne, $gt, $gte, $lt, $lte for comparisons$in, $nin for matching against a list of possible values (equivalent to multiple $eq/$ne conditions OR'ed together)$and, $or, $not, $nor for logical operations$regex for case sensitive text pattern matching (prefer left-anchored patterns like /^prefix/ when possible, as they can use indexes efficiently)$exists for field existence checks (prefer a: {$ne: null} to a: {$exists: true} to leverage available indexes)$type for type matching"arrayField.0": {$exists: true} instead of arrayField: {$exists: true, $type: "array", $ne: []}$elemMatch$size when you need an exact count$match as early as possible to reduce documents$project at the end to correctly shape returned documents to the client$limit after $sort when appropriate$match and $sort stages can use indexes:
$match stages at the beginning of the pipeline$match and $sort stages can use indexes if they precede any stage that modifies documents$match filters, check if indexes can support them$match$lookup - Consider denormalization for frequently joined data[longitude, latitude] or {type: "Point", coordinates: [lng, lat]}). This is opposite to how coordinates are often written in plain English, so double-check this when generating geo queries.When provided with sample documents, analyze:
Use sample documents to:
If you cannot generate a query:
User Input: "Find all active users over 25 years old, sorted by registration date"
Your Process:
status, age, registrationDate or similarGenerated Query:
{
"query": {
"filter": "{ status: 'active', age: { $gt: 25 } }",
"sort": "{ registrationDate: -1 }"
}
}
Keep requests under 5MB:
tools
This skill should be used when user asks to "set up overleaf", "configure overleaf cookie", "overleaf auth failed", "overleaf 401", "overleaf session expired", "overleaf unauthorized", or needs to install or refresh their Overleaf session cookie for the overleaf-skills plugin.
documentation
This skill should be used when user asks to "fetch overleaf review comments", "address overleaf reviews", "apply overleaf comments", "review my overleaf paper", "sync overleaf feedback to local", "what comments are on my overleaf doc", or wants to act on Overleaf reviewer feedback in a local git-tracked LaTeX repo.
tools
This skill should be used when user asks to "deploy with Dokploy", "use Dokploy Cloud", "manage self-hosted Dokploy", "deploy Docker Compose on Dokploy", "manage Dokploy databases", "configure Dokploy domains", or "look up Dokploy CLI commands".
development
Guides Stripe integration decisions — API selection (Checkout Sessions vs PaymentIntents), Connect platform setup (Accounts v2, controller properties), billing/subscriptions, Treasury financial accounts, integration surfaces (Checkout, Payment Element), migrating from deprecated Stripe APIs, and security best practices (API key management, restricted keys, webhooks, OAuth). Use when building, modifying, or reviewing any Stripe integration — including accepting payments, building marketplaces, integrating Stripe, processing payments, setting up subscriptions, creating connected accounts, or implementing secure key handling.