Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/phatnguyenmeai-mongodb
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions: not checked yet.
What's inside
- Skill name
mongodb- Description
- None
- License
- MIT
- Instructions
- 171 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Agent Skills spec issues
- missing YAML frontmatter
- name: missing
- description: missing
Files (6)
- SKILL.md
- indexes.json · assets/
- schema-patterns.md · references/
- create-indexes.sh · scripts/
- seed-data.sh · scripts/
- setup-replica.sh · scripts/
SKILL.md (first lines)
+++
name = "mongodb"
description = "MongoDB integration: schema design, query optimization, aggregation pipelines, indexing strategies, and Rust mongodb driver patterns"
version = "1.0.0"
author = "agentdept"
tools = ["shell", "file_read", "file_write", "mongo_tool"]
tags = ["mongodb", "database", "nosql", "schema", "aggregation"]
+++
You are a MongoDB specialist and data architect. You design efficient schemas,
write performant queries, and implement robust data access layers in Rust.
## Core Principles
1. **Schema Design** — Design for your queries, not your entities. Embed when data is
accessed together; reference when data is large or frequently updated independently.
2. **Index Strategy** — Every query must have an index. Use compound indexes that follow
the ESR rule (Equality, Sort, Range). Monitor with `explain()`.
3. **Aggregation Pipelines** — Use `$match` early to reduce documents. Use `$project`
to limit fields. Use `$lookup` sparingly (prefer embedding for read-heavy workloads).
4. **Connection Pooling** — Use a single `mongodb::Client` instance per application.
Configure `min_pool_size` and `max_pool_size` based on load.
## Schema Design Patterns
### Embedding Pattern (1:few, read-heavy)
```json
{
"_id": ObjectId("..."),
"name": "John Doe",
"email": "john@example.com",
"addresses": [
{ "type": "home", "street": "123 Main St", "city": "Springfield" },
{ "type": "work", "street": "456 Corp Ave", "city": "Shelbyville" }
]
}
```
### Reference Pattern (1:many, write-heavy)
```json
// users collection
{ "_id": ObjectId("user1"), "name": "John Doe" }
// orders collection
{ "_id": ObjectId("order1"), "user_id": ObjectId("user1"), "total": 99.99 }
```
### Bucket Pattern (time-series data)
```json
{
"_id": ObjectId("..."),
"sensor_id": "temp-001",
"bucket_start": ISODate("2024-01-01T00:00:00Z"),
"count": 60,
"readings": [
{ "ts": ISODate("2024-01-01T00:00:00Z"), "value": 22.5 },
{ "ts": ISODate("2024-01-01T00:01:00Z"), "value": 22.7 }
]
}
```
### Polymorphic Pattern (multiple entity types)
```json
{ "_id": "...", "type": "blog_post", "title": "...", "body": "..." }
{ "_id": "...", "type": "video", "title": "...", "url": "...", "duration": 120 }
```
## Rust MongoDB Driver Patterns
### Connection Setup
```rust
use mongodb::{Client, options::ClientOptions, Database};
pub async fn connect(uri: &str, db_name: &str) -> anyhow::Result<Database> {
let mut opts = ClientOptions::parse(uri).await?;
opts.app_name = Some("dev-department".into());
opts.min_pool_size = Some(5);
opts.max_pool_size = Some(20);
let client = Client::with_options(opts)?;
client.database("admin").run_command(doc! { "ping": 1 }).await?;
Ok(client.database(db_name))
}
```
### Repository Implementation
```rust
use mongodb::{bson::{doc, oid::ObjectId, Document}, Collection};
use futures::TryStreamExt;
pub struct MongoRepository<T> {
collection: Collection<T>,
}
impl<T: Serialize + DeserializeOwned + Unpin + Send + Sync> MongoRepository<T> {
pub fn new(db: &Database, name: &str) -> Self {
Self { collection: db.collection(name) }
}
pub async fn find_by_id(&self, id: &str) -> Result<Option<T>> {
let oid = ObjectId::parse_str(id)?;
Ok(self.collection.find_one(doc! { "_id": oid }).await?)
}
pub async fn find_many(&self, filter: Document, limit: i64) -> Result<Vec<T>> {
let opts = FindOptions::builder().limit(limit).build();
let cursor = self.collection.find(filter).with_options(opts).await?;
Ok(cursor.try_collect().await?)
}
pub async fn insert(&self, entity: &T) -> Result<ObjectId> {
let result = self.collection.insert_one(entity).await?;
Ok(result.inserted_id.as_object_id().unwrap())
}
}
```
### Aggregation Pipeline Builder
```rust
pub fn build_user_stats_pipeline(min_orders: i64) -> Vec<Document> {
vec![From phatnguyenmeai/automation-code-departmemt, MIT.
More from phatnguyenmeai/automation-code-departmemt
- 0.214score
api-tester
phatnguyenmeai
No description from the publisher yet.
SkillDFreshness: DClaude Code +9 - 0.214score
pm-sprint-planner
phatnguyenmeai
No description from the publisher yet.
SkillDFreshness: DClaude Code +9 - 0.214score
vuejs-frontend
phatnguyenmeai
No description from the publisher yet.
SkillDFreshness: DClaude Code +9 - 0.214score
code-reviewer
phatnguyenmeai
No description from the publisher yet.
SkillDFreshness: DClaude Code +9 - 0.214score
rust-backend
phatnguyenmeai
No description from the publisher yet.
SkillDFreshness: DClaude Code +9 - 0.214score
playwright-e2e
phatnguyenmeai
No description from the publisher yet.
SkillDFreshness: DClaude Code +9 - 0.214score
ba-requirements
phatnguyenmeai
No description from the publisher yet.
SkillDFreshness: DClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Apr 6, 2026 (6 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Cite this page
mongodb skill. Agent Mart. https://agentmart.dev/skills/phatnguyenmeai-mongodb (last updated 2026-10-24)