cloudthinker-ai/cloudskills/analyzing-mongodb
Claude Code and agent skill by cloudthinker-ai/cloudskills
- community
Checking that the SKILL.md file is still in the repository.
Use when working with Mongodb — mongoDB database analysis, performance tuning, query optimization, and health monitoring. Covers collection analysis, index recommendations, aggregation pipelines, replica set health, Atlas cluster management, and slow query investigation.
Install
npx vskill@latest install cloudthinker-ai/cloudskills/analyzing-mongodbSKILL.md
The same SKILL.md was published earlier as cloudthinker-ai/cloudskills/analyzing-mongodb.
MongoDB Analysis Skill
Analyze and optimize MongoDB databases with safe, read-only operations.
MANDATORY: Two-Phase Execution
You MUST follow this two-phase pattern. Skipping Phase 1 causes hallucinated collection names and schema errors.
Phase 1: Discovery (ALWAYS run first)
Phase 1 outputs:
- List of databases and sizes
- List of collections with document counts
- Sample documents to understand actual field names
Phase 2: Analysis (only after Phase 1)
Only reference collections, databases, and field names confirmed in Phase 1.
Shell Script Patterns
Helper Function
Anti-Hallucination Rules
- NEVER reference a collection by name without confirming it exists via
db.getCollectionNames() - NEVER reference a field name in queries without seeing it in a sample document
- NEVER assume index names — always list indexes via
db.collection.getIndexes() - NEVER assume Atlas cluster names — always run
atlas clusters listfirst - ALWAYS use `--quiet` flag with mongosh to suppress connection banners
Safety Rules
- READ-ONLY ONLY: Use only find, aggregate, explain, stats, currentOp, serverStatus
- FORBIDDEN: insertMany, updateMany, deleteMany, drop, dropDatabase, createIndex without explicit user request
- ALWAYS add `.limit()` to find queries — default cap at 100 documents
- NEVER run
db.collection.find()without a limit on large collections - Use explain() before running expensive aggregations on large collections
Common Operations
Database Health Overview
Collection Analysis
Slow Query Analysis
Index Effectiveness Analysis
Query Performance with explain()
Atlas Cluster Management (if Atlas connection)
Aggregation Pipeline Examples
Output Format
Present results as a structured report:
Target ≤50 lines of output. Use tables for multi-resource comparisons.
Counter-Rationalizations
| Shortcut | Counter | Why | |
|---|---|---|---|
| "I'll skip discovery and check known resources" | Always run Phase 1 discovery first | Resource names change, new resources appear — assumed names cause errors | |
| "The user only asked for a quick check" | Follow the full discovery → analysis flow | Quick checks miss critical issues; structured analysis catches silent failures | |
| "Default configuration is probably fine" | Audit configuration explicitly | Defaults often leave logging, security, and optimization features disabled | |
| "Metrics aren't needed for this" | Always check relevant metrics when available | API/CLI responses show current state; metrics reveal trends and intermittent issues | |
| "I don't have access to that" | Try the command and report the actual error | Assumed permission failures prevent useful investigation; actual errors are informative |
Common Pitfalls
- Schema assumptions: MongoDB is schema-flexible — never assume field names without sampling documents
- Missing `--quiet`: Without
--quiet, mongosh outputs connection banners that corrupt script output - Large `.find()` without limit: Always add
.limit(N)— collections can have millions of documents - `explain()` on production: Use
explain('queryPlanner')for plan-only (no execution);explain('executionStats')runs the query - Replica set reads: Prefer
readPreference: 'secondaryPreferred'for analytics to avoid impacting primary - Aggregation memory: Default 100MB memory limit per stage — add
{ allowDiskUse: true }for large aggregations - Timezone handling: ISODate stores in UTC — always convert user-specified times to UTC before querying
- Atlas vs self-hosted: Atlas has different metric APIs than
db.serverStatus()— check connection type in Phase 1
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/connections/analyzing-mongodb/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/cloudthinker-ai/cloudskills/analyzing-mongodb)