Official agent skill

Azure Cosmos Java

by microsoft in microsoft/skills

Azure Cosmos DB SDK for Java. An agent skill from microsoft/skills.

OfficialMITAuto-check passedDatabases

Install Azure Cosmos Java

skills CLI
$ npx skills add microsoft/skills --skill azure-cosmos-java -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install microsoft/skills azure-cosmos-java --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/microsoft/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.github/plugins/azure-sdk-java/skills/azure-cosmos-java .claude/skills/azure-cosmos-java && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
azure-cosmos-java
GitHub stars
3.1k
Used in
6 other repos
Token cost
~1.9k tokens
SKILL.md length
210 words
Files
2 (incl. references)
Skills in repo
150
Repo updated
First seen
Licence
MIT

At a glance

Azure Cosmos DB SDK for Java. An agent skill from microsoft/skills.

  • Works in 7 steps: Reuse CosmosClient — Create once, reuse… → Use async client for high-throughput… → Choose partition key carefully — Affects… → …
  • Tasks that involve NoSQL databases
  • SKILL.md covers Installation, Environment Variables, Authentication and Client Hierarchy, plus 5 more sections
  • Needs COSMOS_KEY

What it does

Azure Cosmos Java is an agent skill from microsoft/skills, published by the product's own GitHub organization. Azure Cosmos DB SDK for Java. NoSQL database operations with global distribution, multi-model support, and reactive patterns. Triggers: "CosmosClient java", "CosmosAsyncClient", "cosmos database java", "cosmosdb java", "document database java".

Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including reference files (for example `references/examples.md`).

It sits in Databases, covering NoSQL databases. It works with Azure Cosmos DB, Java and Microsoft Azure. The repository describes itself as: Skills, MCP servers, Custom Agents, Agents.md for SDKs to ground Coding Agents. The licence is MIT.

When your agent uses it

  • Tasks that involve NoSQL databases

Example prompts

  • “CosmosClient java”
  • “CosmosAsyncClient”
  • “cosmos database java”
  • “/azure-cosmos-java”

Requirements

  • A credential in COSMOS_KEY

Workflow steps

7 steps, taken from the first numbered list in SKILL.md.

  1. Reuse CosmosClient — Create once, reuse throughout application
  2. Use async client for high-throughput scenarios
  3. Choose partition key carefully — Affects performance and scalability
  4. Enable content response on write for immediate access to created items
  5. Configure preferred regions for geo-distributed applications
  6. Handle 429 errors with retry policies (built-in by default)
  7. Use direct mode for lowest latency in production

What it can do on your machine

Read from SKILL.md and the folder at commit 354361d. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are java, xml and bash).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • learn.microsoft.com
    • central.sonatype.com
    • azuresdkdocs.z19.web.core.windows.net
    • github.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • COSMOS_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Azure Cosmos Java loads about 1.9k tokens when it runs, and up to ~4.9k if it reads all its reference files. Until then it costs about 66 tokens; SKILL.md has 210 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~66
When it runs · the whole SKILL.md, loaded when a task matches
~1.9k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from microsoft/skills at commit 354361d, republished under its MIT licence (© microsoft). 210 words, ~1,874 tokens.

Download SKILL.mdSave it as .claude/skills/azure-cosmos-java/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
azure-cosmos-java
description
Azure Cosmos DB SDK for Java. NoSQL database operations with global distribution, multi-model support, and reactive patterns. Triggers: "CosmosClient java", "CosmosAsyncClient", "cosmos database java", "cosmosdb java", "document database java".
license
MIT
metadata.author
Microsoft
metadata.version
1.0.0
metadata.package
azure-cosmos

Azure Cosmos DB SDK for Java

Client library for Azure Cosmos DB NoSQL API with global distribution and reactive patterns.

Installation

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>

Environment Variables

bash
COSMOS_ENDPOINT=https://<account>.documents.azure.com:443/
COSMOS_KEY=<your-primary-key>

Authentication

Key-based Authentication
java
import com.azure.cosmos.CosmosClient;
import com.azure.cosmos.CosmosClientBuilder;

CosmosClient client = new CosmosClientBuilder()
    .endpoint(System.getenv("COSMOS_ENDPOINT"))
    .key(System.getenv("COSMOS_KEY"))
    .buildClient();
Async Client
java
import com.azure.cosmos.CosmosAsyncClient;

