Agent skill

Opik Python SDK Patterns

by comet-ml in comet-ml/opik

Developer notes for working inside the Opik Python SDK: layered design, async versus blocking calls, integration styles, batching and dependency rules.

Apache-2.0Auto-check passedAI & LLM Engineering

Install Opik Python SDK Patterns

skills CLI
$ npx skills add comet-ml/opik --skill python-sdk -a claude-code

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

GitHub CLI
$ gh skill install comet-ml/opik python-sdk --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/comet-ml/opik.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/python-sdk .claude/skills/python-sdk && 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
python-sdk
GitHub stars
22k
Token cost
~684 tokens
SKILL.md length
103 words
Files
5
Skills in repo
19
Repo updated
First seen
Licence
Apache-2.0

At a glance

Developer notes for working inside the Opik Python SDK: layered design, async versus blocking calls, integration styles, batching and dependency rules.

  • Adding a new integration to the Opik Python SDK
  • SKILL.md covers Three-Layer Architecture, Critical Gotchas, Integration Patterns and Dependency Policy, plus 3 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Deciding whether an SDK call should be queued or blocking

What it does

The skill summarizes how the SDK in `sdks/python` is put together. It is built in layers, starting with the public API (`opik.Opik` and `@opik.track`) and a message-processing layer for queueing, batching and retry. Gotchas include flushing before exit so queued data is sent, and knowing which calls are fire-and-forget through the message queue (traces, spans, feedback scores, experiment inserts) and which block and return data (datasets, prompts, searching traces and spans).

For integrations, it picks a style by library: pure callbacks for LangChain and LlamaIndex, method patching for OpenAI and Anthropic, and a hybrid for ADK where callbacks are unreliable. Integration modules import their dependency lazily. Rules cover adding no new dependencies, keeping flexible version bounds, create, get, list, update and delete method names, and batch flushing on time, size, memory or manual triggers. Reference files cover testing, error handling and good code, and a refactor-helper agent file is included.

When your agent uses it

  • Adding a new integration to the Opik Python SDK
  • Deciding whether an SDK call should be queued or blocking
  • Reviewing SDK changes against the project's dependency and naming rules

Example prompts

  • “Add an Opik integration for a library that has no callbacks, using method patching.”
  • “Why do traces go missing when my script exits, and where does the SDK flush?”
  • “Name the new SDK method for deleting a dataset in line with the existing CRUD conventions.”

Requirements

  • A checkout of the Opik repository with `sdks/python`

What it can do on your machine

Read from SKILL.md and the folder at commit f217a86. 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 python).

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

  • Network

    No URLs in SKILL.md.

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

  • Credentials

    Names no API keys, tokens, secrets or passwords.

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

Context cost

Opik Python SDK Patterns loads about 684 tokens when it runs. Until then it costs about 31 tokens; SKILL.md has 103 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~31
When it runs · the whole SKILL.md, loaded when a task matches
~684

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 comet-ml/opik at commit f217a86, republished under its Apache-2.0 licence (© comet-ml). 103 words, ~684 tokens.

Download SKILL.mdSave it as .claude/skills/python-sdk/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
python-sdk
description
Python SDK patterns for Opik. Use when working in sdks/python, on SDK APIs, integrations, or message processing.

Python SDK

Three-Layer Architecture

Layer 1: Public API      (opik.Opik, @opik.track)
    ↓
Layer 2: Message Processing   (queue, batching, retry)
    ↓
Layer 3: REST Client     (OpikApi, HTTP)

Critical Gotchas

Flush Before Exit
python
# ✅ REQUIRED for async operations
client = opik.Opik()
# ... tracing operations ...
client.flush()  # Must call before exit!
Async vs Sync Operations

Async (via message queue) - fire-and-forget:

  • trace(), span()
  • log_traces_feedback_scores()
  • experiment.insert()

Sync (blocking, returns data):

  • create_dataset(), get_dataset()
  • create_prompt(), get_prompt()
  • search_traces(), search_spans()
Lazy Imports for Integrations
python
# ✅ GOOD - integration files assume dependency exists
import anthropic  # Only imported when user uses integration

