<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nova Studio</title>
    <description>The latest articles on DEV Community by Nova Studio (@nova_studio_127963f255de4).</description>
    <link>https://dev.to/nova_studio_127963f255de4</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4271806%2Fcdd7275a-381d-40c4-ae41-f556cf632168.png</url>
      <title>DEV Community: Nova Studio</title>
      <link>https://dev.to/nova_studio_127963f255de4</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nova_studio_127963f255de4"/>
    <language>en</language>
    <item>
      <title>Run Claude Code subagents on cheaper models: 3 agent files that cut usage</title>
      <dc:creator>Nova Studio</dc:creator>
      <pubDate>Sun, 29 Nov 2026 17:23:12 +0000</pubDate>
      <link>https://dev.to/nova_studio_127963f255de4/run-claude-code-subagents-on-cheaper-models-3-agent-files-that-cut-usage-136o</link>
      <guid>https://dev.to/nova_studio_127963f255de4/run-claude-code-subagents-on-cheaper-models-3-agent-files-that-cut-usage-136o</guid>
      <description>&lt;p&gt;Most of what Claude Code does in a session isn't hard thinking. It's searching for where something lives, reading a long file to find two facts, and running tests to see what failed. If all of that happens in your main conversation, on your top model, two things go wrong: you pay top-model prices for grunt work, and every file dump and test log stays in the context and gets paid for again on every later turn.&lt;/p&gt;

&lt;p&gt;Subagents fix both, if you set them up for it. Here's how, with three agent files you can copy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this matters more than it looks
&lt;/h2&gt;

&lt;p&gt;In three months of my own logs (measured with &lt;a href="https://novastudio1shop-source.github.io/agent-wrapped/" rel="noopener noreferrer"&gt;Agent Wrapped&lt;/a&gt;), subagents were 60% of all usage, and almost all of them ran on the same top model as the main thread. Re-pricing that subagent work at a mid-tier model's rates would have cut it by about half. On top of that, 5,858 tool results over 4,000 tokens rode along in the main context after they arrived.&lt;/p&gt;

&lt;p&gt;A subagent has its own context. Whatever it reads stays there. Only its answer comes back to your conversation. So a subagent on a smaller model that returns a short answer saves twice: cheaper tokens for the reading, and nothing bulky added to the main thread.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where agent files go
&lt;/h2&gt;

&lt;p&gt;Put Markdown files in &lt;code&gt;.claude/agents/&lt;/code&gt; in your project (or &lt;code&gt;~/.claude/agents/&lt;/code&gt; for every project). The frontmatter sets the name, when to use it, which tools it may use and which model it runs on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;---
name: scout
description: "Fast, cheap code search. Use for finding where something is defined, handled, configured or called."
tools: Read, Grep, Glob
model: haiku
---
Instructions for the agent go here.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;model&lt;/code&gt; takes &lt;code&gt;haiku&lt;/code&gt;, &lt;code&gt;sonnet&lt;/code&gt; or &lt;code&gt;opus&lt;/code&gt; (or &lt;code&gt;inherit&lt;/code&gt;). Leave it out and the agent runs on the same model as your main conversation, which is the expensive default most setups never change.&lt;/p&gt;

&lt;h2&gt;
  
  
  Agent 1: scout (search on Haiku)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;---
name: scout
description: Fast, cheap code search. Use for finding where something is defined, handled, configured or called, and for "which files touch X" questions. Returns paths, line numbers and a one-line finding each, never whole files.
tools: Read, Grep, Glob
model: haiku
---

You find things in the codebase for the main agent, cheaply.

