Developing with MongoDB
The agent implements MongoDB NoSQL database solutions with document modeling, aggregation pipelines, and Mongoose ODM. Use when building document-based applications, designing schemas, writing aggregations, or implementing NoSQL patterns.
Best use case
Developing with MongoDB is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
The agent implements MongoDB NoSQL database solutions with document modeling, aggregation pipelines, and Mongoose ODM. Use when building document-based applications, designing schemas, writing aggregations, or implementing NoSQL patterns.
Teams using Developing with MongoDB should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/developing-with-mongodb/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How Developing with MongoDB Compares
| Feature / Agent | Developing with MongoDB | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
The agent implements MongoDB NoSQL database solutions with document modeling, aggregation pipelines, and Mongoose ODM. Use when building document-based applications, designing schemas, writing aggregations, or implementing NoSQL patterns.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Developing with MongoDB
## Quick Start
```typescript
// Schema with Mongoose
import mongoose, { Schema, Document } from 'mongoose';
interface IUser extends Document {
email: string;
profile: { firstName: string; lastName: string };
createdAt: Date;
}
const userSchema = new Schema<IUser>({
email: { type: String, required: true, unique: true, lowercase: true },
profile: {
firstName: { type: String, required: true },
lastName: { type: String, required: true },
},
}, { timestamps: true });
userSchema.index({ email: 1 });
export const User = mongoose.model<IUser>('User', userSchema);
```
## Features
| Feature | Description | Guide |
|---------|-------------|-------|
| Document Schema | Type-safe schema design with Mongoose | Embed related data, use references for large collections |
| CRUD Operations | Create, read, update, delete with type safety | Use `findById`, `findOne`, `updateOne`, `deleteOne` |
| Aggregation Pipelines | Complex data transformations and analytics | Chain `$match`, `$group`, `$lookup`, `$project` stages |
| Indexing | Query optimization with proper indexes | Create compound indexes matching query patterns |
| Transactions | Multi-document ACID operations | Use sessions for operations requiring atomicity |
| Change Streams | Real-time data change notifications | Watch collections for inserts, updates, deletes |
## Common Patterns
### Repository Pattern with Pagination
```typescript
async findPaginated(filter: FilterQuery<IUser>, page = 1, limit = 20) {
const [data, total] = await Promise.all([
User.find(filter).sort({ createdAt: -1 }).skip((page - 1) * limit).limit(limit),
User.countDocuments(filter),
]);
return { data, pagination: { page, limit, total, totalPages: Math.ceil(total / limit) } };
}
```
### Aggregation Pipeline
```typescript
const stats = await Order.aggregate([
{ $match: { status: 'completed', createdAt: { $gte: startDate } } },
{ $group: { _id: '$userId', total: { $sum: '$amount' }, count: { $sum: 1 } } },
{ $sort: { total: -1 } },
{ $limit: 10 },
]);
```
### Transaction for Order Creation
```typescript
const session = await mongoose.startSession();
try {
session.startTransaction();
await Product.updateOne({ _id: productId }, { $inc: { stock: -quantity } }, { session });
const order = await Order.create([{ userId, items, total }], { session });
await session.commitTransaction();
return order[0];
} catch (error) {
await session.abortTransaction();
throw error;
} finally {
session.endSession();
}
```
## Best Practices
| Do | Avoid |
|----|-------|
| Design schemas based on query patterns | Embedding large arrays in documents |
| Create indexes for frequently queried fields | Using `$where` or mapReduce in production |
| Use `lean()` for read-only queries | Skipping validation on writes |
| Implement pagination for large datasets | Storing large files directly (use GridFS) |
| Set connection pool size appropriately | Hardcoding connection strings |
| Use transactions for multi-document ops | Ignoring index usage in explain plans |
| Add TTL indexes for expiring data | Creating too many indexes (write overhead) |Related Skills
developing-with-python
Python 3.11+ development with type hints, async patterns, FastAPI, and pytest. Use for backend services, CLI tools, data processing, and API development.
developing-python
Modern Python development guide covering project setup, tooling, and 125 Pythonic best practices. MUST load when pyproject.toml or requirements.txt is detected. Covers Python 3.13 + uv + ruff + mypy, FastAPI/FastMCP, pytest, Docker, and Effective Python items (idioms, data structures, concurrency, testing).
developing-frontend-apps
Frontend application development best practices. Use when building, modifying, or reviewing frontend applications, React components, UI components, client-side JavaScript/TypeScript, CSS/styling, single-page applications, or web application architecture.
developing-claude-agent-sdk-agents
Build AI agents with the Claude Agent SDK (TypeScript/Python). Covers creating agents, custom tools, hooks, subagents, MCP integration, permissions, sessions, and deployment. Use when building, reviewing, debugging, or deploying SDK-based agents. Invoke PROACTIVELY when user mentions Agent SDK, claude-agent-sdk, ClaudeSDKClient, query(), or building autonomous agents.
developing-backend-services
Backend service development best practices. Use when designing, building, or reviewing backend services, REST APIs, gRPC services, microservices, webhooks, message queues, or server-side applications regardless of language or framework.
mongodb-schema-design
Master MongoDB schema design and data modeling patterns. Learn embedding vs referencing, relationships, normalization, and schema evolution. Use when designing databases, normalizing data, or optimizing queries.
mongodb-expert
Expert-level MongoDB database design, aggregation pipelines, indexing, replication, and production operations
agent-developing-agents
AI agent development standards including frontmatter structure, naming conventions, tool access patterns, model selection, and Bash-only file operations for .opencode/ folders
mongodb_usage
This skill should be used when user asks to "query MongoDB", "show database collections", "get collection schema", "list MongoDB databases", "search records in MongoDB", or "check database indexes".
mongodb
MongoDB - NoSQL document database with flexible schema design, aggregation pipelines, indexing strategies, and Spring Data integration
azure-mgmt-mongodbatlas-dotnet
Manage MongoDB Atlas Organizations as Azure ARM resources using Azure.ResourceManager.MongoDBAtlas SDK. Use when creating, updating, listing, or deleting MongoDB Atlas organizations through Azure M...
developing-langgraph-js-agents
Build, audit, review, and update LangGraph.js agents. Use PROACTIVELY when working with LangGraph, @langchain/langgraph, agent graphs, state machines, or AI workflows in TypeScript/JavaScript. Covers creating new agents, adding features, debugging, testing, and optimizing. (user)