cosmosdb-best-practices
Azure Cosmos DB performance optimization and best practices guidelines for NoSQL, partitioning, queries, SDK usage, and vector search. Use when writing, reviewing, or refactoring code that interacts with Azure Cosmos DB, designing data models, optimizing queries, or implementing high-performance database operations.
What this skill does
# Azure Cosmos DB Best Practices Comprehensive performance optimization guide for Azure Cosmos DB applications, containing 73+ rules across 10 categories, prioritized by impact to guide automated refactoring and code generation. 73 individual rule files are in the [rules/](./rules/) directory, one file per rule, synced from the [AzureCosmosDB/cosmosdb-agent-kit](https://github.com/AzureCosmosDB/cosmosdb-agent-kit). Load only the relevant rule file(s) when answering a question — do NOT load all files at once. Run `/azure-cosmos-db-assistant:generate-skills` to sync with the latest rules from the agent-kit. ## When to Apply Reference these guidelines when: - Designing data models for Cosmos DB - Choosing partition keys - Writing or optimizing queries - Implementing SDK patterns - Reviewing code for performance issues - Configuring throughput and scaling - Building globally distributed applications - Implementing vector search and RAG patterns ## Rule Index Rules are grouped by category prefix. For a given question, load files matching the relevant prefix (e.g., `model-*.md` for data modeling, `sdk-*.md` for SDK usage). See [rules/_sections.md](rules/_sections.md) for category descriptions. ### 1. Data Modeling — CRITICAL (prefix: `model-`) - [model-embed-related.md](rules/model-embed-related.md) — Embed related data retrieved together - [model-reference-large.md](rules/model-reference-large.md) — Reference data when items grow large - [model-avoid-2mb-limit.md](rules/model-avoid-2mb-limit.md) — Keep items well under 2MB limit - [model-id-constraints.md](rules/model-id-constraints.md) — Follow ID value length and character constraints - [model-nesting-depth.md](rules/model-nesting-depth.md) — Stay within 128-level nesting depth limit - [model-numeric-precision.md](rules/model-numeric-precision.md) — Understand IEEE 754 numeric precision limits - [model-denormalize-reads.md](rules/model-denormalize-reads.md) — Denormalize for read-heavy workloads - [model-schema-versioning.md](rules/model-schema-versioning.md) — Version your document schemas - [model-type-discriminator.md](rules/model-type-discriminator.md) — Use type discriminators for polymorphic data - [model-json-serialization.md](rules/model-json-serialization.md) — Handle JSON serialization correctly - [model-relationship-references.md](rules/model-relationship-references.md) — Use ID references with transient hydration ### 2. Partition Key Design — CRITICAL (prefix: `partition-`) - [partition-high-cardinality.md](rules/partition-high-cardinality.md) — Choose high-cardinality partition keys - [partition-avoid-hotspots.md](rules/partition-avoid-hotspots.md) — Distribute writes evenly - [partition-hierarchical.md](rules/partition-hierarchical.md) — Use hierarchical partition keys for flexibility - [partition-query-patterns.md](rules/partition-query-patterns.md) — Align partition key with query patterns - [partition-synthetic-keys.md](rules/partition-synthetic-keys.md) — Create synthetic keys when needed - [partition-key-length.md](rules/partition-key-length.md) — Respect partition key value length limits - [partition-20gb-limit.md](rules/partition-20gb-limit.md) — Plan for 20GB logical partition limit ### 3. Query Optimization — HIGH (prefix: `query-`) - [query-avoid-cross-partition.md](rules/query-avoid-cross-partition.md) — Minimize cross-partition queries - [query-use-projections.md](rules/query-use-projections.md) — Project only needed fields - [query-pagination.md](rules/query-pagination.md) — Use continuation tokens for pagination - [query-avoid-scans.md](rules/query-avoid-scans.md) — Avoid full container scans - [query-parameterize.md](rules/query-parameterize.md) — Use parameterized queries - [query-order-filters.md](rules/query-order-filters.md) — Order filters by selectivity ### 4. SDK Best Practices — HIGH (prefix: `sdk-`) - [sdk-singleton-client.md](rules/sdk-singleton-client.md) — Reuse CosmosClient as singleton - [sdk-async-api.md](rules/sdk-async-api.md) — Use async APIs for throughput - [sdk-retry-429.md](rules/sdk-retry-429.md) — Handle 429s with retry-after - [sdk-connection-mode.md](rules/sdk-connection-mode.md) — Use Direct mode for production - [sdk-preferred-regions.md](rules/sdk-preferred-regions.md) — Configure preferred regions - [sdk-excluded-regions.md](rules/sdk-excluded-regions.md) — Exclude regions experiencing issues - [sdk-availability-strategy.md](rules/sdk-availability-strategy.md) — Configure availability strategy for resilience - [sdk-circuit-breaker.md](rules/sdk-circuit-breaker.md) — Use circuit breaker for fault tolerance - [sdk-diagnostics.md](rules/sdk-diagnostics.md) — Log diagnostics for troubleshooting - [sdk-serialization-enums.md](rules/sdk-serialization-enums.md) — Serialize enums as strings not integers - [sdk-emulator-ssl.md](rules/sdk-emulator-ssl.md) — Configure SSL and connection mode for Cosmos DB Emulator - [sdk-etag-concurrency.md](rules/sdk-etag-concurrency.md) — Use ETags for optimistic concurrency - [sdk-java-content-response.md](rules/sdk-java-content-response.md) — Enable content response on write operations (Java) - [sdk-java-cosmos-config.md](rules/sdk-java-cosmos-config.md) — Configure Cosmos DB in Spring Boot with dependent beans - [sdk-java-spring-boot-versions.md](rules/sdk-java-spring-boot-versions.md) — Match Java version to Spring Boot requirements - [sdk-local-dev-config.md](rules/sdk-local-dev-config.md) — Configure local development to avoid cloud conflicts - [sdk-newtonsoft-dependency.md](rules/sdk-newtonsoft-dependency.md) — Explicitly reference Newtonsoft.Json package (.NET) - [sdk-spring-data-annotations.md](rules/sdk-spring-data-annotations.md) — Annotate entities for Spring Data Cosmos - [sdk-spring-data-repository.md](rules/sdk-spring-data-repository.md) — Use CosmosRepository correctly ### 5. Indexing Strategies — MEDIUM-HIGH (prefix: `index-`) - [index-exclude-unused.md](rules/index-exclude-unused.md) — Exclude paths never queried - [index-composite.md](rules/index-composite.md) — Use composite indexes for ORDER BY - [index-spatial.md](rules/index-spatial.md) — Add spatial indexes for geo queries - [index-range-vs-hash.md](rules/index-range-vs-hash.md) — Choose appropriate index types - [index-lazy-consistent.md](rules/index-lazy-consistent.md) — Understand indexing modes ### 6. Throughput & Scaling — MEDIUM (prefix: `throughput-`) - [throughput-autoscale.md](rules/throughput-autoscale.md) — Use autoscale for variable workloads - [throughput-right-size.md](rules/throughput-right-size.md) — Right-size provisioned throughput - [throughput-serverless.md](rules/throughput-serverless.md) — Consider serverless for dev/test - [throughput-burst.md](rules/throughput-burst.md) — Understand burst capacity - [throughput-container-vs-database.md](rules/throughput-container-vs-database.md) — Choose allocation level wisely ### 7. Global Distribution — MEDIUM (prefix: `global-`) - [global-multi-region.md](rules/global-multi-region.md) — Configure multi-region writes - [global-consistency.md](rules/global-consistency.md) — Choose appropriate consistency level - [global-conflict-resolution.md](rules/global-conflict-resolution.md) — Implement conflict resolution - [global-failover.md](rules/global-failover.md) — Configure automatic failover - [global-read-regions.md](rules/global-read-regions.md) — Add read regions near users - [global-zone-redundancy.md](rules/global-zone-redundancy.md) — Enable zone redundancy for HA ### 8. Monitoring & Diagnostics — LOW-MEDIUM (prefix: `monitoring-`) - [monitoring-ru-consumption.md](rules/monitoring-ru-consumption.md) — Track RU consumption - [monitoring-latency.md](rules/monitoring-latency.md) — Monitor P99 latency - [monitoring-throttling.md](rules/monitoring-throttling.md) — Alert on throttling - [monitoring-azure-monitor.md](rules/monitoring-azure-monitor.md) — Integrate Azure Monitor - [monitoring-diagnostic-logs.md](rules/monitoring-diagnostic-logs.md) — Enable diagnostic
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.