/opik:opik-optimizefrom Opik
Optimizes prompts using Opik Agent Optimizer: resolves prompt, dataset, and metric, runs bounded optimization, validates on held-out data, and saves the winner as a new prompt version.
Ships in Opik. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Definition of done: an optimized prompt whose score on the metric beats the baseline on data it was not tuned on, the optimization run link in Opik, the cost of getting there, and the winner saved as a new prompt version (when the prompt lives in the library) — with the swap into code left as the next step. If the optimization can't run within a stated budget, stop at the first genuine blocker and return exactly one next step. A prompt that scores higher only on its own training items is not an improvement.
Operate: measure the baseline first, state the budget before spending it, hold data out, pick the algorithm for the failure you see, save the winner where it can be versioned — and change no application code. The only file this skill writes is a runner outside the repo; the prompt is saved to Opik, not into the codebase.
The entry point is /opik-optimize <prompt-name> (a prompt-library prompt), /opik-optimize <path or function> (a prompt in code), or /opik-optimize (find the system prompt in this repo). Infer the rest; treat these as optional overrides:
expected_output if present, else one binary judge) · algorithm (default: MetaPromptOptimizer) · budget (default: n_samples=50, max_trials=10) · model · validation split (default: hold out 20%).Ask only at a genuine, non-inferable blocker (see Blockers).
client.get_chat_prompt(name) (or get_prompt for a text prompt). Note the current version — that is the baseline.messages=[...]; read it verbatim. Note where it lives; you will not edit it.llm span's input.messages on a representative trace.The optimizer's opik_optimizer.ChatPrompt is a different class from the library's opik.ChatPrompt — build it from the raw messages yourself: references/sdk-snippets.md (Resolve the prompt).
The optimizer needs an opik.Dataset whose item keys match the prompt's {variables}: references/sdk-snippets.md (Resolve the dataset).
suite.get_items() → client.get_or_create_dataset("<suite>-optimize", project_name=…) → insert([{**it["data"]} …]).search_traces → {"question": t.input[...], "expected_output": …}) or run /opik-evaluate first.validation_dataset=. Note what it does: the optimizer scores every trial on validation_dataset and uses the train set to show the reasoning model examples — so the validation set is the selection set, and it needs ≥10 items or every candidate ties (a 4-item split logs n_samples … larger than evaluation dataset size and cannot separate prompts). If you need a gain measured on items the optimizer never saw, keep a third split and re-score the winner on it with evaluate(). Fewer than ~20 items in total → say the result will be noisy; below 10 → Blocker.A function (dataset_item, llm_output) -> float, higher is better. Give it a real name (def refund_answer_similarity(...)) — its __name__ becomes the Optimization run's objective name in the UI and result.metric_name; a function called metric shows up as "metric".
expected_output present → heuristic (LevenshteinRatio, Equals, or a task-specific check) — deterministic and free. Prefer a graded metric over exact match: when the baseline scores 0.0 on every item (observed with Equals on a strict output format), every candidate also scores 0.0 and the optimizer has nothing to climb — five trials of flat zeros is a metric problem, not a prompt problem.../opik-evaluate/references/write-judge-prompt.md), wrapped to return its score .value. Multi-objective → MultiMetricObjective.
Never optimize against a judge nobody validated: an unvalidated judge is the easiest thing to overfit.| Failure you see | Optimizer |
|---|---|
| Instructions unclear / underspecified (general default) | MetaPromptOptimizer |
| The model needs examples of the right answer; few-shot is acceptable | FewShotBayesianOptimizer |
| Failures cluster into a few root causes | HierarchicalReflectiveOptimizer (HRPO) |
| Larger budget, want broad search | EvolutionaryOptimizer or GepaOptimizer |
| The prompt is fine, temperature/top_p are not | ParameterOptimizer.optimize_parameter(...) |
| Tool descriptions are the problem | optimize_prompt(..., optimize_tools=True) (optimize_mcp is deprecated) |
uv add opik-optimizer (or pip install opik-optimizer) in a scratch environment, not the repo's lockfile unless the user wants it. Each trial evaluates n_samples items with the task model plus the reasoning model — tell the user the rough call count before running. Provider key absent → Blocker.
The MetaPromptOptimizer run, with the default budget: references/sdk-snippets.md (Run the optimizer).
Write the runner as a temp file outside the repo. The run appears in Opik as an Optimization (result.get_run_link()).
result.initial_score → result.score on the metric; result.details["stop_reason"] and ["trials_completed"]; result.llm_calls, result.llm_cost_total (may be None when the provider returns no cost — say "cost unavailable", don't invent one). Report the validation score, not the training score. A gain within run-to-run noise (rerun the baseline once if in doubt) is "no measurable improvement" — say so rather than shipping a lateral move, and do not save a new version for it. The common cause of a flat result: the answers depend on context the prompt can't contain (retrieval, tools, account data) — then the prompt isn't the bottleneck and the next step is /opik-explain on the worst items, not more trials.
For a library prompt, save the winner as a new version: references/sdk-snippets.md (Save the winner).
For a prompt that lives in code, do not edit the file — return the optimized text and the diff as the next step. Then one next step (see Output): typically "/opik-compare the new version against the regression suite" or "point the app at version vN".
Stop at the earliest blocker and return exactly one next step:
opik configure, then rerun /opik-optimize."/opik-evaluate to build one, or name an existing dataset."OPENAI_API_KEY (or the relevant key) and rerun."synthetic) and rerun."User-facing: a short human message — baseline vs optimized score on validation, the run link, the cost, the algorithm, what changed in the prompt (one or two lines), the new version (or the diff for a code prompt), and the single next step. Not the full trial history.
Underneath (for composition / evals), one shape, with its invariants: references/output-shape.md.
Worked runs (library prompt with a heuristic metric, no real gain, prompt in code, blocked): references/examples.md.
Reporting the training-set score as the gain; optimizing against an unvalidated judge; spending an unbounded budget (no n_samples/max_trials) or not stating it; overwriting the prompt in place instead of a new version; editing the prompt in the codebase; treating opik.ChatPrompt and opik_optimizer.ChatPrompt as interchangeable; optimizing on fewer than ~20 items and calling it a result; choosing the algorithm by novelty rather than by the failure observed; using deprecated optimize_mcp.
Dataset and prompt-library detail live in the opik skill, installed beside this one — paths relative to this file: ../opik/references/evaluation-datasets.md (datasets, insert, versions, metrics), ../opik/references/best-practices.md (prompt library, versioning), ../opik/references/tracing-python.md (SDK client). Judge design and validation: ../opik-evaluate/references/write-judge-prompt.md, ../opik-evaluate/references/validate-evaluator.md. If your host lays skills out differently, locate the opik skill's references/ directory.
Optimizer API (opik-optimizer): https://www.comet.com/docs/opik/agent_optimization/overview. 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.
What SKILL.md sets; muted values are Claude Code's defaults
11 skills in this plugin
/opikReference 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", "track_openai", "add OpikTracer", "version a prompt". To instrument a repo end to end, use the `opik-instrument` skill./opik-annotateSet up human review in Opik — create an annotation queue for a project's traces or threads and give it a custom annotator view, an HTML page that shows annotators each item the way they need to judge it (the email beside the reply, the conversation as chat bubbles) instead of raw JSON. Writes through the Opik MCP when connected, the Opik SDK otherwise. Returns the queue, its link, and what annotators will see. Use for "build a custom annotator view", "set up an annotation queue", "make the review queue show the email and the reply side by side", "change what annotators see", "remove the custom view". Not for automatic scoring (use online-eval) or for finding which traces to review (use diagnose)./opik-compareRun a candidate against the baseline over an Opik test suite and read the numbers back — which cases broke, which got fixed, the per-metric deltas, worst rows, and whether the two runs are comparable — with the Opik compare-view link. Runs via the SDK; reads results via the MCP when connected. Does not issue a ship/no-ship verdict. Use for "did my fix work", "compare against the baseline", "run the regression suite", "why did quality drop", "which cases regressed", "compare these two experiments". Not for the ship/hold decision itself (use verify), live production triage (use diagnose), building an evaluation from scratch (use evaluate), or capturing a single case (use test)./opik-diagnoseSurface the Opik traces worth a developer's attention, ranked by signal — Diagnostics issues first, then errors, failed tool calls, latency, regressions, and low online-eval scores. With the Opik MCP connected it lists the project's agent_insights_issue entities, offers to turn Diagnostics on when the project has it switched off, then fills the gaps with list (filters, sort, a time window); without the MCP it reads the same via the SDK (agent_insights and search_traces), so it works with no MCP. Returns a ranked shortlist, each item ready to hand to the explain skill. Use for "what is broken in production", "which traces need attention", "find failing or slow traces", "which tool calls are failing", "triage my agent". Not for offline experiment results (use evaluate or compare) and not for root-causing one trace (use explain)./opik-evaluateBuild 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-explainRoot-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.2 plugins in one repository ship this exact skill · first indexed Oct 28, 2026
npx claudepluginhub comet-ml/opik-mcp --plugin opikOther plugins' skills for the same job