&lt;span class="k"&gt;- &lt;/span&gt;Search with Grep and Glob first. Read only the lines around a match, never whole large files.
&lt;span class="k"&gt;- &lt;/span&gt;Answer with a short list: &lt;span class="sb"&gt;`path:line`&lt;/span&gt;: one-line finding. At most 15 items, most relevant first.
&lt;span class="k"&gt;- &lt;/span&gt;Do not paste code blocks longer than 10 lines. Do not edit anything.
&lt;span class="k"&gt;- &lt;/span&gt;If you can't find it, say what you searched for, so the main agent doesn't repeat it.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;description&lt;/code&gt; matters: Claude picks a subagent by matching your request against it. "Use the scout agent to find where auth tokens are refreshed" works, and so will plain "find where auth tokens are refreshed" once the description clearly covers it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Agent 2: summarizer (long documents on Haiku)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;---
name: summarizer
description: Reads long documents, PDFs, logs, specs or large files and returns only the parts the main agent asked about. Use instead of reading a big file into the main conversation.
tools: Read, Grep, Glob
model: haiku
---

You read long material so the main conversation doesn't have to carry it.

&lt;span class="k"&gt;- &lt;/span&gt;Read in parts. Return only what the request asks for: facts, numbers, names, steps.
&lt;span class="k"&gt;- &lt;/span&gt;Keep your answer under 300 words unless asked for more, with &lt;span class="sb"&gt;`path`&lt;/span&gt; or page numbers next to each point.
&lt;span class="k"&gt;- &lt;/span&gt;If the material doesn't contain the answer, say so plainly.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the one that saves most for me. A 50,000-token PDF read in the main thread is paid once on arrival and again on every turn after it. Read by the summarizer, it's paid once at Haiku prices, and 300 words come back.&lt;/p&gt;

&lt;h2&gt;
  
  
  Agent 3: test-runner (noisy commands on Sonnet)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;---
name: test-runner
description: Runs the test suite, a single test, a linter or a build and reports only what failed. Use instead of running noisy commands in the main conversation.
tools: Bash, Read, Grep
model: sonnet
---

You run checks and report results compactly.

&lt;span class="k"&gt;- &lt;/span&gt;Keep output short: pipe through &lt;span class="sb"&gt;`tail -60`&lt;/span&gt;, or use the tool's quiet or summary flags.
&lt;span class="k"&gt;- &lt;/span&gt;Report pass or fail, counts, then for each failure: test name, &lt;span class="sb"&gt;`path:line`&lt;/span&gt;, the error (at most 8 lines).
&lt;span class="k"&gt;- &lt;/span&gt;Never paste full logs. Never change code; the main agent decides fixes.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sonnet rather than Haiku here, because reading a stack trace well is worth the step up.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep the main thread for decisions
&lt;/h2&gt;

&lt;p&gt;With these three in place, the pattern becomes: the main conversation, on your best model, plans and decides; the agents go and look. A few prompts that route work well:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Use the scout agent to list every place &lt;code&gt;createOrder&lt;/code&gt; is called."&lt;/li&gt;
&lt;li&gt;"Have the summarizer pull the rate limits and error codes out of &lt;code&gt;docs/api-spec.pdf&lt;/code&gt;."&lt;/li&gt;
&lt;li&gt;"Run the tests with the test-runner and tell me what failed."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two more habits make the effect stick: &lt;code&gt;/clear&lt;/code&gt; when you switch tasks, and &lt;code&gt;/compact&lt;/code&gt; before you step away, so the cache doesn't have to rebuild a huge context when you come back.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measure before and after
&lt;/h2&gt;

&lt;p&gt;Run &lt;a href="https://novastudio1shop-source.github.io/agent-wrapped/" rel="noopener noreferrer"&gt;Agent Wrapped&lt;/a&gt; on your logs now (free, in the browser, nothing uploaded), then again after a week or two with the agents in place. Look at the model split and the oversized-context figure.&lt;/p&gt;

