Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Azure Cosmos DB SDK for Java. NoSQL database operations with global distribution, multi-model support, and reactive patterns.
.claude/skills/azure-cosmos-java/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-09 | ✗→✓ | ▲ Improved | — | — |
| case-22 | ✓→✓ | = Same ✓ | — | — |
| case-18 | ✓→✓ | = Same ✓ | — | — |
| case-15 | ✗→✗ | = Same ✗ | — | — |
| case-06 | ✗→✗ | = Same ✗ | — | — |
Client library for Azure Cosmos DB NoSQL API with global distribution and reactive patterns.
xml<dependency> <groupId>com.azure</groupId> <artifactId>azure-cosmos</artifactId> <version>LATEST</version> </dependency>
Or use Azure SDK BOM:
xml<dependencyManagement> <dependencies> <dependency> <groupId>com.azure</groupId> <artifactId>azure-sdk-bom</artifactId> <version>{bom_version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>com.azure</groupId> <artifactId>azure-cosmos</artifactId> </dependency> </dependencies>
bashCOSMOS_ENDPOINT=https://<account>.documents.azure.com:443/ COSMOS_KEY=<your-primary-key>
javaimport com.azure.cosmos.CosmosClient; import com.azure.cosmos.CosmosClientBuilder; CosmosClient client = new CosmosClientBuilder() .endpoint(System.getenv("COSMOS_ENDPOINT")) .key(System.getenv("COSMOS_KEY")) .buildClient();
javaimport com.azure.cosmos.CosmosAsyncClient; CosmosAsyncClient asyncClient = new CosmosClientBuilder() .endpoint(serviceEndpoint) .key(key) .buildAsyncClient();
javaimport com.azure.cosmos.ConsistencyLevel; import java.util.Arrays; CosmosClient client = new CosmosClientBuilder() .endpoint(serviceEndpoint) .key(key) .directMode(directConnectionConfig, gatewayConnectionConfig) .consistencyLevel(ConsistencyLevel.SESSION) .connectionSharingAcrossClientsEnabled(true) .contentResponseOnWriteEnabled(true) .userAgentSuffix("my-application") .preferredRegions(Arrays.asList("West US", "East US")) .buildClient();
| Class | Purpose | |-------|---------| | CosmosClient / CosmosAsyncClient | Account-level operations | | CosmosDatabase / CosmosAsyncDatabase | Database operations | | CosmosContainer / CosmosAsyncContainer | Container/item operations |
java// Sync client.createDatabaseIfNotExists("myDatabase") .map(response -> client.getDatabase(response.getProperties().getId())); // Async with chaining asyncClient.createDatabaseIfNotExists("myDatabase") .map(response -> asyncClient.getDatabase(response.getProperties().getId())) .subscribe(database -> System.out.println("Created: " + database.getId()));
javaasyncClient.createDatabaseIfNotExists("myDatabase") .flatMap(dbResponse -> { String databaseId = dbResponse.getProperties().getId(); return asyncClient.getDatabase(databaseId) .createContainerIfNotExists("myContainer", "/partitionKey") .map(containerResponse -> asyncClient.getDatabase(databaseId) .getContainer(containerResponse.getProperties().getId())); }) .subscribe(container -> System.out.println("Container: " + container.getId()));
javaimport com.azure.cosmos.models.PartitionKey; CosmosAsyncContainer container = asyncClient .getDatabase("myDatabase") .getContainer("myContainer"); // Create container.createItem(new User("1", "John Doe", "john@example.com")) .flatMap(response -> { System.out.println("Created: " + response.getItem()); // Read return container.readItem( response.getItem().getId(), new PartitionKey(response.getItem().getId()), User.class); }) .flatMap(response -> { System.out.println("Read: " + response.getItem()); // Update User user = response.getItem(); user.setEmail("john.doe@example.com"); return container.replaceItem( user, user.getId(), new PartitionKey(user.getId())); }) .flatMap(response -> { // Delete return container.deleteItem( response.getItem().getId(), new PartitionKey(response.getItem().getId())); }) .block();
javaimport com.azure.cosmos.models.CosmosQueryRequestOptions; import com.azure.cosmos.util.CosmosPagedIterable; CosmosContainer container = client.getDatabase("myDatabase").getContainer("myContainer"); String query = "SELECT * FROM c WHERE c.status = @status"; CosmosQueryRequestOptions options = new CosmosQueryRequestOptions(); CosmosPagedIterable<User> results = container.queryItems( query, options, User.class ); results.forEach(user -> System.out.println("User: " + user.getName()));
Choose a partition key with:
| Level | Guarantee | |-------|-----------| | Strong | Linearizability | | Bounded Staleness | Consistent prefix with bounded lag | | Session | Consistent prefix within session | | Consistent Prefix | Reads never see out-of-order writes | | Eventual | No ordering guarantee |
All operations consume RUs. Check response headers:
javaCosmosItemResponse<User> response = container.createItem(user); System.out.println("RU charge: " + response.getRequestCharge());
javaimport com.azure.cosmos.CosmosException; try { container.createItem(item); } catch (CosmosException e) { System.err.println("Status: " + e.getStatusCode()); System.err.println("Message: " + e.getMessage()); System.err.println("Request charge: " + e.getRequestCharge()); if (e.getStatusCode() == 409) { System.err.println("Item already exists"); } else if (e.getStatusCode() == 429) { System.err.println("Rate limited, retry after: " + e.getRetryAfterDuration()); } }
| Resource | URL | |----------|-----| | Maven Package | https://central.sonatype.com/artifact/com.azure/azure-cosmos | | API Documentation | https://azuresdkdocs.z19.web.core.windows.net/java/azure-cosmos/latest/index.html | | Product Docs | https://learn.microsoft.com/azure/cosmos-db/ | | Samples | https://github.com/Azure-Samples/azure-cosmos-java-sql-api-samples | | Performance Guide | https://learn.microsoft.com/azure/cosmos-db/performance-tips-java-sdk-v4-sql | | Troubleshooting | https://learn.microsoft.com/azure/cosmos-db/troubleshoot-java-sdk-v4-sql |
This skill is applicable to execute the workflow or actions described in the overview.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-15 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-01 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +5 percentage points is the difference between those two pass rates over the 22 comparable cases.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.