mongodb-usage
MongoDB Best Practices
MCP Limitation
This MCP operates in READ-ONLY mode. No write, update, or delete operations are possible.
Schema Design Patterns
Embedding vs Referencing
Embed when:
- Data is accessed together frequently
- Child documents are bounded (won't grow unbounded)
- One-to-few relationships
- Data doesn't change frequently
Reference when:
- Data is accessed independently
- Many-to-many relationships
- Documents would exceed 16MB limit
- Frequent updates to referenced data
Common Patterns
Subset pattern: Store frequently accessed subset in parent, full data in separate collection.
Bucket pattern: Group time-series data into buckets (e.g., hourly readings in one document).
Computed pattern: Store pre-computed values for expensive calculations.
Index Strategies
Index Guidelines
- Index fields used in queries, sorts, and aggregation $match stages
- Compound indexes support queries on prefix fields
- Covered queries (all fields in index) are fastest
- Too many indexes slow writes
Index Types
- Single field: Basic index on one field
- Compound: Multiple fields, order matters for queries
- Multikey: Automatically created for array fields
- Text: Full-text search on string content
- TTL: Auto-expire documents after time period
ESR Rule
For compound indexes, order fields by:
- Equality (exact match fields)
- Sort (sort order fields)
- Range (range query fields like $gt, $lt)
Aggregation Pipeline
Performance Tips
- Put
$matchand$projectearly to reduce documents - Use
$limitearly when possible - Avoid
$lookupon large collections without indexes - Use
$facetfor multiple aggregations in one query
Common Stages
// Filter documents
{ $match: { status: "active" } }
// Reshape documents
{ $project: { name: 1, total: { $sum: "$items.price" } } }
// Group and aggregate
{ $group: { _id: "$category", count: { $sum: 1 } } }
// Sort results
{ $sort: { count: -1 } }
// Join collections
{ $lookup: { from: "orders", localField: "_id", foreignField: "userId", as: "orders" } }
Connection Best Practices
Connection String Formats
- Atlas:
mongodb+srv://user:pass@cluster.mongodb.net/database - Local:
mongodb://localhost:27017/database - Replica set:
mongodb://host1,host2,host3/database?replicaSet=rs0
Connection Pooling
- Use connection pooling in applications (default in drivers)
- Set appropriate pool size for your workload
- Don't create new connections per request
Anti-Patterns to Avoid
- Unbounded arrays: Arrays that grow without limit
- Massive documents: Documents approaching 16MB
- Too many collections: Use embedding instead
- Missing indexes: Queries doing collection scans
- $where operator: Use aggregation instead for security
- Storing files in documents: Use GridFS for large files
More from fcakyon/claude-codex-settings
gcloud-usage
This skill should be used when user asks about "GCloud logs", "Cloud Logging queries", "Google Cloud metrics", "GCP observability", "trace analysis", or "debugging production issues on GCP".
62azure-usage
This skill should be used when user asks to "query Azure resources", "list storage accounts", "manage Key Vault secrets", "work with Cosmos DB", "check AKS clusters", "use Azure MCP", or interact with any Azure service.
48commit-workflow
This skill should be used when user asks to "commit these changes", "write commit message", "stage and commit", "create a commit", "commit staged files", or runs /commit-staged or /commit-creator commands.
45supabase-usage
This skill should be used when user asks to "query Supabase", "list Supabase tables", "get Supabase schema", "search Supabase records", "check Supabase database", "Supabase auth", "Supabase authentication", "RLS policy", "row level security", "Supabase foreign key", "table relationships", "Supabase join", "Supabase filter", "Supabase pagination", or needs guidance on Supabase database patterns, auth flows, RLS policies, or query best practices.
37agent-development
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
33mcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context Protocol", "connect external service", mentions "${CLAUDE_PLUGIN_ROOT} with MCP", or discusses MCP server types (SSE, stdio, HTTP, WebSocket). Provides comprehensive guidance for integrating Model Context Protocol servers into Claude Code plugins for external tool and service integration.
31