&lt;p&gt;If you'd rather not assemble this yourself, the &lt;a href="https://buy.stripe.com/cNicN7bc47kBel4gKDbsc0c" rel="noopener noreferrer"&gt;Limit Saver Kit ($9)&lt;/a&gt; has these three agents ready to drop in, plus &lt;code&gt;/handoff&lt;/code&gt; and &lt;code&gt;/slim&lt;/code&gt; commands, a lean CLAUDE.md template and the playbook. The agent files above are free to copy either way.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Independent tool, not made or endorsed by Anthropic.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>claude</category>
      <category>ai</category>
      <category>productivity</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to read Claude Code's session logs (and the 4 traps that inflate your token count)</title>
      <dc:creator>Nova Studio</dc:creator>
      <pubDate>Sun, 29 Nov 2026 07:20:01 +0000</pubDate>
      <link>https://dev.to/nova_studio_127963f255de4/how-to-read-claude-codes-session-logs-and-the-4-traps-that-inflate-your-token-count-33ei</link>
      <guid>https://dev.to/nova_studio_127963f255de4/how-to-read-claude-codes-session-logs-and-the-4-traps-that-inflate-your-token-count-33ei</guid>
      <description>&lt;p&gt;Claude Code keeps a full log of every session on your disk. If you want to know how many tokens you've used, which model they went to, or what a session cost at API prices, everything you need is in there. The format has a few traps that make naive totals wrong, sometimes several times too high.&lt;/p&gt;

&lt;p&gt;This is what I learned writing &lt;a href="https://novastudio1shop-source.github.io/agent-wrapped/" rel="noopener noreferrer"&gt;Agent Wrapped&lt;/a&gt;, a browser tool that reads these logs. It checked out against 2,845 files and 3.4 GB of my own history.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the logs are
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/.claude/projects/&amp;lt;encoded-project-path&amp;gt;/&amp;lt;session-id&amp;gt;.jsonl
~/.claude/projects/&amp;lt;encoded-project-path&amp;gt;/&amp;lt;session-id&amp;gt;/subagents/agent-&amp;lt;id&amp;gt;.jsonl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One JSONL file per session, one JSON object per line. Subagents get their own files in a &lt;code&gt;subagents&lt;/code&gt; folder next to the session that launched them. On Windows the root is &lt;code&gt;%USERPROFILE%\.claude&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;By default Claude Code deletes logs older than about 30 days. Raise &lt;code&gt;cleanupPeriodDays&lt;/code&gt; in &lt;code&gt;~/.claude/settings.json&lt;/code&gt; if you want a longer history.&lt;/p&gt;

&lt;h2&gt;
  
  
  The lines that matter
&lt;/h2&gt;

&lt;p&gt;Most lines have a &lt;code&gt;type&lt;/code&gt;. The two you need are &lt;code&gt;assistant&lt;/code&gt; (a model response) and &lt;code&gt;user&lt;/code&gt; (your prompts and tool results). There are many bookkeeping types too (&lt;code&gt;custom-title&lt;/code&gt;, &lt;code&gt;file-history-snapshot&lt;/code&gt;, &lt;code&gt;queue-operation&lt;/code&gt;, &lt;code&gt;attachment&lt;/code&gt; and others); skip them.&lt;/p&gt;

&lt;p&gt;An &lt;code&gt;assistant&lt;/code&gt; line looks roughly like this (trimmed):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"assistant"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"timestamp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-11-24T14:02:11.512Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"cwd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/home/me/project"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"entrypoint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"cli"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"msg_01..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"model"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"claude-opus-5-5"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"tool_use"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"toolu_01..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Read"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"input"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"file_path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"..."&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"usage"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"input_tokens"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"output_tokens"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;412&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"cache_read_input_tokens"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;182340&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"cache_creation_input_tokens"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2210&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"cache_creation"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"ephemeral_5m_input_tokens"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2210&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"ephemeral_1h_input_tokens"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Trap 1: one response is several lines
&lt;/h2&gt;

&lt;p&gt;Claude Code writes each content block of a response (a thinking block, a text block, each tool call) as its own line, and &lt;strong&gt;every one of those lines carries the same &lt;code&gt;usage&lt;/code&gt; object&lt;/strong&gt;. A response that reads a file and runs a command appears three or four times.&lt;/p&gt;

&lt;p&gt;If you sum &lt;code&gt;usage&lt;/code&gt; over every line, you count that response three or four times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; count &lt;code&gt;usage&lt;/code&gt; once per &lt;code&gt;message.id&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trap 2: resumed sessions copy history
&lt;/h2&gt;

