cosmos-entity

Community

Design resilient Cosmos DB document entities

AuthorFaysilAlshareef
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Designing and maintaining Cosmos DB document entities that are consistent, queryable, and safe for concurrent updates is challenging without clear conventions for ids, partitioning, discriminators, and concurrency control. This Skill captures a repeatable pattern to ensure entities across a microservice or domain follow the same contract and partition strategy to avoid hot partitions, ambiguous queries, and update conflicts.

Core Features & Use Cases

  • IContainerDocument contract: Standardizes required properties such as ContainerName, PartitionKeys, Discriminator, and ETag so different services and readers can rely on the same shape.
  • Hierarchical partition keys: Recommends a three-level PartitionKeyBuilder strategy to distribute load and enable efficient scoped queries.
  • Polymorphic containers: Uses a Discriminator string to allow multiple entity types to coexist in a single container while supporting polymorphic queries.
  • Optimistic concurrency: Uses ETag for safe updates and recommends factory methods and Apply patterns for event-sourced creation and updates.
  • Anti-pattern guidance: Calls out common mistakes like missing lowercase id, single partition keys, unbounded nested arrays, and public setters without factories.

Quick Start

Create a Cosmos DB entity for sales invoices using IContainerDocument with a three-level partition key, a Discriminator property, lowercase id, ETag support, and factory methods for event-based construction.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: cosmos-entity
Download link: https://github.com/FaysilAlshareef/dotnet-ai-kit/archive/main.zip#cosmos-entity

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.