<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Usage on Welcome to Christophe Nasarre's Blog</title><link>https://chrisnas.github.io/tags/usage/</link><description>Recent content in Usage on Welcome to Christophe Nasarre's Blog</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sun, 22 Nov 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://chrisnas.github.io/tags/usage/index.xml" rel="self" type="application/rss+xml"/><item><title>SessionViewer and Claude Code: transcripts, subagents, usage and plans</title><link>https://chrisnas.github.io/posts/2026-11-22_sessionviewer-and-claude-code/</link><pubDate>Sun, 22 Nov 2026 00:00:00 +0000</pubDate><guid>https://chrisnas.github.io/posts/2026-11-22_sessionviewer-and-claude-code/</guid><description>How SessionViewer rebuilds Claude Code 2.1.x history from prompt history, main JSONL, subagents and Markdown plans.</description><content:encoded><![CDATA[<p>The <a href="/posts/2026-11-15_sessionviewer-and-cursor/">previous post</a> introduced <code>SessionViewer</code>, the passive-history application that reconstructs a catalog of past sessions by scanning files that providers have already written. SessionViewer does not need hooks to collect that history. Cursor required two overlapping sources (agent transcript files and a Desktop SQLite database) plus a reconciliation pass that compared duplicate records before displaying them.</p>
<p>Claude Code has no corresponding SQLite database. At first, that sounds easier.</p>
<p>In practice, Claude&rsquo;s storage is not simpler. Claude Code can spread one session across global prompt history, a current transcript, short-lived child agents called subagents, and a Markdown plan stored elsewhere. Prompt history can outlive the detailed transcript, and transcript activity can survive after a plan file is heavily updated.</p>
<p>This is the seventh post in the series:</p>
<ol>
<li><a href="/posts/2026-08-23_spying-on-cursor-hooks/">Spying on Cursor: agent hooks, payloads and a simple observer</a></li>
<li><a href="/posts/2026-09-14_rebuilding-cursor-conversation/">Rebuilding the Agent conversation</a></li>
<li><a href="/posts/2026-09-20_spying-on-claude-code-hooks/">Spying on Claude Code: more lifecycle events, different blind spots</a></li>
<li><a href="/posts/2026-09-27_spying-on-github-copilot-twice/">Spying on GitHub Copilot twice: CLI hooks versus VS Code</a></li>
<li><a href="/posts/2026-10-09_beyond-hooks-transcript-logs/">Beyond hooks: enriching live sessions with undocumented transcript logs</a></li>
<li><a href="/posts/2026-11-15_sessionviewer-and-cursor/">SessionViewer and Cursor: reconstructing history from JSONL, SQLite and plans</a></li>
<li><strong>SessionViewer and Claude Code: transcripts, subagents, usage and plans</strong> (this post)</li>
<li>SessionViewer and Copilot CLI: decoding events.jsonl, turns, usage and plans</li>
</ol>
<p>I will not repeat all the shared SessionViewer machinery from Post 6. The selected harnesses in the UI control which providers are scanned and cached. Scanning happens at startup or after <strong>Refresh</strong>, <strong>Force full refresh</strong>, or enabling a provider; there is no file watcher, periodic scan or process probe. This post starts with Claude Code&rsquo;s files.</p>
<h2 id="the-claude-files-family">The <code>.claude</code> files family</h2>
<p>Claude stores its files under <code>%USERPROFILE%\.claude</code> by default. The <code>CLAUDE_CONFIG_DIR</code> environment variable can override that complete configuration root. The main transcript files use JSON Lines (JSONL), a text format with one JSON record per line:</p>
<p><img alt="Claude Code prompt history, transcript, subagent and plan sources" loading="lazy" src="/posts/2026-11-22_sessionviewer-and-claude-code/ClaudeSessionReconstruction.png"></p>
<p>SessionViewer reads the transcript and subagent directories directly, in addition to the <code>history.jsonl</code> file that contains prompts from all sessions. Claude&rsquo;s <strong>projects</strong> are what we usually call <strong>workspaces</strong>. Claude stores them under subfolders of the <code>.claude\projects</code> directory. These subfolders encode workspace folders: for example, <code>C--github-chrisnas-MyRepo</code> can represent <code>C:\github\chrisnas\MyRepo</code>.</p>
<p>A project directory can also contain <code>sessions-index.json</code> and <code>.session_cache.json</code>. These optional metadata sources can preserve a session title, first prompt, timestamps, workspace candidates, and other session details after the main transcript disappears. They do not recreate missing assistant messages, tools, or turns. SessionViewer also reads subagent JSONL and <code>.meta.json</code> files recursively below a session&rsquo;s <code>subagents</code> directory.</p>
<p>SessionViewer scanner is deliberately separate from <code>ClaudeSpy.App</code>, the live hook viewer. ClaudeSpy learns transcript paths from Claude Code hook payloads, follows new lines as Claude writes them and can copy a short-lived subagent transcript into a HarnessSpy-owned companion file. SessionViewer instead scans the files that still exist under <code>.claude</code>. If Claude Code deletes a transcript or subagent file before a scan begins, SessionViewer cannot recreate its conversation rows. SessionViewer can recover a missing plan artifact only when transcript rows preserve explicit plan evidence, as described later.</p>
<h2 id="the-main-transcript-stores-the-conversation">The main transcript stores the conversation</h2>
<p>Claude Code stores each session conversation in a main <code>.jsonl</code> transcript file under a subfolder corresponding to a project or workspace:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">&lt;root&gt;\projects\&lt;encoded-project-workspace&gt;\&lt;session-id&gt;.jsonl
</span></span></code></pre></td></tr></table>
</div>
</div><p>SessionViewer can discover this file without an index or cache entry. A transcript row can provide the native <code>sessionId</code>, current working directory (<code>cwd</code>), timestamps, prompts, assistant messages, tool calls, tool results, usage and plan activity.</p>
<p>The root-level <code>history.jsonl</code> is a separate file that stores prompts from all sessions. The <code>display</code> field contains the prompt, while <code>sessionId</code> identifies its session. Claude also uses that ID as the name of the <code>.jsonl</code> file in the project subfolder:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span><span class="nt">&#34;display&#34;</span><span class="p">:</span><span class="s2">&#34;Please do this and that&#34;</span><span class="p">,</span> <span class="nt">&#34;timestamp&#34;</span><span class="p">:</span><span class="mi">1792482255511</span><span class="p">,</span><span class="nt">&#34;project&#34;</span><span class="p">:</span><span class="s2">&#34;C:\\github\\chrisnas\\MyRepo&#34;</span><span class="p">,</span><span class="nt">&#34;sessionId&#34;</span><span class="p">:</span><span class="s2">&#34;12345678-1234-beef-beef-1234abcd5678&#34;</span><span class="p">}</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>This record means that the prompt belongs to the discussion stored in <code>%USERPROFILE%\.claude\projects\C--github-chrisnas-MyRepo\12345678-1234-beef-beef-1234abcd5678.jsonl</code>.</p>
<h2 id="joining-main-and-subagent-evidence">Joining main and subagent evidence</h2>
<p>A workspace is the folder under which SessionViewer groups a session. Among the sources covered in this post, SessionViewer prefers Claude&rsquo;s <code>cwd</code> field from the normal main transcript. If that file does not supply <code>cwd</code>, SessionViewer tries one unique project path from <code>history.jsonl</code>, a successfully decoded project-directory name (for example, <code>C--repo</code> can represent <code>C:\repo</code>), and finally a subagent <code>cwd</code>. SessionViewer uses the <code>Unknown workspace</code> label when none of those sources supplies a usable path.</p>
<p>Because the main transcript outranks subagent evidence, a subagent that changes directory cannot move its parent session to another workspace.</p>
<p>SessionViewer merges a subagent transcript into its parent session by using the transcript&rsquo;s <code>parentSessionId</code> or <code>sessionId</code>, with the containing session directory as a fallback. In one Claude Code 2.1.330 session, two background agents also preserved exact parent-turn and parent-tool evidence:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">parent turn promptId=P
</span></span><span class="line"><span class="cl">├── Agent tool_use id=t1
</span></span><span class="line"><span class="cl">│   └── child agent A: promptId=P, meta toolUseId=t1
</span></span><span class="line"><span class="cl">└── Agent tool_use id=t2
</span></span><span class="line"><span class="cl">    └── child agent B: promptId=P, meta toolUseId=t2
</span></span></code></pre></td></tr></table>
</div>
</div><p>The shared native <code>promptId</code> lets SessionViewer place both child transcripts in the parent turn without comparing timestamps. The child filenames and rows supply their <code>agentId</code>, while each <code>.meta.json</code> file supplies the exact parent <code>toolUseId</code>. SessionViewer currently keeps that tool ID as provenance rather than nesting the child transcript below the parent tool node.</p>
<p>This exact turn binding depends on the child records carrying the parent <code>promptId</code>. Records without a prompt ID inherit only within the same subagent file or remain in an <code>agent:&lt;agent-id&gt;:unscoped</code> turn. SessionViewer does not use timestamps as a fallback for parentage: timestamps only order reconstructed events and turns.</p>
<h2 id="turns-are-built-around-promptid">Turns are built around <code>promptId</code></h2>
<p>Claude Code&rsquo;s strongest native key for a conversation turn is <code>promptId</code>. For example, the following observed human prompt is also the root of its transcript chain, so its <code>parentUuid</code> is null:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span><span class="nt">&#34;parentUuid&#34;</span><span class="p">:</span><span class="kc">null</span><span class="p">,</span><span class="nt">&#34;promptId&#34;</span><span class="p">:</span><span class="s2">&#34;6cb3a98c-b077-4caa-b2b3-be8546d76ada&#34;</span><span class="p">,</span><span class="nt">&#34;type&#34;</span><span class="p">:</span><span class="s2">&#34;user&#34;</span><span class="p">,</span><span class="nt">&#34;message&#34;</span><span class="p">:{</span><span class="nt">&#34;role&#34;</span><span class="p">:</span><span class="s2">&#34;user&#34;</span><span class="p">,</span><span class="nt">&#34;content&#34;</span><span class="p">:</span><span class="s2">&#34;Do this and do that&#34;</span><span class="p">},</span> <span class="nt">&#34;origin&#34;</span><span class="p">:{</span><span class="nt">&#34;kind&#34;</span><span class="p">:</span><span class="s2">&#34;human&#34;</span><span class="p">},</span><span class="nt">&#34;cwd&#34;</span><span class="p">:</span><span class="s2">&#34;C:\\MyRepo&#34;</span><span class="p">,</span><span class="nt">&#34;sessionId&#34;</span><span class="p">:</span><span class="s2">&#34;12345678-1234-beef-beef-1234abcd5678&#34;</span><span class="p">}</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>The row repeats <code>sessionId</code> even though the same value usually appears in the <code>.jsonl</code> filename. SessionViewer checks both sources instead of assuming that they agree.</p>
<p>All actions (including tool calls) until the next prompt usually share the same <code>promptId</code>. A row with <code>user</code> as <code>type</code> can contain human text, a tool result, harness-generated text or a mixture of those forms. Only a row that SessionViewer identifies as a human prompt starts a turn.</p>
<p><code>assistant</code>, <code>system</code> and <code>attachment</code> rows without a <code>promptId</code> inherit the last unambiguous prompt in the same file. Any row that still has no turn goes into a SessionViewer bucket such as <code>agent:&lt;agent-id&gt;:unscoped</code> or <code>session:&lt;session-id&gt;:unscoped</code>. SessionViewer does not silently attach that row to the nearest turn.</p>
<p>Claude&rsquo;s <code>uuid</code> and <code>parentUuid</code> fields are kept by SessionViewer: they describe the provider record chain, but SessionViewer does not treat that chain as the semantic parent/child tree shown in the UI. A null <code>parentUuid</code> identifies a chain root, not necessarily the first human prompt. Local commands typed by the user or other provider records can precede that prompt, and later prompts normally point to the preceding record.</p>
<h3 id="not-every-user-row-is-a-human-prompt">Not every <code>user</code> row is a human prompt</h3>
<p>Claude Code also stores harness activity with <code>type:&quot;user&quot;</code> and <code>message.role:&quot;user&quot;</code>. For example, running the local <code>/model</code> command in Claude Code 2.1.317 produced three JSONL records with one <code>promptId</code>:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span><span class="nt">&#34;type&#34;</span><span class="p">:</span><span class="s2">&#34;user&#34;</span><span class="p">,</span><span class="nt">&#34;isMeta&#34;</span><span class="p">:</span><span class="kc">true</span><span class="p">,</span><span class="nt">&#34;message&#34;</span><span class="p">:{</span><span class="nt">&#34;role&#34;</span><span class="p">:</span><span class="s2">&#34;user&#34;</span><span class="p">,</span><span class="nt">&#34;content&#34;</span><span class="p">:</span><span class="s2">&#34;&lt;local-command-caveat&gt;...&lt;/local-command-caveat&gt;&#34;</span><span class="p">}}</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span><span class="nt">&#34;type&#34;</span><span class="p">:</span><span class="s2">&#34;user&#34;</span><span class="p">,</span><span class="nt">&#34;message&#34;</span><span class="p">:{</span><span class="nt">&#34;role&#34;</span><span class="p">:</span><span class="s2">&#34;user&#34;</span><span class="p">,</span><span class="nt">&#34;content&#34;</span><span class="p">:</span><span class="s2">&#34;&lt;command-name&gt;/model&lt;/command-name&gt;\n&lt;command-message&gt;model&lt;/command-message&gt;\n&lt;command-args&gt;&lt;/command-args&gt;&#34;</span><span class="p">}}</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span><span class="nt">&#34;type&#34;</span><span class="p">:</span><span class="s2">&#34;user&#34;</span><span class="p">,</span><span class="nt">&#34;message&#34;</span><span class="p">:{</span><span class="nt">&#34;role&#34;</span><span class="p">:</span><span class="s2">&#34;user&#34;</span><span class="p">,</span><span class="nt">&#34;content&#34;</span><span class="p">:</span><span class="s2">&#34;&lt;local-command-stdout&gt;Set model to Opus...&lt;/local-command-stdout&gt;&#34;</span><span class="p">}}</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>The <code>local-command-caveat</code> record says that the command ran directly in Claude Code rather than being sent as a model request. The <code>command-name</code>, <code>command-message</code> and <code>command-args</code> elements describe the slash command. The <code>local-command-stdout</code> element contains the output displayed to the user, sometimes including terminal-formatting escape sequences.</p>
<p>These angle-bracket elements are Claude Code&rsquo;s internal wrappers, not a documented XML contract. A typed or pasted prompt can also contain a wrapper such as <code>&lt;pasted_content&gt;</code>. In the transcript versions inspected for this post, <code>origin.kind:&quot;human&quot;</code> is the strongest provider marker for a human-originated turn. <code>promptSource</code>, <code>turnOrigin</code> and <code>turnPosition</code> can provide supporting evidence, but these internal fields vary between Claude Code versions. Neither <code>type:&quot;user&quot;</code>, <code>message.role:&quot;user&quot;</code> nor <code>userType:&quot;external&quot;</code> proves that the text was typed as a prompt.</p>
<p>SessionViewer currently excludes <code>isMeta:true</code> rows and separates <code>tool_result</code> blocks, but it does not yet filter every wrapper-only local-command record. A <code>command-name</code> or <code>local-command-stdout</code> row can therefore appear as a prompt. This is a known reconstruction limitation, not evidence that the user sent that text to the model.</p>
<p>Claude&rsquo;s tool IDs provide an exact join:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">assistant message
</span></span><span class="line"><span class="cl">├── tool_use id=t1
</span></span><span class="line"><span class="cl">└── tool_use id=t2
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">later user row
</span></span><span class="line"><span class="cl">└── tool_result tool_use_id=t1
</span></span></code></pre></td></tr></table>
</div>
</div><p>In these Claude-native blocks, <code>tool_use.id</code> identifies the tool and <code>tool_result.tool_use_id</code> points back to that request. SessionViewer uses the exact match to place the result under the same tool node.</p>
<p>Claude&rsquo;s assistant <code>message.id</code>, when present, becomes SessionViewer&rsquo;s assistant-step ID. If one assistant row contains several <code>tool_use</code> blocks, SessionViewer also creates one parallel-group ID for those tool calls. The UI then displays a group such as <strong>Parallel · 2 calls</strong>. The assistant-step and parallel-group IDs are SessionViewer concepts; Claude provides the message and tool-call IDs from which SessionViewer builds them.</p>
<h2 id="one-set-of-transcript-rules-two-pipelines">One set of transcript rules, two pipelines</h2>
<p>Post 5 described the Claude transcript rows that enrich a live hook tree. SessionViewer reads many of the same row shapes. Duplicating every field rule would eventually make the live and passive applications interpret the same value differently.</p>
<p>HarnessSpy therefore has a shared interpreter named <code>ClaudeTranscriptSemantics</code>. The class translates provider-written fields into common HarnessSpy meanings without discovering files or building sessions. It handles:</p>
<ul>
<li>Model Context Protocol (MCP) tool names such as <code>mcp__github__search</code>, plus Claude&rsquo;s explicit MCP attribution fields;</li>
<li>tool success, failure, denial and interruption;</li>
<li>assistant usage fields and <code>cost-state</code> records;</li>
<li>skill listings, activations and <code>Skill</code> tool calls;</li>
<li>system-prompt snapshots;</li>
<li>readable and opaque thinking.</li>
</ul>
<p>Only field interpretation is shared. Discovery and correlation remain separate. <code>ClaudeSpy.App</code> starts from paths supplied by hook payloads and reconciles transcript evidence with a live hook tree. SessionViewer recursively scans Claude Code storage and adds the surviving records to its historical catalog tree.</p>
<p>The separation matters because the same JSON row can produce different behavior in the two applications.</p>
<h2 id="system-prompts-belong-to-the-session">System prompts belong to the session</h2>
<p>One useful Claude Code attachment type is <code>prompt_snapshot</code>, which provides evidence about the system prompt prepared for the model:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="nt">&#34;type&#34;</span><span class="p">:</span> <span class="s2">&#34;attachment&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="nt">&#34;attachment&#34;</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;type&#34;</span><span class="p">:</span> <span class="s2">&#34;prompt_snapshot&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;systemPrompt&#34;</span><span class="p">:</span> <span class="s2">&#34;\nYou are an agent working with the user toward their goals, ...&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>SessionViewer accepts a <code>systemPrompt</code> value that is either one string or an array of strings. It converts line endings to <code>\n</code>, removes blank lines only from the outer edges and joins non-empty array entries with one blank line. SessionViewer then computes a SHA-256 content hash and stores the snapshot as a session-level event outside ordinary turns.</p>
<p>The tree displays those events in a <strong>System prompts</strong> group before the conversation. Snapshots with the same content hash and the same agent become one displayed revision with an occurrence count.</p>
<p>Storing snapshots at session level avoids two misleading views:</p>
<ul>
<li>repeating the same large prompt under every turn;</li>
<li>counting prompt text as a response, thought or tool event.</li>
</ul>
<p>When the content hash changes, the tree keeps a new <strong>System prompt changed</strong> node.</p>
<p>The snapshots show the prompt text that Claude Code exposed locally, but they do not prove the exact request that reached Anthropic&rsquo;s server after every possible transformation.</p>
<h2 id="thinking-tools-and-lifecycle-rows">Thinking, tools and lifecycle rows</h2>
<p>The <code>content</code> array in a Claude assistant message can contain:</p>
<ul>
<li>readable <code>thinking</code> text;</li>
<li>normal text responses;</li>
<li>one or several <code>tool_use</code> blocks.</li>
</ul>
<p>In one Claude Code 2.1.317 transcript, Claude wrote each streamed content block as a separate JSONL row. The rows shared the same assistant <code>message.id</code>. The following abridged records preserve that observed structure:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span><span class="nt">&#34;message&#34;</span><span class="p">:{</span><span class="nt">&#34;id&#34;</span><span class="p">:</span><span class="s2">&#34;msg_011C...&#34;</span><span class="p">,</span><span class="nt">&#34;type&#34;</span><span class="p">:</span><span class="s2">&#34;message&#34;</span><span class="p">,</span><span class="nt">&#34;role&#34;</span><span class="p">:</span><span class="s2">&#34;assistant&#34;</span><span class="p">,</span><span class="nt">&#34;content&#34;</span><span class="p">:[{</span><span class="nt">&#34;type&#34;</span><span class="p">:</span><span class="s2">&#34;thinking&#34;</span><span class="p">,</span><span class="nt">&#34;thinking&#34;</span><span class="p">:</span><span class="s2">&#34;I need to read the analysis file first...&#34;</span><span class="p">}]},</span><span class="nt">&#34;apiBlockIndex&#34;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span><span class="nt">&#34;type&#34;</span><span class="p">:</span><span class="s2">&#34;assistant&#34;</span><span class="p">,</span><span class="nt">&#34;uuid&#34;</span><span class="p">:</span><span class="s2">&#34;b09c...&#34;</span><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="p">{</span><span class="nt">&#34;message&#34;</span><span class="p">:{</span><span class="nt">&#34;id&#34;</span><span class="p">:</span><span class="s2">&#34;msg_011C...&#34;</span><span class="p">,</span><span class="nt">&#34;type&#34;</span><span class="p">:</span><span class="s2">&#34;message&#34;</span><span class="p">,</span><span class="nt">&#34;role&#34;</span><span class="p">:</span><span class="s2">&#34;assistant&#34;</span><span class="p">,</span><span class="nt">&#34;content&#34;</span><span class="p">:[{</span><span class="nt">&#34;type&#34;</span><span class="p">:</span><span class="s2">&#34;text&#34;</span><span class="p">,</span><span class="nt">&#34;text&#34;</span><span class="p">:</span><span class="s2">&#34;I&#39;ll start by reading the analysis document...&#34;</span><span class="p">}]},</span><span class="nt">&#34;apiBlockIndex&#34;</span><span class="p">:</span><span class="mi">1</span><span class="p">,</span><span class="nt">&#34;type&#34;</span><span class="p">:</span><span class="s2">&#34;assistant&#34;</span><span class="p">,</span><span class="nt">&#34;uuid&#34;</span><span class="p">:</span><span class="s2">&#34;d40e...&#34;</span><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="p">{</span><span class="nt">&#34;message&#34;</span><span class="p">:{</span><span class="nt">&#34;id&#34;</span><span class="p">:</span><span class="s2">&#34;msg_011C...&#34;</span><span class="p">,</span><span class="nt">&#34;type&#34;</span><span class="p">:</span><span class="s2">&#34;message&#34;</span><span class="p">,</span><span class="nt">&#34;role&#34;</span><span class="p">:</span><span class="s2">&#34;assistant&#34;</span><span class="p">,</span><span class="nt">&#34;content&#34;</span><span class="p">:[{</span><span class="nt">&#34;type&#34;</span><span class="p">:</span><span class="s2">&#34;tool_use&#34;</span><span class="p">,</span><span class="nt">&#34;id&#34;</span><span class="p">:</span><span class="s2">&#34;toolu_01UC...&#34;</span><span class="p">,</span><span class="nt">&#34;name&#34;</span><span class="p">:</span><span class="s2">&#34;Bash&#34;</span><span class="p">,</span><span class="nt">&#34;input&#34;</span><span class="p">:{</span><span class="nt">&#34;command&#34;</span><span class="p">:</span><span class="s2">&#34;...&#34;</span><span class="p">}}]},</span><span class="nt">&#34;apiBlockIndex&#34;</span><span class="p">:</span><span class="mi">2</span><span class="p">,</span><span class="nt">&#34;type&#34;</span><span class="p">:</span><span class="s2">&#34;assistant&#34;</span><span class="p">,</span><span class="nt">&#34;uuid&#34;</span><span class="p">:</span><span class="s2">&#34;61e2...&#34;</span><span class="p">}</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>The outer <code>type:&quot;assistant&quot;</code> identifies the transcript row. The nested <code>message.type:&quot;message&quot;</code> belongs to Claude&rsquo;s message object. The shared <code>message.id</code> and increasing <code>apiBlockIndex</code> show that these rows are blocks from one assistant step rather than three independent responses. Other Claude Code versions or message shapes can place several blocks in one <code>content</code> array, so SessionViewer supports both layouts.</p>
<p>Claude Code also writes useful rows that are not messages. A <code>system</code> row with subtype <code>turn_duration</code> closes a turn and provides <code>durationMs</code>. Context compaction is Claude Code&rsquo;s process for reducing long conversation context before continuing. A <code>system</code> row with subtype <code>compact_boundary</code> reports that this process completed. For example, SessionViewer can show the compaction boundary even though the row contains no assistant response.</p>
<p>MCP identity normally comes from a native name such as <code>mcp__github__search</code>, which maps to server <code>github</code> and tool <code>search</code>. Claude&rsquo;s explicit <code>attributionMcpServer</code> and <code>attributionMcpTool</code> fields take precedence when present.</p>
<h2 id="usage-is-a-mixture-of-snapshots-and-deltas">Usage is a mixture of snapshots and deltas</h2>
<p>Claude Code writes a <code>message.usage</code> object on assistant messages. SessionViewer interprets each measurement as either a cumulative snapshot or a delta. If two rows report 100 and then 120 input tokens, the result is 120, not 220. A delta is an increment: if two rows report 20 and then 5 output tokens, the result is 25.</p>
<table>
  <thead>
      <tr>
          <th>Measurement</th>
          <th>Interpretation</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>input_tokens</code></td>
          <td>cumulative turn snapshot</td>
      </tr>
      <tr>
          <td><code>cache_read_input_tokens</code></td>
          <td>cumulative turn snapshot</td>
      </tr>
      <tr>
          <td><code>cache_creation_input_tokens</code></td>
          <td>cumulative turn snapshot</td>
      </tr>
      <tr>
          <td><code>output_tokens</code></td>
          <td>delta</td>
      </tr>
      <tr>
          <td><code>output_tokens_details.thinking_tokens</code> (stored by HarnessSpy as <code>thinking_tokens</code>)</td>
          <td>delta</td>
      </tr>
      <tr>
          <td><code>server_tool_use.*</code></td>
          <td>delta</td>
      </tr>
  </tbody>