&lt;p&gt;Resume or continue a session and the earlier turns are copied into the new file. Sum per file and the same responses are counted again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; keep the set of &lt;code&gt;message.id&lt;/code&gt;s you've already counted across all files, not just per file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trap 3: there are four kinds of input token
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;usage&lt;/code&gt; splits input into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;input_tokens&lt;/code&gt;: uncached input (usually tiny)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cache_creation_input_tokens&lt;/code&gt;: written to the prompt cache&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cache_read_input_tokens&lt;/code&gt;: read back from the cache&lt;/li&gt;
&lt;li&gt;inside &lt;code&gt;cache_creation&lt;/code&gt;: how much of the write was the 5-minute or the 1-hour cache&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They are priced very differently. At list prices a cache read is a small fraction of the input price, a 5-minute write is 1.25× input and a 1-hour write is 2× input. In my logs, cache reads were 95% of all tokens but only about a quarter of the cost. Price them separately, per model, or the dollar figure is meaningless.&lt;/p&gt;

&lt;p&gt;Older lines have only &lt;code&gt;cache_creation_input_tokens&lt;/code&gt; with no breakdown; treat those as 5-minute writes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trap 4: synthetic and error lines
&lt;/h2&gt;

&lt;p&gt;Lines with &lt;code&gt;"model": "&amp;lt;synthetic&amp;gt;"&lt;/code&gt; aren't model calls. Usage-limit messages appear as assistant lines with &lt;code&gt;apiError: "usage_limit_reached"&lt;/code&gt; and zero usage. Skip both for totals. The limit lines are useful in their own right, though: they're the exact moments you hit the wall, with &lt;code&gt;rateLimitType&lt;/code&gt; (&lt;code&gt;five_hour&lt;/code&gt;, &lt;code&gt;seven_day&lt;/code&gt;) and &lt;code&gt;resetsAt&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things you can work out once the counting is right
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Context size per request&lt;/strong&gt; = &lt;code&gt;input_tokens + cache_read + cache_creation&lt;/code&gt;. Track it per session to see when a conversation got too big.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cache rebuilds:&lt;/strong&gt; a request whose cache read is far below the previous request's context, while the context hasn't shrunk, means the cache was lost (after an idle gap, a model switch, or a change to the tool list) and everything was written again.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tool-result weight:&lt;/strong&gt; the &lt;code&gt;tool_result&lt;/code&gt; blocks in &lt;code&gt;user&lt;/code&gt; lines show what each tool returned. A big result is paid once on arrival and again on every later turn.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Who used what:&lt;/strong&gt; &lt;code&gt;cwd&lt;/code&gt; gives the project and &lt;code&gt;entrypoint&lt;/code&gt; the surface (&lt;code&gt;cli&lt;/code&gt;, &lt;code&gt;sdk-cli&lt;/code&gt; for headless &lt;code&gt;claude -p&lt;/code&gt;, &lt;code&gt;claude-desktop&lt;/code&gt;, and so on). Subagent files map back to their parent session through the folder they're in.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A minimal correct total
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;allLinesFromAllFiles&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'assistant'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;usage&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;synthetic&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;usage&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;input_tokens&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;output_tokens&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
          &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cache_read_input_tokens&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cache_creation_input_tokens&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Stream the files rather than loading them whole: long sessions reach tens of megabytes, and a heavy user has gigabytes.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you'd rather not write it
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://novastudio1shop-source.github.io/agent-wrapped/" rel="noopener noreferrer"&gt;Agent Wrapped&lt;/a&gt; does all of the above in your browser: pick your &lt;code&gt;.claude&lt;/code&gt; folder and it shows tokens, models, tools, rhythm, a share card, and where usage went to cache rebuilds, oversized context and large tool results. It's one HTML file with a Content-Security-Policy that blocks all network requests, so nothing leaves your machine. The &lt;a href="https://github.com/novastudio1shop-source/agent-wrapped" rel="noopener noreferrer"&gt;source is on GitHub&lt;/a&gt; (MIT). There's also a &lt;a href="https://buy.stripe.com/9B67sN4NG6gx1yi1PJbsc0b" rel="noopener noreferrer"&gt;$9 Pro file&lt;/a&gt; with per-session detail and export.&lt;/p&gt;

