home / skills / shipshitdev / library / mongodb-atlas-checker
This skill validates MongoDB Atlas setup for backend apps by checking connection strings, environment variables, and proper configuration patterns.
npx playbooks add skill shipshitdev/library --skill mongodb-atlas-checkerReview the files below or copy the command above to add this skill to your agents.
---
name: mongodb-atlas-checker
description: Verify MongoDB Atlas setup and configuration for backend applications. Checks connection strings, environment variables, connection pooling, and ensures proper setup for Next.js and NestJS applications.
version: 1.0.0
tags:
- mongodb
- atlas
- database
- backend
- nestjs
- nextjs
---
# MongoDB Atlas Checker
Verify MongoDB Atlas setup and configuration. Identifies configuration issues, missing environment variables, incorrect connection strings, and ensures proper database setup.
## When to Use
- Verifying MongoDB Atlas backend setup
- Checking connection string configuration
- Validating environment variable setup
- Troubleshooting database connection issues
- Auditing database setup before deployment
## Quick Checklist
### 1. Environment Variables
- [ ] `MONGODB_URI` exists (not hardcoded)
- [ ] Uses `mongodb+srv://` protocol (required for Atlas)
- [ ] Includes database name
- [ ] Includes `retryWrites=true&w=majority`
- [ ] No credentials in `.env.example`
### 2. Connection String Format
```
mongodb+srv://<username>:<password>@<cluster-host>/<database>?retryWrites=true&w=majority
```
### 3. Driver Installation
- [ ] `mongoose` or `mongodb` package installed
- [ ] In dependencies (not devDependencies)
### 4. Connection Setup
- [ ] Singleton pattern (Next.js)
- [ ] `MongooseModule.forRoot()` (NestJS)
- [ ] Error handling implemented
### 5. Atlas Configuration
- [ ] IP whitelist configured
- [ ] Database user exists with permissions
- [ ] SSL/TLS enabled (default with `mongodb+srv://`)
## Common Issues
| Issue | Solution |
|-------|----------|
| Missing `MONGODB_URI` | Add to `.env.local` or `.env` |
| Wrong protocol | Use `mongodb+srv://` not `mongodb://` |
| Multiple connections (Next.js) | Use singleton pattern |
| Connection timeout | Check IP whitelist in Atlas |
| Auth failed | Verify credentials, URL-encode special chars |
## Recommended Connection Options
```typescript
{
retryWrites: true,
w: 'majority',
maxPoolSize: 10,
serverSelectionTimeoutMS: 5000,
bufferCommands: false,
}
```
---
**For detailed setup patterns, verification scripts, and complete examples:** `references/full-guide.md`
This skill verifies MongoDB Atlas setup and configuration for backend applications. It inspects connection strings, environment variables, driver usage, and framework-specific connection patterns to surface misconfigurations. It helps ensure reliable connections for Next.js and NestJS apps before deployment.
The checker parses environment files and source code to confirm MONGODB_URI exists, follows the mongodb+srv:// format, and includes required options like retryWrites and w=majority. It looks for proper driver installation and dependency placement, validates singleton or framework-specific connection patterns (e.g., Next.js singleton, MongooseModule.forRoot in NestJS), and flags common pitfalls like credentials in example files or missing IP whitelist entries. The tool reports actionable issues and recommends connection options and fixes.
What URI format is required for Atlas?
Use mongodb+srv://<user>:<pass>@<cluster>/<db>?retryWrites=true&w=majority and URL-encode special characters in credentials.
Why use a singleton in Next.js?
Serverless environments can create many short-lived connections; a singleton prevents multiple concurrent connections and reduces connection churn.
What driver should I install?
Install mongoose for ODM features or mongodb for the native driver, and ensure they are listed in dependencies, not devDependencies.