mcpField
C
cosmosdb-best-practices

cosmosdb-best-practices

github.com/azurecosmosdbData & databases611.1k installsUpdated 1d ago
Repository

About cosmosdb-best-practices

A coding skill with prioritized Azure Cosmos DB guidance for developers designing, building, and reviewing applications. Its rules span data modeling, queries, SDK use, scaling, security, and vector search.

Key features

  1. 01100+ rules across 13 categories
  2. 02Prioritized guidance by impact
  3. 03Language-specific SDK recommendations
  4. 04Coverage of vector and full-text search

Use cases

  1. 01Choosing partition keys and data models
  2. 02Optimizing queries and SDK patterns
  3. 03Reviewing performance and scaling
  4. 04Building vector search or RAG features

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/azurecosmosdb/cosmosdb-agent-kit --skill cosmosdb-best-practices

After installing, type/cosmosdb-best-practicesin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

metadata.json
README.md
agents/
openai.yaml
rules/
_sections.md
_template.md
fts-add-index.md
fts-define-policy.md
fts-enable-capability.md
fts-hybrid-queries.md
fts-keyword-matching.md
fts-relevance-ranking.md
global-conflict-resolution.md
global-consistency.md
global-failover.md
global-multi-region-write-antipattern.md
global-multi-region.md
global-read-regions.md
global-zone-redundancy.md
index-composite-direction.md
index-composite.md
index-exclude-unused.md
index-lazy-consistent.md
index-path-syntax.md
index-range-vs-hash.md
index-spatial.md
model-avoid-2mb-limit.md
model-denormalize-reads.md
model-embed-related.md
model-id-constraints.md
model-json-serialization.md

Details

From the project README

Azure Cosmos DB Best Practices

Comprehensive performance optimization guide for Azure Cosmos DB applications, containing 100+ rules across 13 categories, prioritized by impact to guide automated refactoring and code generation.

Before answering, read the linked rule files relevant to the user's question. The quick reference below is an index, not the full guidance: SDK APIs, limits, configuration prerequisites, and caveats live in the rule bodies. Use the language-specific integration rule when one exists rather than substituting a generic pattern. Keep answers concise, but include the constraints that make the recommendation correct for the user's scenario.

When to Apply

Reference these guidelines when:

  • Designing data models for Cosmos DB
  • Choosing partition keys
  • Writing or optimizing queries
  • Implementing SDK patterns
  • Using the Cosmos DB Emulator for local development
  • Inspecting or managing Cosmos DB data with developer tooling
  • Implementing vector search or RAG features on Cosmos DB
  • Reviewing code for performance issues
  • Configuring throughput and scaling
  • Building globally distributed applications

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Data ModelingCRITICALmodel-
2Partition Key DesignCRITICALpartition-
3Query OptimizationHIGHquery-
4SDK Best PracticesHIGHsdk-
5Indexing StrategiesMEDIUM-HIGHindex-
6Throughput & ScalingMEDIUMthroughput-
7Global DistributionMEDIUMglobal-
8Monitoring & DiagnosticsLOW-MEDIUMmonitoring-
9Design PatternsHIGHpattern-
10Developer ToolingMEDIUMtooling-
11Vector SearchHIGHvector-
12Full-Text SearchHIGHfts-
13SecurityHIGHsecurity-

Quick Reference

1. Data Modeling (CRITICAL)
2. Partition Key Design (CRITICAL)
3. Query Optimization (HIGH)
4. SDK Best Practices (HIGH)
5. Indexing Strategies (MEDIUM-HIGH)
6. Throughput & Scaling (MEDIUM)
7. Global Distribution (MEDIUM)
8. Monitoring & Diagnostics (LOW-MEDIUM)
9. Design Patterns (HIGH)
10. Developer Tooling (MEDIUM)
11. Vector Search (HIGH)
12. Full-Text Search (HIGH)
  • fts-enable-capability - Enable EnableNoSQLFullTextSearch capability on the account — prerequisite for all FTS functions
  • fts-full-text-policy - Define fullTextPolicy on the container with correct language code (en-US, case-sensitive)
  • fts-index-policy - Add fullTextIndexes entry in the indexing policy to build the inverted index
  • fts-contains-query - Use FullTextContains / FullTextContainsAll / FullTextContainsAny instead of CONTAINS(LOWER(...))
  • fts-score-ranking - Use ORDER BY RANK FullTextScore(path, term) for BM25 relevance ranking
  • fts-hybrid-query - Combine FTS predicates with selective indexed equality/range filters; predicate text order does not control execution
13. Security (HIGH)

How to Use

Use the linked rule files above for detailed explanations and code examples. The links give the agent direct paths to the relevant guidance instead of relying on folder scanning or inferred filenames.

Each rule file contains:

  • Brief explanation of why it matters
  • Incorrect code example with explanation
  • Correct code example with explanation
  • Additional context and references

Comments

Markdown supported