&lt;p&gt;If you've found other quirks in the format, I'd like to hear about them in the comments.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Independent tool, not made or endorsed by Anthropic.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>claude</category>
      <category>ai</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Why you keep hitting Claude Code's usage limit: 8 fixes, measured on 6 billion tokens</title>
      <dc:creator>Nova Studio</dc:creator>
      <pubDate>Sun, 29 Nov 2026 07:00:00 +0000</pubDate>
      <link>https://dev.to/nova_studio_127963f255de4/why-you-keep-hitting-claude-codes-usage-limit-8-fixes-measured-on-6-billion-tokens-33ej</link>
      <guid>https://dev.to/nova_studio_127963f255de4/why-you-keep-hitting-claude-codes-usage-limit-8-fixes-measured-on-6-billion-tokens-33ej</guid>
      <description>&lt;p&gt;If Claude Code tells you "You've hit your session limit" more often than you expect, the cause is usually not the work you asked for. It's what rides along with every request.&lt;/p&gt;

&lt;p&gt;I measured three months of my own logs (6 billion tokens, 624 sessions, 2,193 subagents) with &lt;a href="https://novastudio1shop-source.github.io/agent-wrapped/" rel="noopener noreferrer"&gt;Agent Wrapped&lt;/a&gt;. 71% of the spend was context (the conversation written to the prompt cache and read back each turn), not the model's answers. Here are the fixes that matter, roughly in order of what they saved.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Find the loop you forgot about
&lt;/h2&gt;

&lt;p&gt;In 7 of my 9 limit walls, the biggest consumer was a scheduled agent: a &lt;code&gt;claude -p&lt;/code&gt; job running every 15 to 30 minutes. Each run starts a fresh session and pays the full startup cost (system prompt, tool definitions, memory files) before doing anything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; list what runs on a schedule (cron, Task Scheduler, launchd, &lt;code&gt;~/.claude/scheduled-tasks/&lt;/code&gt;). Run each job less often, or batch the work into fewer, larger runs.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. &lt;code&gt;/clear&lt;/code&gt; between tasks
&lt;/h2&gt;

&lt;p&gt;Every turn re-reads the entire conversation. Past about 150k tokens, each extra turn pays for all of it again. My most expensive sessions peaked above 500k tokens of context.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; when you switch to a new task, &lt;code&gt;/clear&lt;/code&gt;. The new task doesn't need the old task's 200k tokens riding along.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. &lt;code&gt;/compact&lt;/code&gt; before you walk away
&lt;/h2&gt;

&lt;p&gt;The prompt cache expires. Come back after a long pause and the whole conversation is written to the cache again at the full write price, which is much more than reading it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; at a natural stopping point, &lt;code&gt;/compact&lt;/code&gt; and say what to keep (&lt;code&gt;/compact keep the API design and the failing test&lt;/code&gt;). Coming back to a small context is cheap.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Don't switch models or MCP servers mid-session
&lt;/h2&gt;

&lt;p&gt;Caches are per model, and the tool list sits at the start of the prompt. Switching with &lt;code&gt;/model&lt;/code&gt;, or connecting and disconnecting MCP servers partway through, throws the cache away and rewrites everything after it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; pick the model and tools at the start of a session.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Disconnect MCP servers you don't use here
&lt;/h2&gt;

&lt;p&gt;Every connected server adds its tool descriptions to every request of every session and every subagent. My median subagent started at 28k tokens before doing any work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; &lt;code&gt;/mcp&lt;/code&gt; and turn off what this project doesn't need.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Keep CLAUDE.md lean
&lt;/h2&gt;

&lt;p&gt;CLAUDE.md and memory files load on every request. A 6,000-token CLAUDE.md costs 6,000 tokens on every turn.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; keep only what the agent needs every time. Move rarely needed detail into separate files it reads on demand.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Ask for the part, not the file
&lt;/h2&gt;

