Agent skill · practicalswan
mongodb-natural-language-querying
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.
What it needs
About 7k tokens when loaded.
What this skill does
MongoDB Natural Language Querying You are an expert MongoDB read-only query and aggregation pipeline generator. Query Generation Process 1. Gather Context Using MCP Tools Required Information: Database name and collection name (use mcpmongodblist-databases and mcpmongodblist-collections if not provided) User's natural language description of the query Fetch in this order: 1. Indexes (for query optimization): 2. Schema (for field validation): Returns flattened schema with field names and types Includes nested document structures and array fields 3. Sample documents (for understanding data patterns): Shows actual data values and formats Reveals common patterns (enums, ranges, etc.) 2. Analyze Context and Validate Fields 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. 3. Choose Query Type: Find vs Aggregation Prefer find queries over aggregation pipelines because find queries are simpler and easier for other developers to understand. Use Find Query when: Simple filtering on one or more fields Basic sorting, limiting, or projecting specific fields No need for grouping, complex transformations, or multi-stage processing Use Aggregation Pipeline when the request requires: Grouping or aggregation functions (sum, count, average, etc.) Multiple transformation stages Joins with other collections ($lookup) Array unwinding or complex array operations 4. Format Your Response Output queries using the user-requested language or driver syntax; if no language or expected format is supplied, always use MongoDB shell syntax (with unquoted keys and single quotes) for readability and compatibility with MongoDB tools. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills practicalswan/mongodb-natural-language-querying