documentdb-indexing

Guidance for choosing and designing indexes in Azure DocumentDB. An index is an extra data structure that helps the database find records faster for specific searches, sorting, maps, or expiry rules.

In plain words
What is it for?
Use it when creating single-field or combined indexes, indexing arrays or locations, adding expiry or vector search, or reviewing an index budget.
Why use it?
It helps match indexes to real query patterns while avoiding unnecessary indexes and DocumentDB-specific search mistakes.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/azure/documentdb-agent-kit/indexing
Any agent
npx skills add Azure/documentdb-agent-kit --skill indexing
Clone the repo
git clone --depth 1 https://github.com/Azure/documentdb-agent-kit

Made for: Claude Code, Codex.

Per session 101 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 754 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00101 $0.00754
Opus 5 $0.00051 $0.00377
Sonnet 5 $0.00020 $0.00151
Haiku 4.5 $0.00010 $0.00075

Measured 2d ago against content hash c6e438a5c2e9, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

documentdb-indexing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/indexing/SKILL.md · 32 lines

How it starts

The opening of the file, as written. The whole thing — 32 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Indexing Strategies — Azure DocumentDB

Companion skill to documentdb-query-optimizer. That skill answers "why is this query slow?"; this one answers "which index should I create, and what shape should it take?".

Azure DocumentDB supports the standard MongoDB index types. Only _id is created automatically — every other index must be created explicitly. Default limit: 64 single-field indexes per collection (extendable to 300 on request).

Index engine types

_id vs regular indexes: The _id index is a B-tree, created automatically, and cannot be dropped. For sharded collections the _id key is composite — it includes a hash of the shard key. All other indexes created via createIndex are RUM indexes; the exception is geospatial indexes (2dsphere, 2d), which are GiST indexes.

Rules

  • index-single-field — When a single-field index is enough; direction, options (unique, sparse, partial, collation).
  • index-compound-esr — Compound index design via ESR (Equality → Sort → Range); prefer one compound over many singles.
  • index-multikey-arrays — Indexing array fields; the one-array-per-compound (parallel-array) restriction; multikey can't cover queries.
  • index-text-prefer-textsearch — On Azure DocumentDB, prefer the textSearch index + $search over community $text indexes.
  • index-wildcard-dynamic-schemas — Wildcard indexes for truly dynamic schemas; cost vs benefit; scope the prefix.
  • index-hashed-shard-keys — Hashed indexes for even distribution; when sharding becomes necessary; shard-key alignment; range-query caveats.
  • index-2dsphere-geospatial — GeoJSON types, [longitude, latitude] order, $near / $geoWithin / $geoIntersects.
  • index-ttl-expiry — TTL indexes: expireAfterSeconds semantics, date-field requirement, monitoring.
  • index-count-budget — Keep 5–15 indexes per collection; review $indexStats; drop unused.
  • index-lifecycle-drop-hide — Safe lifecycle: inventory → detect redundancy → hideIndexdropIndex. The _id index cannot be dropped.
  • index-pattern-cookbook — Query-pattern → index-shape cookbook (equality+sort, multi-equality, selectivity ordering, $eq + $in mix, range+sort, equality+range, hybrid, partial index for large arrays).

Read the full file on GitHub · 32 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 32 lines · 101 tokens per session scan A c6e438a5c2e9

Subscribe to this mod's changes

documentdb-indexing is a skill published in the GitHub repository Azure/documentdb-agent-kit (5 stars, last pushed 1mo ago), licensed MIT. It adds 101 tokens to every session and 754 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

azure-mgmt-mongodbatlas-dotnet

Manage MongoDB Atlas Organizations as Azure ARM resources using Azure.ResourceManager.MongoDBAtlas SDK. Use when creating, updating, listing, or deleting MongoDB Atlas organizations through Azure Marketplace integration. This SDK manages the Azure-side organization resource, not Atlas clusters/databases directly.

microsoft/skills · 64 tokens

moai-domain-database

Database specialist covering PostgreSQL, MongoDB, Redis, Oracle, and cloud database platforms (Neon, Supabase, Firestore). Use for schema design, query optimization, indexing strategies, data modeling, or cloud database selection. Cloud vendor guide absorbed from moai-platform-database-cloud.

modu-ai/moai-adk · 64 tokens

mongodb-mcp-v3-migration

Migrates external consumer code from the mongodb-mcp-server v1/v2 single-package API to the v3 scoped-package structure. In v3, mongodb-mcp-server is a binary-only package (npx / MCPB); library embedding uses @mongodb-js/mcp-cli, @mongodb-js/mcp-core, @mongodb-js/mcp-http-runners, @mongodb-js/mcp-tools-, and the other…

mongodb-js/mongodb-mcp-server · 153 tokens

prisma-mongodb-upgrade

Decision and migration guide for Prisma ORM MongoDB projects on v6, which have no upgrade path to v7. Use when a MongoDB project asks about upgrading Prisma, when "upgrade to prisma 7" comes up in a project with provider = "mongodb", or when evaluating a move to Prisma Next. Triggers on "upgrade prisma mongodb"…

nitrocloudofficial/nitrostack · 95 tokens

mongodb

MongoDB operations expert for queries, aggregation pipelines, indexes, and schema design.

RightNow-AI/openfang · 17 tokens

mongodb-atlas-stream-processing

Manages MongoDB Atlas Stream Processing (ASP) workflows. Handles workspace provisioning, data source/sink connections, processor lifecycle operations, debugging diagnostics, and tier sizing. Supports Kafka, Atlas clusters, S3, HTTPS, and Lambda integrations for streaming data workloads and event processing. NOT for…

fcakyon/claude-codex-settings · 82 tokens