&lt;p&gt;One big tool result (a PDF, a lock file, a full test log) is paid for when it arrives and again on every later turn of the session. I had 5,858 results over 4,000 tokens.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; "read lines 100 to 180", &lt;code&gt;Grep&lt;/code&gt; first, add &lt;code&gt;| tail -50&lt;/code&gt; to noisy commands, and give page ranges for PDFs. Put "keep command output short" in CLAUDE.md so it's the default.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Give search-and-read subagents a cheaper model
&lt;/h2&gt;

&lt;p&gt;Subagents were 60% of my usage. Much of that work is searching and summarizing, which a smaller model handles well.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; in &lt;code&gt;.claude/agents/&amp;lt;name&amp;gt;.md&lt;/code&gt;, add &lt;code&gt;model: haiku&lt;/code&gt; or &lt;code&gt;model: sonnet&lt;/code&gt; to agents that only search, read or summarize. Keep the top model for the main thread.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check your own setup in one command
&lt;/h2&gt;

&lt;p&gt;I packaged these checks as a Claude Code plugin. Install it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/plugin install agent-wrapped --marketplace novastudio1shop-source/agent-wrapped
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run &lt;code&gt;/agent-wrapped:leak-check&lt;/code&gt;. Claude inspects your MCP servers, CLAUDE.md size, scheduled jobs, biggest sessions and subagent settings, and gives you a fix list. It's read-only.&lt;/p&gt;

&lt;p&gt;For the actual numbers (tokens and API-price value per session, every cache rebuild, oversized context, the biggest tool results, and what was running before each time you hit the limit), open the free &lt;a href="https://novastudio1shop-source.github.io/agent-wrapped/" rel="noopener noreferrer"&gt;Agent Wrapped page&lt;/a&gt;. It reads your &lt;code&gt;~/.claude&lt;/code&gt; logs in the browser and uploads nothing. There's also a &lt;a href="https://buy.stripe.com/9B67sN4NG6gx1yi1PJbsc0b" rel="noopener noreferrer"&gt;$9 version&lt;/a&gt; with the per-session detail and an export.&lt;/p&gt;

&lt;p&gt;What's the biggest leak you've found in your own setup? I'm collecting them for the next version.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Independent tool, not made or endorsed by Anthropic.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>claude</category>
      <category>ai</category>
      <category>productivity</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>I built a "Wrapped" for Claude Code. It found 6 billion tokens and why I kept hitting my limit</title>
      <dc:creator>Nova Studio</dc:creator>
      <pubDate>Sun, 29 Nov 2026 06:42:08 +0000</pubDate>
      <link>https://dev.to/nova_studio_127963f255de4/i-built-a-wrapped-for-claude-code-it-found-6-billion-tokens-and-why-i-kept-hitting-my-limit-kcf</link>
      <guid>https://dev.to/nova_studio_127963f255de4/i-built-a-wrapped-for-claude-code-it-found-6-billion-tokens-and-why-i-kept-hitting-my-limit-kcf</guid>
      <description>&lt;p&gt;Every December the apps I use tell me what my year looked like. My coding agent never did, so I built it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://novastudio1shop-source.github.io/agent-wrapped/" rel="noopener noreferrer"&gt;Agent Wrapped&lt;/a&gt;&lt;/strong&gt; is one HTML file. You open it, pick your &lt;code&gt;~/.claude&lt;/code&gt; folder, and it reads the session logs Claude Code already keeps on your disk. No install, no account, no API key, and nothing is uploaded: the page's Content-Security-Policy is &lt;code&gt;default-src 'none'; connect-src 'none'&lt;/code&gt;, so it cannot make a network request even if it wanted to. Open the Network tab and check.&lt;/p&gt;

&lt;p&gt;There's a &lt;a href="https://novastudio1shop-source.github.io/agent-wrapped/?demo" rel="noopener noreferrer"&gt;sample-data version&lt;/a&gt; if you want to look before pointing it at your logs.&lt;/p&gt;

&lt;h2&gt;
  
  
  What my own logs said
&lt;/h2&gt;

