From db-cosmosdb
Use when implementing Azure Cosmos DB code with SDKs — enforces patterns for .NET SDK (CosmosClient, LINQ, bulk), Node.js SDK (@azure/cosmos), Python SDK (azure-cosmos), and custom versioned migration scripts
How this skill is triggered — by the user, by Claude, or both
Slash command
/db-cosmosdb:cosmosdb-frameworksThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- Use `ConnectionMode.Direct` for lowest latency
ConnectionMode.Direct for lowest latencyAllowBulkExecution for batch operationsCosmosPropertyNamingPolicy.CamelCase for JSON serializationRequestCharge on responses for RU monitoringPartitionKey explicitly — never rely on auto-extractionCosmosClient at application shutdown, not per request (singleton)// Create database and container
await client.CreateDatabaseIfNotExistsAsync("orderdb");
await database.CreateContainerIfNotExistsAsync(
new ContainerProperties("orders", "/customerId")
{
DefaultTimeToLive = -1, // TTL enabled, no default expiry
IndexingPolicy = new IndexingPolicy
{
CompositeIndexes = {
new Collection<CompositePath> {
new CompositePath { Path = "/status", Order = CompositePathSortOrder.Ascending },
new CompositePath { Path = "/createdAt", Order = CompositePathSortOrder.Descending }
}
}
}
},
throughput: 400);
fetchAll() for small result sets, fetchNext() for paginationrequestCharge on all responsesconst operations = orders.map(order => ({
operationType: "Create",
resourceBody: order,
}));
const response = await container.items.batch(operations, partitionKey);
enable_cross_partition_query=True only when necessary (expensive)partition_key parameter to scope queries to single partitionmax_item_count for pagination controlCosmosHttpResponseError for retry logicpublic class CosmosDbMigrationRunner
{
private readonly Container _container;
private readonly Container _migrationContainer;
public async Task RunMigrationsAsync(IEnumerable<ICosmosDbMigration> migrations)
{
var applied = await GetAppliedMigrationsAsync();
foreach (var migration in migrations.OrderBy(m => m.Version))
{
if (applied.Contains(migration.Version)) continue;
await migration.UpAsync(_container);
await RecordMigrationAsync(migration);
}
}
}
// Update indexing policy via SDK
var containerResponse = await container.ReadContainerAsync();
var properties = containerResponse.Resource;
properties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/largeField/?" });
await container.ReplaceContainerAsync(properties);
npx claudepluginhub gagandeepp/software-agent-teams --plugin db-cosmosdbGuides completion of development work by verifying tests, detecting environment, and presenting structured options for merge, PR, or cleanup.
Enforces test-driven development: write failing test first, then minimal code to pass. Use when implementing features or bugfixes.
Guides creation and editing of skills using test-driven development with pressure scenarios and subagents to verify agent compliance.