1. Habit
  2. Skills
  3. MongoDB Query Optimizer skill
mongodb · 7K installs

MongoDB Query Optimizer skill
Runs by itself, weekly slow query review.

Suggest indexes for slow queries.

Install the MongoDB Query Optimizer skill and make it a habit: follow https://gethabit.dev/skills/mongodb/mongodb-query-optimizer.md

  1. 1Copy
  2. 2Paste into Claude Code, Codex or Cursor
  3. 3It runs by itself

7K installs190 starsApache-2.0 licenceSource on GitHub ↗

MongoDB Query Optimizer

by mongodb · 7K installs

The skill

The mongodb query optimizer skill helps agents find why MongoDB queries are slow and suggest indexes, using explain, collection indexes and Atlas Performance Advisor through MongoDB MCP.

Only when you ask.

The habit

Suggest indexes for slow queries.

↻ Runs by itselfweekly slow query review

How the habit works.
You don't have to.

Three questionsWhen does it start? How does it check its work? What does it remember?

One run, step by step.
Then it stops.

Stop ruleStops after the 5 slowest queries per run.

  1. 01

    Load references

    Your agent reads references/core-indexing-principles.md and references/antipattern-examples.md.

  2. 02

    Fetch slow queries

    It calls atlas-list-projects, then atlas-get-performance-advisor with slowQueryLogs and suggestedIndexes.

  3. 03

    Inspect top queries

    For the slowest and most frequent, it calls collection-indexes, explain and find.

  4. 04

    Diagnose

    It compares documents scanned with documents returned and looks for in-memory sorts.

  5. 05

    Suggest

    It suggests the highest-impact indexes with short reasons, as suggestions.

  6. 06

    Ask before creating

    It creates an index only after you approve.

What it may do.
Nothing more.

Safe by defaultIt writes only in its own folder and asks you before anything goes out.

Is it for you?
Use it when it fits.

Quick checkRead both lists. If the left one sounds like you, the MongoDB Query Optimizer skill helps.

Use it when

  • ✓ A query is slow
  • ✓ You want index suggestions
  • ✓ You review slow queries on a cluster

Skip it when

  • – You only write a new query
  • – You have no performance problem

Questions

MongoDB Query Optimizer skill, answered.

Will it drop indexes?

It suggests removal only when Atlas Performance Advisor recommends it.

What if Atlas is not set up?

General analysis needs Atlas MCP credentials. Without them it suggests indexes from query shape only.

How do I install the MongoDB Query Optimizer skill?

Copy the prompt at the top into your agent. It installs the skill from mongodb/agent-skills and sets up the habit. Or run npx skills add mongodb/agent-skills --skill mongodb-query-optimizer.

Is the MongoDB Query Optimizer skill free?

Yes. It is published under Apache-2.0. Habit is free too.

MongoDB Query Optimizer. Now as a habit.

Install the MongoDB Query Optimizer skill and make it a habit: follow https://gethabit.dev/skills/mongodb/mongodb-query-optimizer.md

  • Free
  • No account
  • Undo in one line

All mongodb skills →More ops skills →

Works in

  • Claude Code
  • Codex
  • Cursor
  • ChatGPT
  • Claude app

Made by mongodb, published under Apache-2.0. Habit links to the original and never changes it. Is this your skill?

Copying didn't work here. Select the line and copy it by hand.