&lt;p&gt;About three months of Claude Code on one machine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;6.0 billion tokens&lt;/strong&gt;, worth about &lt;strong&gt;$4,339 at API list prices&lt;/strong&gt; (I'm on a subscription, so that's a measure of how hard I used it, not a bill)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;624 sessions and 2,193 subagents&lt;/strong&gt;: 60% of the usage was subagents, not me&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;71% of the cost was context&lt;/strong&gt;, not answers: writing the conversation into the prompt cache and reading it back every turn&lt;/li&gt;
&lt;li&gt;Busiest hour: &lt;strong&gt;7 am&lt;/strong&gt;. Biggest day: one Tuesday with 2.1 billion tokens&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;9 separate usage-limit walls&lt;/strong&gt;. In 7 of them, the top consumer was a scheduled agent I had running every 15 to 30 minutes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last one was the useful surprise. I thought I hit the limit because of the work I was doing. Mostly it was a loop I had forgotten about.&lt;/p&gt;

&lt;h2&gt;
  
  
  The six leaks it measures
&lt;/h2&gt;

&lt;p&gt;The free page shows how big each one is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Oversized context.&lt;/strong&gt; Every turn re-reads the whole conversation. Past 150k tokens, each further turn pays for all of it again. Mine: $276.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Subagent startup tax.&lt;/strong&gt; Each subagent loads the system prompt, every tool definition and your memory files before doing any work. Mine: $192 across 2,193 launches (median start: 28k tokens).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fat tool results.&lt;/strong&gt; A 50k-token PDF read is paid once when it arrives and again on every later turn. Mine: 5,858 results over 4k tokens, $190 in repeat cost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cache rebuilds.&lt;/strong&gt; Come back after the cache expires, switch models mid-session, or add an MCP server, and the whole context is written again at full price. Mine: 138 rebuilds, $86.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Re-reading the same files.&lt;/strong&gt; Mine: 4,018 extra reads.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Top-tier model on subagent work&lt;/strong&gt;, as a what-if rather than a recommendation.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Getting the numbers right was the hard part
&lt;/h2&gt;

&lt;p&gt;If you've tried summing Claude Code's JSONL yourself, you may have overcounted. Two traps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One response, several lines.&lt;/strong&gt; Claude Code writes each content block of a response (thinking, text, each tool call) as its own line, and every line repeats the same &lt;code&gt;usage&lt;/code&gt; object. Summing every line multiplies your usage. Agent Wrapped counts each &lt;code&gt;message.id&lt;/code&gt; once.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resumed sessions copy history.&lt;/strong&gt; Resume a session and the old turns are copied into the new file. Same fix: dedupe by message id across all files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It also prices 5-minute cache writes, 1-hour cache writes and cache reads separately per model. As a check, I compared its totals with the cost Claude Code records in its own logs, and they matched to the cent for the models I use.&lt;/p&gt;

&lt;p&gt;Everything streams through &lt;code&gt;TextDecoderStream&lt;/code&gt;, so size doesn't matter. In testing, 3.4 GB across 2,845 files took about 30 seconds in Chrome.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Free:&lt;/strong&gt; &lt;a href="https://novastudio1shop-source.github.io/agent-wrapped/" rel="noopener noreferrer"&gt;https://novastudio1shop-source.github.io/agent-wrapped/&lt;/a&gt; (MIT, &lt;a href="https://github.com/novastudio1shop-source/agent-wrapped" rel="noopener noreferrer"&gt;source on GitHub&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;If you want the detail behind each leak (the exact sessions, files and commands, a fix list written for Claude Code, what was running before each limit hit, and Markdown/PDF export), there's a &lt;strong&gt;&lt;a href="https://buy.stripe.com/9B67sN4NG6gx1yi1PJbsc0b" rel="noopener noreferrer"&gt;$9 Pro file&lt;/a&gt;&lt;/strong&gt;. It also runs offline and is yours to keep.&lt;/p&gt;

&lt;p&gt;If a number looks wrong on your logs, tell me in the comments. I'd like to know.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Independent tool, not made or endorsed by Anthropic. Written with help from Claude.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>claude</category>
      <category>ai</category>
      <category>productivity</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