CosmosAsyncClient asyncClient = new CosmosClientBuilder()
    .endpoint(serviceEndpoint)
    .key(key)
    .buildAsyncClient();
With Customizations
java
import 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();

Client Hierarchy

ClassPurpose
CosmosClient / CosmosAsyncClientAccount-level operations
CosmosDatabase / CosmosAsyncDatabaseDatabase operations
CosmosContainer / CosmosAsyncContainerContainer/item operations

Core Workflow

Create Database
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()));
Create Container
java
asyncClient.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()));
CRUD Operations
java
import 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();
Query Documents
java
import 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()));

Key Concepts

Partition Keys

Choose a partition key with:

  • High cardinality (many distinct values)
  • Even distribution of data and requests
  • Frequently used in queries
Consistency Levels
LevelGuarantee
StrongLinearizability
Bounded StalenessConsistent prefix with bounded lag
SessionConsistent prefix within session
Consistent PrefixReads never see out-of-order writes
EventualNo ordering guarantee
Request Units (RUs)

All operations consume RUs. Check response headers:

java
CosmosItemResponse<User> response = container.createItem(user);
System.out.println("RU charge: " + response.getRequestCharge());

Best Practices

  1. Reuse CosmosClient — Create once, reuse throughout application
  2. Use async client for high-throughput scenarios
  3. Choose partition key carefully — Affects performance and scalability
  4. Enable content response on write for immediate access to created items
  5. Configure preferred regions for geo-distributed applications
  6. Handle 429 errors with retry policies (built-in by default)
  7. Use direct mode for lowest latency in production

Error Handling

java
import 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());
    }
}

© microsoft, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (references) in .github/plugins/azure-sdk-java/skills/azure-cosmos-java of microsoft/skills.

  • SKILL.md
  • references/examples.md

Open the folder on GitHubat commit 354361d

Used in 6 other repositories

We found 17 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 6 other GitHub owners. This page covers the copy in microsoft/skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Azure Cosmos Java next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Azure Cosmos Java compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Azure Cosmos Java this skillmicrosoft/skills3.1k6 repos~1.9kAutomated safety check: PassMIT
Azure Cosmosdbalinaqi/maggy7071 repos~4.5kAutomated safety check: PassMIT
Azure Storagemicrosoft/GitHub-Copilot-for-Azure2552 repos~1.3kAutomated safety check: PassMIT
Cosmosdb Best Practicesmicrosoft/vscode-cosmosdb200—~4.3kAutomated safety check: PassMIT
Azure Data Tables Pyaiskillstore/marketplace4305 repos~1.5kAutomated safety check: PassNone
Extend Commands APIredis/lettuce5.8k—~7.7kAutomated safety check: NotesMIT

Similar skills

  • Azure Cosmosdb

    alinaqi/maggy

    Azure Cosmos DB partition keys, consistency levels, change feed, SDK patterns

    707 GitHub starsUsed in 1 repo~4.5k tokens
    DatabasesAuto-check passed
  • Azure Storage

    microsoft/GitHub-Copilot-for-Azure

    Official

    Azure Storage Services including Blob Storage, File Shares, Queue Storage, Table Storage, and Data Lake.

    255 GitHub starsUsed in 2 repos~1.3k tokens
    DatabasesAuto-check passed
  • Cosmosdb Best Practices

    microsoft/vscode-cosmosdb

    Official

    Azure Cosmos DB performance optimization and best practices guidelines for NoSQL, partitioning, queries, and SDK usage.

    200 GitHub stars~4.3k tokensUpdated today
    DatabasesAuto-check passed
  • Azure Data Tables Py

    aiskillstore/marketplace

    Azure Tables SDK for Python (Storage and Cosmos DB). An agent skill from aiskillstore/marketplace.

    430 GitHub starsUsed in 5 repos~1.5k tokens
    DatabasesAuto-check passed
  • Extend Commands API

    redis/lettuce

    Official

    Add or extend Redis commands in the Lettuce client API end-to-end — a new core command, a family of new commands, an extension to an existing command's options, or a module/area command…

    5.8k GitHub stars~7.7k tokensUpdated today
    DatabasesAuto-check: notes
  • Writing Javadoc

    redis/lettuce

    Official

    A skill your agent uses when writing or editing Javadoc for Lettuce public API — new methods, classes, deprecations, or when a reviewer asks to fix or improve doc comments.

    5.8k GitHub stars~809 tokensUpdated today
    DatabasesAuto-check passed