# ❌ BAD - importing at package level
from opik.integrations import anthropic  # Would fail if not installed

Integration Patterns

Pattern Selection
Library has callbacks? → Pure Callback (LangChain, LlamaIndex)
No callbacks?         → Method Patching (OpenAI, Anthropic)
Callbacks unreliable? → Hybrid (ADK)
Method Patching (OpenAI, Anthropic)
python
from opik.integrations.anthropic import track_anthropic

client = anthropic.Anthropic()
tracked_client = track_anthropic(client)  # Wraps methods
Callback-Based (LangChain)
python
from opik.integrations.langchain import OpikTracer

tracer = OpikTracer()
chain.invoke(input, config={"callbacks": [tracer]})
Decorator-Based
python
@opik.track
def my_function(input: str) -> str:
    # Auto-creates span, captures input/output
    return process(input)

Dependency Policy

  • Avoid adding new dependencies
  • Use conditional imports for integrations
  • Keep version bounds flexible: >=2.0.0,<3.0.0

Batching System

Messages batch together for efficiency:

  • Flush triggers: time (1s), size (100), memory (50MB), manual
  • Reduces HTTP overhead significantly

API Method Naming

python
# CRUD: create/get/list/update/delete
client.create_experiment(name="exp")
client.get_dataset(name="ds")

# Search for complex queries
client.search_spans(project_name="proj")
client.search_traces(project_name="proj")

# Batch for bulk operations
client.batch_create_items(...)

Reference Files

© comet-ml, Apache-2.0. 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 4 other files in .agents/skills/python-sdk of comet-ml/opik.

  • SKILL.md
  • agents/refactor-helper.md
  • error-handling.md
  • good-code.md
  • testing.md

Open the folder on GitHubat commit f217a86

Compare with similar skills

Opik Python SDK Patterns 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.

Opik Python SDK Patterns compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Opik Python SDK Patterns this skillcomet-ml/opik22k—~684Automated safety check: PassApache-2.0
Langfusemajiayu000/claude-skill-registry6663 repos~3.1kAutomated safety check: PassMIT
Failproof AI SDK IntegrationFailproofAI/failproofai5.3k—~6kAutomated safety check: PassCustom licence
Upgrade Stripekanchengw/cnllm1754 repos~1.4kAutomated safety check: PassApache-2.0
Sentence Transformers EmbeddingsOrchestra-Research/AI-Research-SKILLs13k3 repos~1.6kAutomated safety check: PassMIT
Langchain Dependencieslangchain-ai/langchain-skills1.3k1 repos~3.6kAutomated safety check: PassMIT

Similar skills

  • Langfuse

    majiayu000/claude-skill-registry

    Expert in Langfuse - the open-source LLM observability platform.

    666 GitHub starsUsed in 3 repos~3.1k tokens
    AI & LLM EngineeringAuto-check passed
  • Failproof AI SDK Integration

    FailproofAI/failproofai

    Helps instrument a custom Python or TypeScript agent to record events for Failproof AI, verify what gets written, and run an evaluator worker that scores the runs.

    5.3k GitHub stars~6k tokensUpdated yesterday
    AI & LLM EngineeringAuto-check passed
  • Upgrade Stripe

    kanchengw/cnllm

    Guide for upgrading Stripe API versions and SDKs. An agent skill from kanchengw/cnllm.

    175 GitHub starsUsed in 4 repos~1.4k tokens
    AI & LLM EngineeringAuto-check passed
  • Sentence Transformers Embeddings

    Orchestra-Research/AI-Research-SKILLs

    Generates text embeddings locally with the sentence-transformers library for RAG, semantic search, clustering and similarity, with model picks for general, multilingual and legal text.

    13k GitHub starsUsed in 3 repos~1.6k tokens
    AI & LLM EngineeringAuto-check passed
  • Langchain Dependencies

    langchain-ai/langchain-skills

    Official

    INVOKE THIS SKILL when setting up a new project or when asked about package versions, installation, or dependency management for LangChain, LangGraph, LangSmith, or Deep Agents.

    1.3k GitHub starsUsed in 1 repo~3.6k tokens
    AI & LLM EngineeringAuto-check passed
  • Phoenix LLM Observability

    Orchestra-Research/AI-Research-SKILLs

    Sets up Arize Phoenix to trace, evaluate and monitor LLM applications, with instrumentation for OpenAI, LangChain and LlamaIndex and a self-hosted server.

    13k GitHub starsUsed in 2 repos~2.9k tokens
    AI & LLM EngineeringAuto-check passed

