
opik-instrument
Add Opik tracing to an existing app and verify a real trace lands. Installs the Opik package, detects the language and LLM framework, adds the minimum tracing, runs a safe representative path, confirms a trace in Opik, and returns the trace link. Use for "instrument my code", "add opik tracing", "add observability", "trace my agent". Not for building a new app from scratch, or a review-only pass with no code changes.
- Installs
- 94
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/comet-ml/opik-skills --skill opik-instrument- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads opik-instrument automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Instrument — Add Opik Tracing and Verify a Real Trace
Definition of done: a representative, safely-executed path produces a trace that is confirmed in Opik and a direct trace link is returned. If verification can't be completed safely or autonomously, stop at the first genuine blocker and return exactly one concrete next step. Code edits alone are not success.
Operate: opinionated in execution, conservative in code changes, automatic in routine decisions, uncompromising about verifying value — but never by running something unsafe.
Inputs
The entry point is just /opik-instrument (optionally /opik-instrument <path>). Infer everything else; treat these only as optional overrides the user may pass, never as required setup:
- target path (default: project root) · project name (default: inferred from the repo) · run command (default: an inferred safe path) ·
migrate_prompts(default: false).
Never turn inference into a questionnaire. Ask only when you hit a genuine, non-inferable blocker (see Blockers).
Activation — the only in-scope work
1. Configure Opik (one source of truth)
- If
~/.opik.configexists orOPIK_API_KEYis set, use it as-is. - Otherwise run the official flow:
opik configure(Python) /npx opik-ts configure(TypeScript). - Verify the config before instrumenting: run
opik healthcheck— it validates the config, the install, and backend/workspace reachability. If it fails, stop at that Blocker and fix config or connectivity before adding any tracing. - Only add project-local
.envvars if the project already uses that pattern. Never introduce a second config mechanism; never copy secret values between mechanisms.
2. Detect language & framework
Python (*.py, pyproject.toml) or TypeScript (*.ts, package.json). Identify the LLM framework from imports and pick its integration:
| Import | Integration |
|---|---|
openai / anthropic | track_openai / track_anthropic |
langchain / langgraph | OpikTracer callback |
crewai / dspy / google-genai / bedrock / llama_index / litellm | track_crewai / OpikCallback / track_genai / track_bedrock / LlamaIndexCallbackHandler / OpikLogger |
TS: opik-openai / opik-vercel / opik-langchain | trackOpenAI / OpikExporter / OpikCallbackHandler |
Full list: read ../opik/references/integrations.md (the opik skill, installed beside this one). If that file isn't there, read https://www.comet.com/docs/opik/integrations/overview — never settle for manual spans on a framework that has a native integration just because the reference was unreachable. If the project is already instrumented, audit and add only what's missing — do not re-instrument.
3. Add the minimum tracing
Decision policy, in order:
- Prefer the framework-native integration for provider LLM spans.
- Add manual
@opik.trackspans only for orchestration/tools the integration doesn't cover (type="tool"/"llm"/"guardrail"). A bare@opik.trackproduces the default span type,general— the right choice for an entrypoint/orchestrator. - Never instrument the same operation twice (no
@opik.track(type="llm")on top oftrack_openai). - Mark one entrypoint per independently-runnable agent/service — not necessarily one per repo.
- Decorator order relative to framework decorators (e.g.
@app.route) is framework-dependent — verify per framework; do not assume a universal order. - Scripts: flush at the end (
opik.flush_tracker()/await client.flush()). LiteLLM inside@opik.track: passmetadata={"opik": {"current_span_data": get_current_span_data()}}or traces orphan.
Make the smallest change that lets one representative path emit a trace.
4. Install the Opik package (by default)
Add only the required Opik package(s) via the repo's detected package manager (pip / uv / poetry / npm / pnpm / yarn), through normal project conventions. Preserve the lockfile; do not run generic upgrades; do not install globally; treat unusual lifecycle scripts cautiously. Surface it as a change (e.g. "added opik to pyproject.toml"). If the environment blocks installation → Blocker with the one exact command.
5. Run a safe representative path
Infer a safe command — prefer an existing test, example, or dev script, then a bounded single-request entrypoint. Never run anything that looks like production or does irreversible/expensive work (writes, emails, purchases, mass API calls). If no safe path is inferable → Blocker ("which dev command safely exercises this agent?"). Print the command, then run it.
If the run needs an LLM provider credential (e.g. OPENAI_API_KEY) and it's absent, that's a Blocker — the app can't produce a trace. Note some SDK clients raise at construction (module load), before any span runs, so there is no partial trace to wait on: return blocked with the one next step, don't wait on a flush that never happened.
6. Verify ingestion
Confirm a trace actually arrived — don't assume. Prefer the SDK for verification: it's already installed as part of instrumenting (zero extra moving parts), whereas the Opik MCP is optional and may not be connected.
import opik
client = opik.Opik()
tid = "<trace_id>" # the tracer logs a trace URL/id when the run flushes — use that
detail = client.get_trace_content(tid) # TracePublic: exposes project_id, NOT project_name (accessing .project_name raises)
project = client.rest_client.projects.get_project_by_id(detail.project_id).name
spans = client.search_spans(project_name=project, trace_id=tid) # SEPARATE call; without project_name it searches the default project and returns nothing
# Reconstruct the tree via each span's parent_span_id (the root span has none); check the expected types (general -> tool/llm).
To find the newest trace instead of using a known id, use the client's trace search (e.g. search_traces) scoped to the project. Optionally, if the Opik MCP is connected, list recent traces then read the newest.
Traces are asynchronous — allow a few seconds after the run and make sure the flush ran.
7. Report
Return a short human result + the trace link (see Output), then make the single expansion offer.
Blockers
When you genuinely can't proceed, stop at the earliest blocker and return exactly one next step — never a checklist — and still report the changes already made. Examples:
- "Run
opik configure, then rerun/opik-instrument." - "Install dependencies with
uv sync, then rerun/opik-instrument." - "Which dev command safely exercises this agent?"
- "Instrumented and installed, but the run needs a provider credential — set
OPENAI_API_KEY(or the relevant provider key) and rerun." - "Instrumented and ran, but this environment can't query Opik — open the project and confirm trace
<id>arrived."
Expansion — after the trace lands (one offer, not a funnel)
Do not migrate prompts, add threading, or broaden spans during activation. After verification, make a single consolidated offer of what you found, e.g.:
Tracing is verified. I also found ways to deepen it: 3 Prompt Library candidates, missing conversation threading, and 2 untraced tools. Expand?
Output
User-facing: a short human message — what was instrumented, the trace link, and the one expansion offer (or, if blocked, the single next step plus what changed). Not raw JSON.
Underneath (for composition / evals), a small state model:
status:verified|blocked|already_verified|unsupportedchanges:files_changed,dependency_added,config_source,entrypoints_instrumented,integrations_addedverification:command_run,trace_id,trace_urlblocker:reason,next_stepexpansion_opportunities:prompts,threads,spans
Invariants: verified must carry a trace_id/trace_url; blocked must carry exactly one next_step and still report changes; already_verified = existing instrumentation exercised and confirmed; unsupported explains the unsupported language/shape and modifies nothing.
Examples
Normal — no LLM framework. A Python script with a retrieve() tool and a local generate(). No provider to wrap → add @opik.track(type="tool") on retrieve, bare @opik.track (→ general) on the entrypoint, flush in __main__; uv add opik; run it; confirm the general → tool → llm trace via the SDK; return the link. → verified.
Framework — OpenAI. from openai import OpenAI. Use the native integration: client = track_openai(OpenAI()); leave the LLM-calling function undecorated (the integration traces it); mark the entrypoint; install opik; run. If OPENAI_API_KEY is missing, OpenAI() raises at construction → blocked: "set OPENAI_API_KEY, then rerun" (report the edits already made).
Already instrumented. @opik.track / track_openai already present. Audit only — add a missing entrypoint or flush, do not re-instrument; run + verify. → already_verified.
Anti-patterns
Double-wrapping (integration + manual span on the same call); orphaned LiteLLM traces (missing current_span_data); missing flush in scripts; overwriting or duplicating config; running an unsafe/production path just to force a trace; broad dependency upgrades when only opik is needed; migrating prompts during activation.
References
SDK detail lives in the opik skill, installed beside this one. Read the files directly — paths are relative to this file: ../opik/references/tracing-python.md, ../opik/references/tracing-typescript.md, ../opik/references/integrations.md, ../opik/references/observability.md. If your host lays skills out differently, locate the opik skill's references/ directory.
If the opik skill isn't installed, say so in the report and use https://www.comet.com/docs/opik/ rather than working from memory.
FAQ
What does the opik-instrument skill do?
Add Opik tracing to an existing app and verify a real trace lands. Installs the Opik package, detects the language and LLM framework, adds the minimum tracing, runs a safe representative path, confirms a trace in Opik, and returns the trace link. Use for "instrument my code", "add opik tracing", "add observability", "trace my agent". Not for building a new app from scratch, or a review-only pass with no code changes.
How do I install opik-instrument?
Run npx skills add https://github.com/comet-ml/opik-skills --skill opik-instrument in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/opik-instrument/ (personal) or .claude/skills/opik-instrument/ (project).
Which AI agents can use opik-instrument?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is opik-instrument safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains opik-instrument?
It is published by comet-ml in comet-ml/opik-skills. It has 94 recorded installs.
More from comet-ml/opik-skills
opik
comet-ml/opik-skills
Reference for the Opik SDK — tracing, span types, framework integrations, threads, and the prompt library (Python, TypeScript, REST). Use for "what span types exist", "how do I flush", "trackopenai", "add OpikTracer", "version a prompt". To instrument a repo end to end, use the opik-instrument skill.
opik-evaluate
comet-ml/opik-skills
Build an LLM evaluation and run it against the app, returning an Opik experiment with scores and its link. Picks a test suite with judge assertions or a dataset with metrics, sources cases from traces or synthetic data, scores heuristics-first then one-failure-mode judges, runs client-side via the SDK or server-side for prompt-only targets, and reads the scores back. Covers RAG evaluation, error analysis, writing and validating LLM judges against human labels, and auditing an existing eval pipeline. Use for "evaluate my agent", "measure quality", "build an eval", "write an LLM judge for hallucinations", "audit our evaluation pipeline", "how good is my RAG", "set up evals for this". Not for before/after on an existing suite (use compare), one regression case (use test), scoring production traffic (use online-eval), or the ship/hold decision (use verify).
opik-explain
comet-ml/opik-skills
Root-cause a specific Opik trace, or a pattern across traces, and return a grounded explanation. Uses the hosted Opik MCP when it is connected, and falls back to SDK scripting otherwise. Returns the root cause, the evidence spans as clickable Opik UI links, and one suggested next step. Use for "why did this trace fail", "explain this trace", "debug this trace", "why is my agent slow or wrong". Not for adding tracing to an app (use the instrument skill) or for changing code.
opik-test
comet-ml/opik-skills
Open the skill to read its SKILL.md instructions.
Popular ai & agents skills
google-agents-cli-publish
google/agents-cli
This skill should be used when the user wants to "publish an agent", "publish my ADK agent", "register an agent with Gemini", "publish to Gemini" (formerly Gemini Enterprise), or needs guidance on the agents-cli publish gemini command. Also use when the user wants to "manage agents in Agent Registry", "list/update/delete registered agents", or "register an MCP server". Covers ADK vs A2A registration modes, programmatic and interactive usage, flag reference, auto-detection from deployment metadata, Agent Registry fleet management, and troubleshooting. Part of the agents-cli skills suite. Do NOT use for deployment (use google-agents-cli-deploy).
google-agents-cli-eval
google/agents-cli
This skill should be used when the user wants to "run an evaluation", "evaluate my agent", "evaluate my ADK agent", "write an eval dataset", "analyze eval failures", "compare eval results", "optimize agent", or needs guidance on the Gemini platform eval methodology and the Quality Flywheel. Covers eval metrics, dataset schema, LLM-as-judge scoring, and common failure causes. Applies to any agents-cli project, whatever framework the agent is written in. Do NOT use for agent API code patterns (ADK: use google-agents-cli-adk-code), deployment (use google-agents-cli-deploy), or project scaffolding (use google-agents-cli-scaffold).
skill-creator
anthropics/skills
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
codex-pet
prime-skills/runcomfy-agent-skills
Codex Pet generator on RunComfy. Build a Codex-compatible Codex Pet spritesheet.webp + pet.json from a single reference image, drop it into ${CODEXHOME:-$HOME/.codex}/pets/ / and Codex picks it up as a custom Codex Pet next to the 8 built-ins. This skill produces the exact Codex Pet atlas Codex expects (1536x1872 PNG/WebP, 8 cols x 9 rows, 192x208 cells, 9 animation states — idle, running-right, running-left, waving, jumping, failed, waiting, running, review). Calls OpenAI GPT Image 2 edit ONCE via the local RunComfy CLI as runcomfy run openai/gpt-image-2/edit to produce a canonical Codex Pet pose, then assembles all 9 animation rows programmatically with ImageMagick micro-transforms — no Codex Pro, no $imagegen, no OPENAIAPIKEY required, only RUNCOMFYTOKEN. Triggers on "codex pet", "create codex pet", "make codex pet", "hatch codex pet", "/hatch image", "desktop pet codex", "codex pets", "spritesheet.webp", or any explicit ask to build a custom pet for OpenAI Codex.
full-output-enforcement
leonxlnx/taste-skill
Overrides default LLM truncation behavior. Enforces complete code generation, bans placeholder patterns, and handles token-limit splits cleanly. Apply to any task requiring exhaustive, unabridged output.
executing-plans
obra/superpowers
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available