trace-claude-code

A command for turning Opik tracing on or off for Claude Code sessions. Opik is a service that records session activity for debugging and analysis.

In plain words
What is it for?
Use it to enable tracing, disable it, or turn on debug logging at project or user level.
Why use it?
It lets you control whether tracing applies to one project or all projects, including opting a project out of a global setting.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/comet-ml/opik-claude-code-plugin/trace-claude-code
Clone the repo
git clone --depth 1 https://github.com/comet-ml/opik-claude-code-plugin
Per session 9 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 986 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00009 $0.00986
Opus 5 $0.00005 $0.00493
Sonnet 5 $0.00002 $0.00197
Haiku 4.5 $0.00001 $0.00099

Measured 2d ago against content hash 5e0c8fd8f888, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

trace-claude-code scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/trace-claude-code.md · 88 lines

How it starts

The opening of the file, as written. The whole thing — 88 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Opik Claude Code Session Tracing

This command enables/disables automatic tracing of your Claude Code sessions to Opik.

Based on the user's request: $ARGUMENTS

Scope

Tracing can be enabled at two levels:

  • Project (default): .claude/.opik-tracing-enabled in the current project directory.
  • Global (--global flag): ~/.claude/.opik-tracing-enabled, which enables tracing for every project.

The project-level file takes precedence over the global one, so a single project can override the global setting (including turning tracing off while it is enabled globally).

File Semantics

For both the project and global files:

  • File contains off or disabled → tracing disabled (used to opt a project out of a global enable)
  • File contains debug → tracing + debug logging
  • File exists with any other content (or empty) → tracing enabled
  • File doesn't exist → no opinion at this level (fall through to the next level)

Resolution order (first match wins): project off → project enabled → global enabled → disabled.

Actions

Determine the target file from the flags:

  • If --global (or --user) is present, target is ~/.claude/.opik-tracing-enabled.
  • Otherwise, target is .claude/.opik-tracing-enabled in the current directory.

If the request contains "start":

  • Create the parent .claude/ directory if needed with mkdir -p.
  • If --debug is present, write debug to the target file.
  • Otherwise, write an empty file / touch the target file (content doesn't matter).
  • Confirm scope: "Opik session tracing enabled [globally for all projects | for this project]. Takes effect immediately for new conversation turns."

If the request contains "stop":

  • If --global is present: delete ~/.claude/.opik-tracing-enabled. Confirm: "Opik session tracing disabled globally."
  • Otherwise (project stop):
    • Check whether the global file ~/.claude/.opik-tracing-enabled exists and is not itself off/disabled.
    • If global tracing is active, write off to .claude/.opik-tracing-enabled (an explicit opt-out that overrides the global enable), and confirm: "Opik session tracing disabled for this project (overriding the global setting)."
    • If global tracing is not active, delete .claude/.opik-tracing-enabled, and confirm: "Opik session tracing disabled for this project."

Read the full file on GitHub · 88 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 88 lines · 0 tokens per session scan A 5e0c8fd8f888

Subscribe to this mod's changes

trace-claude-code is a command published in the GitHub repository comet-ml/opik-claude-code-plugin (21 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 9 tokens to every session and 986 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.