One read of Claude Code CLIclaude-code-20261201T153701Z
2 pages moved out of 221 read.
Pages moved
2
significant first
Pages read
221
in this capture
Captured
15:37 UTC
Corpus hash
181883dd4f73
corpus-hash
What this read moved
1-2 of 2code-mode Changed · +9 / -2 lines
#### Trace calls from code
from line 51
5151* **Surface**: an interactive `claude` session in a terminal. Code Mode doesn't work with the VS Code panel, the Desktop app, or cloud sessions
5252* **Agent teams**: to use Code Mode with [agent teams](https://code.claude.com/docs/en/agent-teams.md) on, you need v2.1.326 or later. Teammates run in Code Mode in the default [in-process display mode](https://code.claude.com/docs/en/agent-teams.md#choose-a-display-mode), and start without it in split panes
5353* **Mods**: to use Code Mode with a [mod](https://code.claude.com/docs/en/plugins/mods/overview.md) that hooks tool calls, you need v2.1.327 or later. If you're on the `stable` channel and an update doesn't reach that version, [switch to `latest`](https://code.claude.com/docs/en/setup#configure-release-channel)
54* **Telemetry settings**: to use Code Mode with [feature-flag fetching off](https://code.claude.com/docs/en/env-vars.md#features-that-need-feature-flag-fetching) or [OpenTelemetry](https://code.claude.com/docs/en/monitoring-usage.md) events and metrics on, you need v2.1.329 or later. Keep [tracing](https://code.claude.com/docs/en/monitoring-usage.md#traces-beta) off on any version
54* **Telemetry settings**: to use Code Mode with [feature-flag fetching off](https://code.claude.com/docs/en/env-vars.md#features-that-need-feature-flag-fetching) or [OpenTelemetry](https://code.claude.com/docs/en/monitoring-usage.md) events and metrics on, you need v2.1.329 or later. With [tracing](https://code.claude.com/docs/en/monitoring-usage.md#traces-beta) on, you need v2.1.333 or later
5555* **Installation**: the [native build](https://code.claude.com/docs/en/setup.md) of Claude Code
5656* **Windows**: [Git for Windows](https://git-scm.com/downloads/win) is installed
5757
from line 174
174174* **Read classifier verdicts**: in auto mode, a call that the classifier's [review of the code](#permission-checks) covers has no `classifier_verdict`. Look for the verdict on the `REPL` tool's `tool_decision` events that have that call's `request_id`. If you find more than one, the events don't show which piece of code made the call
175175* **Keep secrets out of your backend**: code can read a value, such as a token in a file, and pass it to another call. Leave `OTEL_LOG_TOOL_DETAILS` unset if your backend shouldn't receive those values
176176
177#### Trace calls from code
178
179On v2.1.333 or later, look for calls from code under the `claude_code.tool.execution` span of the `REPL` call that ran the code. Expect the same [span types](https://code.claude.com/docs/en/monitoring-usage.md#span-hierarchy) as for a call that Claude makes directly. Before your users turn on Code Mode, decide what you export and what you audit from:
180
181* **Keep tool output out of your backend**: code can read far more than it shows Claude. Leave `OTEL_LOG_TOOL_CONTENT` unset if your backend shouldn't receive what calls from code return. In that case, also leave `OTEL_LOG_TOOL_DETAILS`, `OTEL_LOG_RAW_API_BODIES`, `OTEL_LOG_ASSISTANT_RESPONSES`, and `OTEL_LOG_USER_PROMPTS` unset, because each can send parts of that output
182* **Audit from events**: after code makes many calls, you can lose spans if Claude Code exits right away or your collector falls behind. Export [events](https://code.claude.com/docs/en/monitoring-usage.md#events) too and audit from those. To avoid losing events as well, run a collector that responds quickly and accepts large requests
183
177184## Permissions and long-running code
178185
179186Your permission mode decides how the code that Claude writes is checked and whether you can talk to Claude while the code runs.
from line 343
336343| `it only works with Opus 5.5, Sonnet 5.5 and later models` | Pass the full name of a [supported model](#requirements) that your account can use, for example `--model claude-opus-5-5`, or on Microsoft Foundry the name of your deployment of one. Avoid aliases such as `sonnet`, which [select older models on some providers](https://code.claude.com/docs/en/model-config.md#model-aliases) |
337344| `it doesn't work in background jobs` | Start in the foreground, without `--remote-control`. If the reason shows in a teammate's split pane, use the [in-process display mode](https://code.claude.com/docs/en/agent-teams.md#choose-a-display-mode) to run teammates in Code Mode |
338345| `it needs settings that Claude Code downloads from Anthropic` | [Update Claude Code](https://code.claude.com/docs/en/setup.md#update-claude-code) to meet the [telemetry settings requirement](#requirements). To stay on your version, unset the variable that [turns off feature-flag fetching](https://code.claude.com/docs/en/env-vars.md#features-that-need-feature-flag-fetching), such as `DISABLE_TELEMETRY` |
339| `OpenTelemetry tracing is on` | Unset `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA`, `ENABLE_ENHANCED_TELEMETRY_BETA`, and `ENABLE_BETA_TRACING_DETAILED` if you can work without [traces](https://code.claude.com/docs/en/monitoring-usage.md#traces-beta) |
346| `OpenTelemetry tracing is on` | To keep [traces](https://code.claude.com/docs/en/monitoring-usage.md#traces-beta) on, [update Claude Code](https://code.claude.com/docs/en/setup.md#update-claude-code) to meet the [telemetry settings requirement](#requirements). To stay on your version, unset `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA`, `ENABLE_ENHANCED_TELEMETRY_BETA`, and `ENABLE_BETA_TRACING_DETAILED` if you can work without traces |
340347| `OpenTelemetry is on` | To keep events and metrics on, [update Claude Code](https://code.claude.com/docs/en/setup.md#update-claude-code) and meet the [telemetry settings requirement](#requirements). To stay on your version, unset `CLAUDE_CODE_ENABLE_TELEMETRY` and `ENABLE_BETA_TRACING_DETAILED` if you can work without [OpenTelemetry export](https://code.claude.com/docs/en/monitoring-usage.md) |
341348| `it doesn't yet work with the plugin` | [Update Claude Code](https://code.claude.com/docs/en/setup.md#update-claude-code) to meet the [mods requirement](#requirements). To stay on your version, run `/plugin` and disable each plugin that the reason names. If your organization turned one on, ask your administrator to turn it off |
342349| `it doesn't yet work with an installed mod` | [Update Claude Code](https://code.claude.com/docs/en/setup.md#update-claude-code) to meet the [mods requirement](#requirements). To stay on your version, run `/plugin` and disable each mod you installed |
monitoring-usage Changed · +6 / -3 lines
from line 122
122122| `OTEL_LOG_TOOL_DETAILS` | Enable logging of tool parameters and input arguments in tool events and trace span attributes: Bash commands, MCP server and tool names, skill names, user-authored workflow names, and tool input. Also enables custom, plugin, and MCP command names on `user_prompt` events, and real agent, skill, plugin, and MCP server and tool names on the [cost and token counters](#cost-counter) (default: disabled). For Claude Desktop's built-in servers, in sessions Claude Desktop owns, `mcp_server_name`/`mcp_tool_name` emit on `tool_decision`/`tool_result` even with the flag off. The exception requires Claude Code v2.1.214 or later | `1` to enable |
123123| `OTEL_LOG_TOOL_CONTENT` | Enable logging of tool content in the [`tool.output` span event](#tool-output-span-event) (default: disabled). Span attributes carry tool content under [their own gates](#new-context-gates). Requires [tracing](#traces-beta). Content is truncated at the content limit (60 KB by default) | `1` to enable |
124124| `OTEL_LOG_MANAGED_SETTINGS` | Add the redacted managed settings, and a SHA-256 digest of the settings before redaction, to [managed settings resolved](#managed-settings-resolved-event) events (default: disabled). A value in project or local settings doesn't turn it on. Requires Claude Code v2.1.274 or later | `1` to enable |
125| `OTEL_LOG_RAW_API_BODIES` | Emit the full Anthropic Messages API request and response JSON as `api_request_body` / `api_response_body` log events (default: disabled). Bodies can include the entire conversation history. Enabling this implies consent to everything `OTEL_LOG_USER_PROMPTS`, `OTEL_LOG_TOOL_DETAILS`, and `OTEL_LOG_TOOL_CONTENT` would reveal | `1` for inline bodies truncated at the content limit (60 KB by default), or `file:<dir>` for untruncated bodies on disk with a `body_ref` pointer in the event |
125| `OTEL_LOG_RAW_API_BODIES` | Emit the full Anthropic Messages API request and response JSON as `api_request_body` / `api_response_body` log events (default: disabled). Bodies can include the entire conversation history. Enabling this implies consent to everything `OTEL_LOG_USER_PROMPTS`, `OTEL_LOG_TOOL_DETAILS`, and `OTEL_LOG_TOOL_CONTENT` would reveal. In [Code Mode](https://code.claude.com/docs/en/code-mode.md#trace-calls-from-code), your backend can receive output through the last two that the bodies lack | `1` for inline bodies truncated at the content limit (60 KB by default), or `file:<dir>` for untruncated bodies on disk with a `body_ref` pointer in the event |
126126| `CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTH` | Content limit: the maximum length of content-bearing attributes such as model responses, tool content, system prompts, and raw API bodies, truncation marker included, in UTF-16 code units (default: 61440, i.e. 60 KB). The default is sized for backends that cap attribute values at 64 KB; raise it only if your backend accepts larger values, or lower it to cut telemetry volume. When an OpenTelemetry SDK attribute limit, `OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT` or one of its logrecord and span variants, is set lower, Claude Code truncates at that smaller value so the `[TRUNCATED ...]` marker stays within the SDK limit | `262144` |
127127| `OTEL_RESOURCE_INCLUDE_HOST` | Add the machine's name and ID to the resource attributes of metrics, events, and traces (default: disabled). See [Identify the machine a session ran on](#identify-the-machine-a-session-ran-on). Requires Claude Code v2.1.326 or later | `1` to enable |
128128| `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE` | Metrics temporality preference (default: `delta`). Set to `cumulative` if your backend expects cumulative temporality | `delta`, `cumulative` |
from line 224
224224
225225Each user prompt starts a `claude_code.interaction` root span. API calls, tool calls, and hook executions are recorded as its children. Tool spans have two child spans of their own: one for the time spent waiting on a permission decision and one for the execution itself. When the Agent tool, or legacy Task tool, spawns a subagent, the subagent's API and tool spans nest under the parent's `claude_code.tool` span.
226226
227In Code Mode, [calls from code](https://code.claude.com/docs/en/code-mode.md#trace-calls-from-code) nest under the `REPL` tool's `claude_code.tool.execution` span.
228
227229```text theme={null}
228230claude_code.interaction
229231├── claude_code.llm_request
from line 305
303305| `parent_agent_id` | Identifier of the agent that spawned this one. Absent for the main session and for agents spawned directly from it | |
304306| `workflow.run_id` | Run identifier of the Workflow tool run that spawned this agent, prefixed `wf_`. Absent for agents not spawned by a workflow | |
305307| `workflow.name` | Name of the workflow that spawned this agent. User-authored names are replaced with `custom` unless the gate is set | `OTEL_LOG_TOOL_DETAILS` |
306| `tool_use_id` | The model's `tool_use` block id for this call. Matches the `tool_use_id` on the [tool\_result](#tool-result-event) and [tool\_decision](#tool-decision-event) events and in hook payloads, so you can join the span to those records | |
308| `tool_use_id` | The model's `tool_use` block id for this call, or an ID that Claude Code generates for a [call from code](https://code.claude.com/docs/en/code-mode.md#monitor-code-mode-with-opentelemetry) in Code Mode. Matches the `tool_use_id` on the [tool\_result](#tool-result-event) and [tool\_decision](#tool-decision-event) events and in hook payloads, so you can join the span to those records | |
307309| `gen_ai.tool.call.id` | Same value as `tool_use_id`. OpenTelemetry GenAI semantic convention | |
308310| `file_path` | Target file path for Read, Edit, and Write tools | `OTEL_LOG_TOOL_DETAILS` |
309311| `full_command` | Command string for the Bash tool | `OTEL_LOG_TOOL_DETAILS` |
from line 396
394396| `system_prompt_preview` | `claude_code.llm_request` | First 500 characters of the complete system prompt sent with the request | `OTEL_LOG_USER_PROMPTS` |
395397| `user_system_prompt` | `claude_code.llm_request` | Only the system prompt text you provide via the `systemPrompt` SDK option or `--system-prompt` and `--append-system-prompt` flags. Emitted once per session rather than per request | `OTEL_LOG_USER_PROMPTS` |
396398| `response.model_output` | `claude_code.llm_request` | Text of the model's response to the request | `OTEL_LOG_USER_PROMPTS` |
397| `new_context` | `claude_code.tool` | The tool call's result, whatever the tool | `OTEL_LOG_TOOL_CONTENT` |
399| `new_context` | `claude_code.tool` | The tool call's result. Absent for `REPL` and `Poll`, the tools that run [Code Mode](https://code.claude.com/docs/en/code-mode.md#trace-calls-from-code) code and return its output | `OTEL_LOG_TOOL_CONTENT` |
398400| `tool_input` | `claude_code.tool` | The tool call's serialized input | `OTEL_LOG_TOOL_DETAILS` |
399401
400402Under detailed beta tracing with `OTEL_LOG_USER_PROMPTS=1`, Claude Code also emits a `claude_code.system_prompt` event that carries the complete system prompt, truncated at the content limit. It arrives the first time a session sends each distinct system prompt, and again after compaction.
from line 1888
18861888 * With `=file:<dir>`, Claude Code writes untruncated bodies to `.request.json` and `.response.json` files under that directory, and the events carry a `body_ref` path instead of the inline body. Ship the directory with a log collector or sidecar rather than through the telemetry stream.
18871889
18881890 For each successful response, Claude Code also appends one line to `index.jsonl` in that directory, linking the response file to the request file that produced it and to the transcript message it became. Each line holds no message content, and the [API response body event](#api-response-body-event) section lists its fields. The index file requires Claude Code v2.1.274 or later
1891* In [Code Mode](https://code.claude.com/docs/en/code-mode.md#trace-calls-from-code), review `OTEL_LOG_TOOL_CONTENT` and `OTEL_LOG_TOOL_DETAILS` separately from raw bodies. With either set, your backend can receive output that code read but didn't return to Claude, which the bodies can lack
18891892* The machine's name and ID aren't included by default. To include them as `host.name` and `host.id`, set [`OTEL_RESOURCE_INCLUDE_HOST=1`](#identify-the-machine-a-session-ran-on). A host name often contains a person's name, and `host.id` is a lasting identifier for the machine. If you set the variable in managed settings, tell the people who use those machines, because Claude Code shows them no notice.
18901893
18911894## Monitor Claude Code on Amazon Bedrock