agentsclimarketplace

Mongodb atlas cli

Skill georgekhananaev/claude-skills-vault/.claude/skills/mongodb-atlas-cli

A curated collection of high impact skills for Claude Code designed to supercharge the senior full stack workflow. This vault automates the repetitive parts of development like architectural reviews, TDD cycles, and PR management so you can stay in flow. It is a force multiplier for shipping clean, production ready code at scale. πŸš€βš‘οΈ

Install
npx -y skills add georgekhananaev/claude-skills-vault --skill mongodb-atlas-cli

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

What its author says it does

Copied from the file, not written here

Comprehensive MongoDB Atlas + mongosh skill for performance auditing, all index types (b-tree/text/2dsphere/hashed/TTL/partial/wildcard/Atlas-Search/Vector-Search), Performance Advisor analysis, query explain, schema advice, backup status, alerts, week-over-week diffs, and additive index creation. Read-only by default; create-index ops gated behind explicit `--confirm`. Hard-blocks any destructive op (delete, drop, restore, pause, terminate, kill, dbuser write, network change). Works against Atlas Cloud (full feature set) and self-hosted/local mongo (mongosh-based subset).

SKILL.md

14.2 KB, ~3.5k tokens by cl100k_base, as published. Nobody here has run it

MongoDB Atlas CLI Skill

Comprehensive coverage of MongoDB Atlas operations w/ strict safety guarantees. Optimized for the loop: read Performance Advisor β†’ review suggestions β†’ create the right indexes safely. Never destructive.

When to Use

Invoke when the user wants to:

  • Connect to Atlas, list clusters/processes/projects
  • Pull Performance Advisor output (slow queries, suggested indexes, schema advice, drop hints)
  • Read cluster/process/database metrics, alerts, backup status
  • List existing indexes w/ live access counts (mongosh-based)
  • Explain a query (find or aggregate)
  • Create indexes β€” single, compound, TTL, sparse, partial, unique, geospatial, hashed, Atlas Search, Vector Search
  • Diff two audits week-over-week
  • Audit overall cluster performance
  • Diagnose slow queries before code changes

Do NOT use for any destructive op. Direct CRUD against data is also out of scope (use mongosh directly or the official MongoDB MCP server β€” see Integration).

Hard Safety Boundaries

CategoryOpAction
Readclusters/processes/metrics/logs/projectsAllowed, no confirm
ReadperformanceAdvisor (all subcmds)Allowed, no confirm
Readapi performanceAdvisor list*Allowed, no confirm
Readalerts/events/backups list, dbusers listAllowed, no confirm
Readclusters search indexes listAllowed, no confirm
Readmongosh: getIndexes, $indexStats, .explain(), getProfilingStatusAllowed, no confirm
Write (additive)clusters indexes createRequires --confirm + dry-run + duplicate pre-flight
Write (additive)clusters search indexes createRequires --confirm + dry-run
Destructivedelete, drop, terminate, pause, restore, kill, forceREFUSE β€” never run, even w/ user request
Destructivedbusers create/update/deleteREFUSE β€” auth changes can lock prod
Destructivenetworking * writes, accessLists deleteREFUSE β€” can sever connectivity
Destructivebackups restore / snapshot deleteREFUSE β€” overwrites data
Destructiveclusters indexes deleteREFUSE β€” even if advisor suggests dropping; only INFORM the user

If user asks to drop an index based on listDropIndexSuggestions, surface the suggestion and tell them to do it manually in mongosh / Atlas UI. Never run it.

Local Mongo vs. Atlas Cloud

This skill works against both, but coverage differs. Performance Advisor, metrics, backups, alerts, Atlas Search are cloud-only. mongosh-based scripts (list_indexes, explain_query, profiler_status) work everywhere. Full matrix in references/local-vs-atlas.md.

For local self-hosted mongo, safe_index_create.py --print-mongosh outputs the equivalent createIndex() snippet you can run directly in mongosh.

Prerequisites

Install

# macOS β€” both atlas CLI + mongosh
brew install mongodb-atlas

# Linux β€” see https://www.mongodb.com/docs/atlas/cli/current/install-atlas-cli/

# Docker fallback (any OS)
docker pull mongodb/atlas
alias atlas='docker run --rm -it -v ~/.config/atlas:/root/.config/atlas mongodb/atlas atlas'

# Verify
atlas --version && mongosh --version

validate_env.py --install auto-installs via brew on macOS.

Authenticate (Atlas Admin API)

Pick one (priority order):

# 1. Env vars (recommended for automation)
# Preferred (Atlas CLI 1.51+): Service Accounts (OAuth2)
export MONGODB_ATLAS_CLIENT_ID=<client_id>
export MONGODB_ATLAS_CLIENT_SECRET=<client_secret>
# Legacy: programmatic API keys
export MONGODB_ATLAS_PUBLIC_API_KEY=<public_key>
export MONGODB_ATLAS_PRIVATE_API_KEY=<private_key>
export MONGODB_ATLAS_PROJECT_ID=<24-hex-project-id>