More from microsoft/skills

All 150 skills in this repo
  • Official

    Reference for building on Microsoft Foundry with the azure-ai-projects Python SDK: project clients, versioned agents, evaluations, connections, datasets and indexes.

    3.1k GitHub starsUsed in 6 repos~2.8k tokens
    Auto-check passed
  • Official

    Python guidance for the Azure AI Search SDK covering vector, hybrid and semantic search, index management and indexers, with Entra ID authentication preferred over keys.

    3.1k GitHub starsUsed in 6 repos~4.4k tokens
    Auto-check passed
  • Official

    Covers producer, consumer, and checkpoint-store setup for Azure Event Hubs streaming in Python, with Entra ID auth and partition targeting.

    3.1k GitHub starsUsed in 1 repo~2.3k tokens
    Auto-check passed
  • Pydantic Models Py

    microsoft/skills

    Official

    Create Pydantic models following the multi-model pattern with Base, Create, Update, Response, and InDB variants.

    3.1k GitHub starsUsed in 6 repos~496 tokens
    Auto-check passed
  • Official

    Builds podcast-style audio narration from text with Azure OpenAI's GPT Realtime Mini over WebSocket, from a Python FastAPI backend to a React player.

    3.1k GitHub starsUsed in 1 repo~947 tokens
    Auto-check passed
  • Frontend UI Dark TS

    microsoft/skills

    Official

    Build dark-themed React applications using Tailwind CSS with custom theming, glassmorphism effects, and Framer Motion animations.

    3.1k GitHub starsUsed in 5 repos~3.6k tokens
    Auto-check passed

Categories

Questions about Azure Cosmos Java

What does Azure Cosmos Java do?

Azure Cosmos DB SDK for Java. An agent skill from microsoft/skills. Azure Cosmos Java is an agent skill from microsoft/skills, published by the product's own GitHub organization. Azure Cosmos DB SDK for Java.

When should I use Azure Cosmos Java?

Azure Cosmos Java fits situations like: tasks that involve NoSQL databases.

How do I install Azure Cosmos Java in Claude Code?

Run `npx skills add microsoft/skills --skill azure-cosmos-java -a claude-code`. Or copy the skill folder (.github/plugins/azure-sdk-java/skills/azure-cosmos-java in microsoft/skills) into .claude/skills/azure-cosmos-java in your project. Claude Code loads it when a task matches its description.

How do I install Azure Cosmos Java in Codex?

Run `npx skills add microsoft/skills --skill azure-cosmos-java -a codex`. Or copy the skill folder (.github/plugins/azure-sdk-java/skills/azure-cosmos-java in microsoft/skills) into .agents/skills/azure-cosmos-java in your project. Codex loads it when a task matches its description.

Can I use Azure Cosmos Java in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add microsoft/skills --skill azure-cosmos-java -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/azure-cosmos-java, .gemini/skills/azure-cosmos-java, .github/skills/azure-cosmos-java and .opencode/skills/azure-cosmos-java in your project.

What does Azure Cosmos Java need to run?

Going by SKILL.md and its folder, Azure Cosmos Java needs credentials named COSMOS_KEY. Our summary lists: A credential in COSMOS_KEY.

Does Azure Cosmos Java access the network?

SKILL.md names 4 domains. As links in the text: learn.microsoft.com, central.sonatype.com, azuresdkdocs.z19.web.core.windows.net and github.com. This is read from the text; nothing was executed.

Is Azure Cosmos Java safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Azure Cosmos Java use?

Azure Cosmos Java is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Azure Cosmos Java use?

About 1.9k tokens (SKILL.md is roughly 7.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 3k tokens, read only when the agent opens those files.

What are the alternatives to Azure Cosmos Java?

Skills that share tags, products or a category with Azure Cosmos Java: Azure Cosmosdb (alinaqi/maggy, 707 stars), Azure Storage (microsoft/GitHub-Copilot-for-Azure, 255 stars), Cosmosdb Best Practices (microsoft/vscode-cosmosdb, 200 stars) and Azure Data Tables Py (aiskillstore/marketplace, 430 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Azure Cosmos Java?

microsoft (a GitHub organization, an official publisher) maintains it in microsoft/skills, which has 3,086 GitHub stars. The repository holds 150 skills in this directory. The repository was last updated on October 6, 2026.

Source: microsoft/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.