</table>
<p>For <code>server_tool_use.*</code>, the asterisk means each counter inside the <code>server_tool_use</code> object. For example, a <code>web_search_requests</code> child value is treated as a delta.</p>
<p>Claude&rsquo;s <code>cost-state</code> row describes session-wide totals:</p>
<ul>
<li>per-model token, cache and <code>webSearchRequests</code> values from <code>modelUsage</code>;</li>
<li><code>totalAPIDuration</code>, <code>totalToolDuration</code> and <code>totalDuration</code>;</li>
<li><code>totalLinesAdded</code> and <code>totalLinesRemoved</code>;</li>
<li><code>totalCostUSD</code>, converted to integer micro-USD.</li>
</ul>
<p>For example, <code>totalCostUSD: 0.012345</code> becomes <code>12345</code> micro-USD. The converted amount is provider-reported transcript evidence, not an independently verified bill.</p>
<h2 id="available-skill-does-not-mean-invoked-skill">Available skill does not mean invoked skill</h2>
<p>A skill is a reusable instruction bundle that Claude Code can offer to an agent. They are exposed through several signals, and SessionViewer maps those signals to its own stages:</p>
<ul>
<li>a <code>skill_listing</code> attachment becomes <strong>Available</strong>;</li>
<li>a <code>skill_activated</code> attachment becomes <strong>Invoked</strong>;</li>
<li>a <code>tool_use</code> block named <code>Skill</code> with <code>input.skill</code> becomes <strong>Invoked</strong> directly;</li>
<li><code>attributionSkill</code> or <code>skill</code> on another tool can also identify an <strong>Invoked</strong> skill.</li>
</ul>
<p><strong>Available</strong> and <strong>Invoked</strong> are HarnessSpy labels, not values stored by Claude Code. For example, if <code>skill_listing</code> offers <code>pdf</code> and <code>review</code> but the <code>Skill</code> tool invokes only <code>review</code>, SessionViewer reports both skills as available and only <code>review</code> as invoked.</p>
<h2 id="one-unique-plan-to-rule-them-all">One (unique) plan to rule them all</h2>
<p>By default in plan mode, Claude Code creates one Markdown file under the configuration root: <code>%USERPROFILE%\.claude\plans\</code> by default, or <code>CLAUDE_CONFIG_DIR\plans\</code> when the environment variable is set. Even if you explicitly ask Claude to create unrelated plans in one session, Claude can add them as sections in that same Markdown file. The filename (called a <em>slug</em>) is not derived from the workspace or session. For example, here is the name I got for a session where I asked to &ldquo;build a detailed plan to do this and do that&rdquo;:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">build-a-detailed-plan-smooth-thunder.md
</span></span></code></pre></td></tr></table>
</div>
</div><p>SessionViewer extracts plan activity from Claude transcript rows:</p>
<ul>
<li>a <code>plan_mode</code> or <code>plan_mode_exit</code> attachment with <code>planFilePath</code> supplies an explicit plan path for that session; <code>planExists:true</code> also confirms that the artifact existed;</li>
<li>a Claude <code>Write</code> tool request targeting a file inside a <code>plans</code> directory can supply a complete revision body;</li>
<li>an <code>ExitPlanMode</code> tool request can carry the complete plan body in its <code>plan</code> input;</li>
<li><code>Edit</code>, <code>MultiEdit</code> and <code>NotebookEdit</code> prove that an update was requested but do not expose the resulting document.</li>
</ul>
<p>Plan ownership is a SessionViewer binding decision built from those provider records. The explicit <code>planFilePath</code> can bind an existing plan file even though the attachment is a reference rather than a write. For tool requests, SessionViewer resolves the matching <code>tool_result</code> by <code>tool_use_id</code>: a rejected, failed or aborted <code>Write</code> or <code>ExitPlanMode</code> remains inspectable but cannot establish ownership or materialize a revision.</p>
<p>A pathless <code>ExitPlanMode</code> body is attached only when that session already owns exactly one plan. Otherwise the body remains unbound. If provider evidence points the same plan to more than one session, SessionViewer marks the binding as ambiguous and leaves the file under <strong>Orphan Plans</strong>.</p>
<p>As with Cursor, SessionViewer rebuilds revisions only from complete bodies that it observed, including the current Markdown file. Before hashing a body, it removes an optional byte-order mark (a hidden marker at the start of some text files), standardizes line endings, and converts canonically equivalent Unicode spellings to the same form. For example, one file can store <code>é</code> as one character while another stores <code>e</code> followed by a combining accent; SessionViewer treats both spellings as equal. It removes only leading and trailing newline runs, while preserving indentation, trailing spaces and internal blank lines. SessionViewer then collapses adjacent bodies with the same hash and counts the remaining content transitions. For example, observations <code>A</code>, <code>A</code>, <code>B</code> produce two revisions and one update. An edit that exposes no resulting body sets the plan&rsquo;s <code>partial</code> marker instead of creating a fictional revision.</p>
<h2 id="closed-state-is-deliberately-conservative">Closed state is deliberately conservative</h2>
<p>The Claude catalog source emits every reconstructed session as <strong>Closed</strong> with unavailable lifecycle evidence. SessionViewer does not enumerate <code>claude</code> processes, inspect their command lines or invoke <code>claude agents --json</code> to get the list of running agents. A recent transcript does not prove that a Claude process is still attached to the session.</p>
<p>The <strong>Open Session</strong> action uses the Claude Code VS Code URI when transcript metadata contains an <code>entrypoint</code> value with <code>vscode</code>. Otherwise SessionViewer opens a terminal and launches:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-powershell" data-lang="powershell"><span class="line"><span class="cl"><span class="n">claude</span> <span class="p">-</span><span class="n">-resume</span> <span class="s2">&#34;&lt;session-id&gt;&#34;</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>Refreshing the catalog only reads provider files. Choosing <strong>Open Session</strong> is an explicit activation.</p>
<h2 id="conclusion">Conclusion</h2>
<p>Claude&rsquo;s local history is best understood as a set of cooperating files:</p>
<ol>
<li><strong>Prompt history can preserve metadata; transcript JSONL carries the conversation.</strong></li>
<li><strong>When present, <code>promptId</code> and <code>tool_use.id</code> provide strong turn and tool identity.</strong></li>
<li><strong>Cumulative snapshots and incremental deltas require different usage math.</strong></li>
<li><strong>Subagent files improve coverage without guaranteeing completeness.</strong></li>
<li><strong>Plan <em>slug</em> filenames are not tied to a workspace, but transcript evidence can bind them to sessions.</strong></li>
</ol>
<p>The final post will turn to Copilot CLI. Its <code>events.jsonl</code> is not primarily a chat transcript: it is a broad event stream where one user interaction can contain several model cycles that reuse <code>turnId</code>.</p>
<h2 id="references">References</h2>
<ul>
<li><a href="https://github.com/chrisnas/HarnessSpy">HarnessSpy source code</a></li>
<li><a href="https://github.com/chrisnas/HarnessSpy/blob/main/docs/session_claude.md">Claude passive-session format</a></li>
<li><a href="https://github.com/chrisnas/HarnessSpy/blob/main/docs/Transcripts_Claude.md">Claude transcript extraction contract</a></li>
<li><a href="/posts/2026-08-23_spying-on-cursor-hooks/">Part 1: Spying on Cursor</a></li>
<li><a href="/posts/2026-09-14_rebuilding-cursor-conversation/">Part 2: Rebuilding the Agent conversation</a></li>
<li><a href="/posts/2026-09-20_spying-on-claude-code-hooks/">Part 3: Spying on Claude Code</a></li>
<li><a href="/posts/2026-09-27_spying-on-github-copilot-twice/">Part 4: Spying on GitHub Copilot twice</a></li>
<li><a href="/posts/2026-10-09_beyond-hooks-transcript-logs/">Part 5: Beyond hooks</a></li>
<li><a href="/posts/2026-11-15_sessionviewer-and-cursor/">Part 6: SessionViewer and Cursor</a></li>
</ul>
]]></content:encoded></item></channel></rss>