# 2. Profile config
atlas config init

# 3. Browser
atlas auth login

API key role: Project Read Only for reads, Project Data Access Admin for index creation. Get keys: Atlas UI β†’ Project Settings β†’ Access Manager β†’ API Keys.

Authenticate (mongosh-based scripts)

For list_indexes.py, explain_query.py, profiler_status.py, safe_index_create.py pre-flight:

export MONGODB_CONNECTION_STRING="mongodb+srv://<host>.mongodb.net/?authSource=admin"
export MONGODB_USERNAME="<atlas-db-user>"
export MONGODB_PASSWORD="<password>"

DB user is separate from API key β€” Atlas UI β†’ Database Access β†’ ADD NEW DATABASE USER. See references/mongosh-integration.md.

Validate

python3 .claude/skills/mongodb-atlas-cli/scripts/validate_env.py

Script Index

Atlas Admin API (read-only, no DB credentials needed)

ScriptTask
validate_env.pyCheck CLI install + auth + project access
performance_audit.pyFull read-only audit (orchestrator)
namespaces.pyPerformance Advisor β†’ list hot namespaces (entry point)
suggest_indexes.pyPerformance Advisor β†’ suggested new indexes
slow_queries.pyPerformance Advisor β†’ slow query log lines
schema_advice.pyPerformance Advisor β†’ schema anti-pattern recommendations
drop_index_hints.pyPerformance Advisor β†’ redundant/hidden/unused indexes (advisory)
cluster_health.pyProcess metrics (CPU/mem/conn/op counters/query targeting) β€” parallel fetches
alerts.pyActive Atlas alerts
backup_status.pySnapshot list + freshness check
events.pyProject events / audit log
atlas_search_list.pyList Atlas Search & Vector Search indexes
audit_diff.pyCompare two audit JSON snapshots β€” week-over-week diff

Atlas Admin API (additive write β€” gated by --confirm)

ScriptTask
safe_index_create.pyCreate normal index β€” single/compound/TTL/sparse/partial/unique/2dsphere/hashed
atlas_search_create.pyCreate Atlas Search OR Vector Search index

mongosh-based (works on local + Atlas β€” needs DB user creds)

ScriptTask
list_indexes.pyList indexes per coll/db w/ live access counts & sizes β€” parallel per coll
explain_query.pyRun .explain() on find or aggregate query
profiler_status.pyDB profiler level + recent slow ops captured
index_build_status.pyPoll in-progress index builds via db.currentOp()

All mongosh scripts validate db/collection identifiers before interpolating into JS to prevent injection. Passwords passed via stdin (not argv) to avoid /proc/<pid>/cmdline exposure on Linux.

Pure local

ScriptTask
audit_diff.pyCompare audits week-over-week (no Atlas calls)
safe_index_create.py --print-mongoshPrint mongosh createIndex() snippet for local use

All scripts default to dry-run/read-only. Mutations need explicit --confirm.

Common Workflows

1. Optimize from advisor β†’ index

# Full picture
python3 scripts/performance_audit.py --cluster <C> --hours 168

# Verify what's already there
python3 scripts/list_indexes.py --db <DB> --collection <COLL>

# Inspect a specific suggestion's query first
python3 scripts/explain_query.py --db <DB> --collection <COLL> --filter '{...}'

# Create (dry-run)
python3 scripts/safe_index_create.py --cluster <C> --db <DB> --collection <COLL> \
  --key field:1 --name idx_field

# Execute
python3 scripts/safe_index_create.py --cluster <C> --db <DB> --collection <COLL> \
  --key field:1 --name idx_field --confirm

# Re-audit after build completes
python3 scripts/performance_audit.py --cluster <C>

2. Atlas Search for case-insensitive regex queries

When schema advice flags OPTIMIZE_CASE_INSENSITIVE_REGEX_QUERIES:

# See existing search indexes
python3 scripts/atlas_search_list.py --cluster <C> --db <DB> --collection <COLL>

# Generate starter definition
python3 scripts/atlas_search_create.py --init-template search > search.json
# edit search.json

# Dry-run
python3 scripts/atlas_search_create.py --cluster <C> --db <DB> --collection <COLL> \
  --name <coll>_text --file search.json

# Execute
python3 scripts/atlas_search_create.py --cluster <C> --db <DB> --collection <COLL> \
  --name <coll>_text --file search.json --confirm

3. Vector Search for AI / RAG

python3 scripts/atlas_search_create.py --init-template vector > vec.json
# edit vec.json β€” set numDimensions matching your embedding model
python3 scripts/atlas_search_create.py --cluster <C> --db <DB> --collection <COLL> \
  --name <coll>_vec --file vec.json --type vectorSearch --confirm

