Claude Code Log Format
This guide documents where Claude Code stores logs and what the JSONL structure looks like, so we can map entries into UIMessage parts later.Locations
Claude Code stores data under~/.claude/:
~/.claude/history.jsonl: lightweight user prompt history (no full assistant/tool detail).~/.claude/projects/<project-slug>/*.jsonl: per-session logs (full message + tool content).
Version note: Log paths vary by Claude Code version. Older versions use
*.jsonl files directly in the project folder. Newer versions use a sessions/ subdirectory with session.jsonl and metadata.json per session.JSONL Record Structure
Each line is a JSON object. Common top-level fields:uuid,parentUuid: event id and parent link for threading.sessionId: per-session UUID (matches filename).type:"user"or"assistant".timestamp: ISO timestamp.cwd,gitBranch,version: environment metadata.agentId,slug,requestId: present for agent sidechains.message: the LLM message payload (role/content/usage/etc).isApiErrorMessage: true for API errors (e.g., rate/billing issues).toolUseResult: optional, structured tool result payload for some tool outputs.
User Message Example
Assistant Message Example (Text)
Assistant Tool Use Example
Tool Result Example (User Role)
Tool results appear as atype: "user" record with a tool result payload in message.content.
If the tool returns file content, toolUseResult mirrors it with structured metadata.
Mapping to UIMessage
Suggested mapping to Vercel AI SDKUIMessage parts:
- There is no explicit reasoning block in the JSONL observed so far.
- Tool result linkage uses
tool_use_idto connect tool calls and outputs. history.jsonlis insufficient for UIMessage reconstruction (missing assistant/tool detail).
Open Gaps
- Reasoning/extended thinking blocks: not observed in JSONL logs yet.
- Streaming state: no explicit
streamingmarkers observed. - Source citations: not observed; likely absent from Claude Code logs.