Claude Code¶
Record every Claude Code session (in the terminal, in an IDE, or in Claude Desktop's Code tab) as a trace: each API request with its model, thinking and tokens, each tool call, and each subagent under the Task call that started it.
Connect it¶
Restart Claude Code if it was running, then open http://127.0.0.1:7842 and set Source to Claude Code. Your existing sessions are imported on first start, so the list is not empty even before you send a new message.
What is recorded, and from where¶
| What | Source |
|---|---|
| Every turn, model request (model, thinking, reply, input, output and cache tokens, cost) and tool call | ~/.claude/projects/<project>/<session>.jsonl |
| Subagents (Task / Agent tool), nested under the spawning call | <session>/subagents/agent-<id>.jsonl and its .meta.json |
| MCP tool calls, grouped by server | mcp__<server>__<tool> names in the transcript |
The transcripts are read in full on first start; there is no day limit. A
session becomes a thread, each prompt you send becomes a run, and the run's
agent node is claude-code.
What connect changes¶
~/.claude/settings.json: HTTP hooks forSessionStart,UserPromptSubmit,PreToolUse,PostToolUse,PostToolUseFailure,SubagentStart,SubagentStop,StopandSessionEnd, all posting tohttp://127.0.0.1:7842/v1/hooks/claude-code. A backup is kept assettings.json.tracesage.bak.- The collector service, if it is not installed yet.
While the collector can read the transcripts it ignores these hooks, so a turn is never recorded twice. The hooks are a fallback for machines where the transcripts are not readable.
Options¶
| Flag | Effect |
|---|---|
--metadata-only |
Keep names, timing, tokens and status, but not prompt, reply or tool text. |
--otel |
Also turn on Claude Code's OpenTelemetry export (CLAUDE_CODE_ENABLE_TELEMETRY and an OTLP endpoint in settings.json). Not needed for traces. |
--mcp |
Add tracesage as an MCP server in ~/.claude.json, so Claude Code can query its own traces. See MCP server. |
--no-trace |
Skip the hooks; useful with --mcp alone. |
--dry-run, --print claude-code |
Show the planned changes and write nothing. |
Limits¶
- Cost is filled in for models that
genai-pricesknows; others shown/a. - Transcripts over 64 MB are skipped.
Disconnect¶
This restores settings.json (and ~/.claude.json if you used --mcp) from
the backups. Recorded runs stay until you delete them; see
Privacy and data.