4. Drop redundant indexes (manually β€” skill won't drop)

# Get advisory list
python3 scripts/drop_index_hints.py --cluster <C>

# Verify w/ live counters
python3 scripts/list_indexes.py --db <DB> --collection <COLL>

# Confirm covering index serves a real query
python3 scripts/explain_query.py --db <DB> --collection <COLL> \
  --filter '{<typical_filter>}'

# Hide first (24-48h soak), then drop manually in mongosh
mongosh ... --eval 'db.runCommand({collMod: "<COLL>", index: {name: "<NAME>", hidden: true}})'

5. Weekly automation

# Save snapshot
python3 scripts/performance_audit.py --cluster <C> --hours 168 --json > audits/$(date +%F).json

# Diff vs. last week
python3 scripts/audit_diff.py audits/<old>.json audits/<new>.json --markdown > diff.md

6. Health checks (read-only, run anytime)

python3 scripts/cluster_health.py --cluster <C>
python3 scripts/backup_status.py --cluster <C>
python3 scripts/alerts.py --status OPEN

Index Types Supported

safe_index_create.py covers every standard MongoDB index type:

TypeFlag combinationAtlas-only?
Single-field--key field:1no
Compound--key f1:1 --key f2:-1 ...no
TTL--key created_at:1 --ttl-seconds Nno
Sparse--sparseno
Partial--partial-filter pf.jsonno
Unique--uniqueno
Combined (e.g. unique + partial)--unique --partial-filter pf.jsonno
Geospatial 2dsphere--key location:2dsphereno
Hashed (sharding)--key user_id:hashedno
Text (legacy)--key field:textno
Wildcard--file <json> w/ {"keys": [{"$**": 1}]}no
Atlas Searchatlas_search_create.py --type searchyes
Vector Searchatlas_search_create.py --type vectorSearchyes

Full reference: references/index-types.md.

Pre-flight Duplicate Detection

safe_index_create.py runs a pre-flight via mongosh (when creds are available) that checks if:

  • An index w/ identical keys already exists β†’ refuses to create duplicate
  • An existing larger compound already covers the proposed keys as a prefix β†’ refuses (your index would be redundant)

Override w/ --skip-preflight (not recommended). If mongosh creds aren't available, pre-flight is silently skipped.

Output Format

Default: human-readable summary to stderr, JSON to stdout when --json flag set. Pipe through jq:

python3 scripts/suggest_indexes.py --cluster <C> --json | jq '.[] | .namespace'

Error Handling

When scripts detect missing credentials or permission errors, they output:

MISSING: <ENV_VAR>
ASK_USER: <human prompt>
LOCATION: <where to find the value>

Claude should parse & use AskUserQuestion to prompt.

For permission errors:

PERMISSION_DENIED: requires <role>
ACTION: Ask user to grant role or use a different API key

Refusal Pattern

Refused destructive ops produce:

REFUSED: `atlas <command>` is a destructive op blocked by this skill.
  Matched forbidden prefix: <prefix>
  Run it manually in Atlas UI or via `atlas` directly if you intend to.

Never bypass β€” even w/ "I'm sure", "force it", "yolo". Tell the user to run it manually.

Complementary Tools

This skill focuses on admin/audit/index-management. For complementary capabilities:

NeedTool
AI-assisted CRUD against data, NL β†’ query, schema introspectionMongoDB MCP Server
Atlas Stream Processing pipelinesjwongmongodb/atlas-streams-skills
Connection pool / driver tuningMongoDB Agent Skills β€” Connection
Schema design from scratchsibling pydantic-model skill in this repo

References

TopicFile
Full Atlas CLI command mapreferences/cli-commands.md
Performance Advisor deep-divereferences/performance-advisor.md
Index strategy (ESR, etc.)references/index-strategy.md
Every index type w/ examplesreferences/index-types.md
Atlas Search + Vector Searchreferences/atlas-search.md
Local vs. Atlas feature matrixreferences/local-vs-atlas.md
mongosh integration detailsreferences/mongosh-integration.md
Quick recipes (copy-paste)references/quick-recipes.md
Safety boundaries detailreferences/safety-boundaries.md
Troubleshootingreferences/troubleshooting.md

Self-Healing

On any atlas error: atlas <command> --help β†’ if unclear, WebFetch https://www.mongodb.com/docs/atlas/cli/current/command/atlas-<command>/ (dashes join subcommands) β†’ adjust β†’ re-run.

Integration

Pairs w/:

  • senior-backend β€” schema/query design before adding indexes
  • code-quality β€” review query code that produces slow ops
  • pydantic-model β€” model-level fixes that reduce doc bloat
  • MongoDB MCP server β€” for direct data ops

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.