11ai MongoDB databases
Version baseline: MongoDB 8.x, with 8.3.7 as the current stable release at this review. Inspect server, Atlas release track, featureCompatibilityVersion, mongosh, Database Tools, and driver versions independently before using 8.3-only behavior.
Use this skill for database-level navigation and lifecycle tasks. MongoDB creates a database when data or a collection is first written; selecting a name with use does not by itself create one.
Read-only inspection
show dbs
db.getName()
db.stats()
db.getCollectionNames()
db.getSiblingDB("admin").runCommand({ connectionStatus: 1 })
When the current database is not obvious, report the value from db.getName() and ask for the intended target before writing. Do not infer a production database from a connection URI alone.
Selecting and creating
use app
db.createCollection("users")
db.getSiblingDB("reporting").createCollection("daily")
Before creating anything, check whether the database or collection already exists and confirm the intended name. If the task only needs a collection, use the collections skill for validation options and collection-specific checks.
Dropping a database
Dropping is irreversible for the target database. Before proposing db.dropDatabase():
- confirm the exact deployment and database name
- list collections and report approximate sizes
- create or verify a backup if the user needs recovery
- show the exact command and ask for explicit approval
- after approval, run it and verify the result without printing sensitive data
Never run db.dropDatabase() because a database appears empty, stale, or misspelled. If the request says clean up, ask which exact database or provide a dry-run inventory first.