More from comet-ml/opik

All 19 skills in this repo
  • Checklist for wiring a new linter into Opik's Code Quality pipeline: the four files to edit, the silent-failure gotchas and the pass/fail verification loop.

    22k GitHub stars~2.3k tokensUpdated today
    Auto-check passed
  • Shows how to add product analytics events to Opik's frontend, Java backend and Python SDK, all reporting through Segment to PostHog with an opik_ name prefix.

    22k GitHub stars~4.4k tokensUpdated today
    Auto-check passed
  • Investigates a failed Opik end-to-end test from CI, TestOps or a local run, decides regression versus flake, and proposes a fix without editing tests.

    22k GitHub stars~1.8k tokensUpdated today
    Auto-check passed
  • Rules for writing PR descriptions, changelog entries and feature documentation in the Opik repository, including the exact headings that CI requires.

    22k GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • Turns a code change into one committed, passing Playwright end-to-end spec by resolving the change scope and handing authoring to a companion skill.

    22k GitHub stars~3.4k tokensUpdated today
    Auto-check passed
  • Starts, rebuilds, and troubleshoots the Opik local dev stack, including an optional Comet Platform integration mode for the Opik team.

    22k GitHub stars~734 tokensUpdated today
    Auto-check passed

Questions about Opik Python SDK Patterns

What does Opik Python SDK Patterns do?

Developer notes for working inside the Opik Python SDK: layered design, async versus blocking calls, integration styles, batching and dependency rules. The skill summarizes how the SDK in `sdks/python` is put together.track`) and a message-processing layer for queueing, batching and retry.

When should I use Opik Python SDK Patterns?

Opik Python SDK Patterns fits situations like: adding a new integration to the Opik Python SDK; deciding whether an SDK call should be queued or blocking; reviewing SDK changes against the project's dependency and naming rules.

How do I install Opik Python SDK Patterns in Claude Code?

Run `npx skills add comet-ml/opik --skill python-sdk -a claude-code`. Or copy the skill folder (.agents/skills/python-sdk in comet-ml/opik) into .claude/skills/python-sdk in your project. Claude Code loads it when a task matches its description.

How do I install Opik Python SDK Patterns in Codex?

Run `npx skills add comet-ml/opik --skill python-sdk -a codex`. Or copy the skill folder (.agents/skills/python-sdk in comet-ml/opik) into .agents/skills/python-sdk in your project. Codex loads it when a task matches its description.

Can I use Opik Python SDK Patterns 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 comet-ml/opik --skill python-sdk -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/python-sdk, .gemini/skills/python-sdk, .github/skills/python-sdk and .opencode/skills/python-sdk in your project.

What does Opik Python SDK Patterns need to run?

SKILL.md names no scripts, command-line tools or credentials: Opik Python SDK Patterns is instructions for the agent only. Our summary lists: A checkout of the Opik repository with `sdks/python`.

Does Opik Python SDK Patterns access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Opik Python SDK Patterns 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 Opik Python SDK Patterns use?

Opik Python SDK Patterns is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Opik Python SDK Patterns use?

About 684 tokens (SKILL.md is roughly 2.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Opik Python SDK Patterns?

Skills that share tags, products or a category with Opik Python SDK Patterns: Langfuse (majiayu000/claude-skill-registry, 666 stars), Failproof AI SDK Integration (FailproofAI/failproofai, 5.3k stars), Upgrade Stripe (kanchengw/cnllm, 175 stars) and Sentence Transformers Embeddings (Orchestra-Research/AI-Research-SKILLs, 13k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Opik Python SDK Patterns?

comet-ml (a GitHub organization) maintains it in comet-ml/opik, which has 22,412 GitHub stars. The repository holds 19 skills in this directory. The repository was last updated on October 7, 2026.

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