Trace Claude Code CLI and Agent SDK sessions, tool usage, and token costs in Arize AX using the Arize Coding Harness Tracing.
Trace Claude Code CLI sessions, tool usage, and token costs with Arize AX for full observability.
Claude Code is Anthropic’s agentic coding tool that lives in your terminal. The Arize Coding Harness Tracing instruments sessions using 16 hook events and sends OpenInference spans to Arize AX or Phoenix. The plugin works with both the Claude Code CLI and the Claude Agent SDK.
claude plugin marketplace add Arize-ai/coding-harness-tracingclaude plugin install claude-code-tracing@coding-harness-tracing
The marketplace flow registers the hooks but skips the interactive wizard, so backend credentials and content-logging preferences must be set directly in ~/.claude/settings.json under env (see Configuration).
curl -sSL https://raw.githubusercontent.com/Arize-ai/coding-harness-tracing/main/install.sh | bash -s -- claude
Windows (PowerShell):
iwr -useb https://raw.githubusercontent.com/Arize-ai/coding-harness-tracing/main/install.bat -OutFile $env:TEMP\install.bat& $env:TEMP\install.bat claude
The installer prompts for your backend (Phoenix or Arize AX) and project name, writes credentials to ~/.arize/harness/config.yaml, and registers the hooks in ~/.claude/settings.json.
git clone https://github.com/Arize-ai/coding-harness-tracing.gitcd coding-harness-tracing./install.sh claude # macOS / Linuxinstall.bat claude # Windows
The curl and local installers write credentials to ~/.arize/harness/config.yaml. Environment variables in ~/.claude/settings.json take precedence and are required for the marketplace install path.
The tracing plugin also works with the Claude Agent SDK in both Python and TypeScript. The SDK loads the plugin locally — no marketplace install is required — but the setup must be done in your application code before the SDK session starts, so the agent cannot configure it at runtime.
You must use ClaudeSDKClient. The standalone query() function does not support hooks, so tracing will not work with it.
The SDK spawns a Claude Code subprocess that does not inherit your shell environment, so tracing env vars must be passed through a settings file referenced from ClaudeAgentOptions:
For Phoenix, replace the Arize AX keys with PHOENIX_ENDPOINT (and optional PHOENIX_API_KEY). The same ARIZE_LOG_* redaction flags from Configuration apply here.
Pass the plugin path and settings file to ClaudeSDKClient:
Python
TypeScript
from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClientPLUGIN_PATH = "./coding-harness-tracing/claude-code-tracing" # or your install pathoptions = ClaudeAgentOptions( plugins=[{"type": "local", "path": PLUGIN_PATH}], settings="./settings.local.json",)async with ClaudeSDKClient(options=options) as client: await client.query("Your prompt here") async for message in client.receive_response(): print(message)
import { ClaudeSDKClient } from "@anthropic-ai/claude-agent-sdk";const PLUGIN_PATH = "./coding-harness-tracing/claude-code-tracing"; // or your install pathconst client = new ClaudeSDKClient({ plugins: [{ type: "local", path: PLUGIN_PATH }], settings: "./settings.local.json",});await client.connect();await client.query("Your prompt here");for await (const message of client.receiveResponse()) { console.log(message);}await client.close();
If you installed via the curl or local installer, the harness ships a Python convenience helper that returns a pre-configured ClaudeAgentOptions (plugin path + setting_sources=["user"] so user-level Claude settings are honored):
from tracing.claude_code.agent_sdk import claude_optionsasync with ClaudeSDKClient(options=claude_options()) as client: ...
Add "ARIZE_DRY_RUN": "true" to your settings file to verify hooks fire without sending data, and tail ~/.arize/harness/logs/claude-code.log to confirm activity.
Full parity — all 16 hooks fire, including SessionStart, Notification, PermissionRequest, and SessionEnd.
Python
SessionStart, SessionEnd, Notification, and PermissionRequest are not available. Session state is lazily initialized on the first UserPromptSubmit; core tracing (LLM, tool, and subagent spans) still works fully.