# mongodb

A skill that walks your agent through MongoDB and Mongoose: schema design, queries, indexes and update operators.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 1700 installs · ★ 291
- Author: hoodini
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/hoodini/ai-agents-skills/tree/HEAD/skills/mongodb/SKILL.md
- Updated: 2026-10-23
- HTML: https://affpapa.org/en/nevibecode/skills/mongodb

## What it does

The skill loads into your agent and supplies working TypeScript examples for MongoDB. Native driver setup covers `MongoClient`, `client.db()` and basic CRUD. The Mongoose part shows `mongoose.connect` with pool size and timeouts, connection event handlers, and closing the connection on `SIGINT`.

Schema design gets its own section: required fields, `enum`, `select: false` on passwords, `timestamps`, and indexes including compound and text. There is a clear split between embedding documents and referencing them with `ObjectId` plus `populate`, and virtuals for reverse references. Query operators follow — `$gt`, `$in`, `$and`, `$or`, `$exists`, `$size`, `$text`, `$regex` — along with updates like `$set`, `$unset`, `$inc` and `$mul`.

You need the packages installed first: `npm install mongodb mongoose`. The examples read the connection string from `MONGODB_URI`, so a project without that variable will need edits before anything runs. The skill text stops partway through the update operators, at `$min` — past that point your agent is on its own.

## Requirements
- Works with: MongoDB

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add hoodini/ai-agents-skills --skill mongodb -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/mongodb/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/mongodb/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add hoodini/ai-agents-skills --skill mongodb -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/mongodb/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add hoodini/ai-agents-skills --skill mongodb -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/mongodb/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install hoodini/ai-agents-skills mongodb
```

2. **Manually: put the files in place**
- File: `.github/skills/mongodb/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add hoodini/ai-agents-skills --skill mongodb -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/hoodini/ai-agents-skills --path skills/mongodb
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/mongodb/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add hoodini/ai-agents-skills --skill mongodb -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/hoodini/ai-agents-skills/tree/HEAD/skills/mongodb/SKILL.md

## When to use it
- design a Mongoose schema with validation and indexes
- decide between embedding a document and referencing it
- write a query with comparison and logical operators
- populate nested references with selected fields
- set up connection pooling and graceful shutdown

## Example prompts
- Help me design a Mongoose User schema with indexes and a hidden password field
- Write a query using $or and $gte on createdAt
- How do I populate the author and comments on a Post?

## Similar
- [mongodb-development](https://affpapa.org/en/nevibecode/skills/mongodb-development.md) — skill · 891 installs
- [mongodb-connection](https://affpapa.org/en/nevibecode/skills/mongodb-connection.md) — skill · 5200 installs
- [nosql-database-design](https://affpapa.org/en/nevibecode/skills/nosql-database-design.md) — skill · 486 installs
- [database-management-patterns](https://affpapa.org/en/nevibecode/skills/database-management-patterns.md) — skill · 466 installs
- [prisma-mongodb-upgrade](https://affpapa.org/en/nevibecode/skills/prisma-mongodb-upgrade.md) — skill · 370400 installs
- [mongodb-query-optimizer](https://affpapa.org/en/nevibecode/skills/mongodb-query-optimizer.md) — skill · 7000 installs

## Other versions with the same name
- [mongodb · bagelhole](https://affpapa.org/en/nevibecode/skills/devops-skills-mongodb.md) — 339 installs

From the same set: [hoodini/ai-agents-skills](https://affpapa.org/en/nevibecode/by/hoodini/ai-agents-skills.md) — 5 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
