<?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: Ankan Mondal</title>
    <description>The latest articles on DEV Community by Ankan Mondal (@ankan_mondal_2b2f6eba11a0).</description>
    <link>https://dev.to/ankan_mondal_2b2f6eba11a0</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%2F3884159%2Fd98feba9-c1e3-4ed9-9320-4a9d9929701d.jpg</url>
      <title>DEV Community: Ankan Mondal</title>
      <link>https://dev.to/ankan_mondal_2b2f6eba11a0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ankan_mondal_2b2f6eba11a0"/>
    <language>en</language>
    <item>
      <title>Metering the Agentic Coding Loop: Per-Task Token Accounting for Claude Code</title>
      <dc:creator>Ankan Mondal</dc:creator>
      <pubDate>Wed, 15 Jul 2026 03:50:15 +0000</pubDate>
      <link>https://dev.to/ankan_mondal_2b2f6eba11a0/metering-the-agent-per-task-token-accounting-for-claude-code-1okc</link>
      <guid>https://dev.to/ankan_mondal_2b2f6eba11a0/metering-the-agent-per-task-token-accounting-for-claude-code-1okc</guid>
      <description>&lt;p&gt;You can already get &lt;code&gt;usage.input_tokens&lt;/code&gt; back from an API call. What you &lt;strong&gt;can't&lt;/strong&gt; get is the cost of &lt;strong&gt;JIRA-1234&lt;/strong&gt; — a multi-turn, tool-calling, cache-heavy agent session that spanned two days and three sittings.&lt;/p&gt;

&lt;p&gt;That's the instrumentation gap, and &lt;a href="https://github.com/ankan4445/claude-meter" rel="noopener noreferrer"&gt;Claude Meter&lt;/a&gt; closes it at the layer where you actually work: the CLI/IDE coding loop. This post is the engineer's cut — the cost model, the hook architecture, and the token math that makes a 452K-token session cost 34 cents.&lt;/p&gt;

&lt;h2&gt;
  
  
  The attribution gap, stated precisely
&lt;/h2&gt;

&lt;p&gt;Token spend is a first-class line item now, but observability for it is stratified by &lt;strong&gt;how the model is invoked&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Invocation surface&lt;/th&gt;
&lt;th&gt;Who owns the request loop&lt;/th&gt;
&lt;th&gt;Per-work-unit attribution&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Direct API integration&lt;/td&gt;
&lt;td&gt;Your code&lt;/td&gt;
&lt;td&gt;✓&lt;code&gt;usage&lt;/code&gt; object + your own tags&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Chat / session status UIs&lt;/td&gt;
&lt;td&gt;The vendor UI&lt;/td&gt;
&lt;td&gt;~ Per-session, not per-work-unit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CLI / IDE agentic coding&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The agent (Claude Code)&lt;/td&gt;
&lt;td&gt;✗&lt;strong&gt;The blind spot&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The reason the blind spot exists is structural: in an agentic coding session, &lt;strong&gt;you sit above the API&lt;/strong&gt;. The tool owns the request loop, so you have no natural seam to hang instrumentation on. And the work isn't a request — it's a &lt;em&gt;trajectory&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Prompt
     │
     ▼
 ┌─────────────┐   tool call (read/edit/bash)
 │  Agent turn │ ──────────────────────────────┐
 └─────────────┘                                ▼
     ▲                                  ┌────────────────┐
     │        tool result into context  │  Tool executes │
     └──────────────────────────────────└────────────────┘
     │
     ▼
 Final answer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every loop iteration re-sends accumulated context, spawns tool calls, and burns tokens across several distinct &lt;em&gt;price classes&lt;/em&gt;. That trajectory maps cleanly onto a ticket — but nothing connects the token stream to the ticket. Wiring that link is the entire product.&lt;/p&gt;

&lt;h2&gt;
  
  
  The cost model: how tokens become dollars
&lt;/h2&gt;

&lt;p&gt;The naive mental model — &lt;code&gt;cost = tokens × price&lt;/code&gt; — is wrong for agentic sessions, because not all tokens are billed at the same rate. There are (at least) four price classes:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2r7h7a5ylgrkmvbqougd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2r7h7a5ylgrkmvbqougd.png" alt="four price classes" width="586" height="76"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;where &lt;code&gt;T_in, T_out, T_cw, T_cr&lt;/code&gt; are input, output, cache-&lt;strong&gt;write&lt;/strong&gt; (creation), and cache-&lt;strong&gt;read&lt;/strong&gt; token counts. For a Sonnet-class model the price vector is roughly:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Class&lt;/th&gt;
&lt;th&gt;Symbol&lt;/th&gt;
&lt;th&gt;Price ($/M tokens)&lt;/th&gt;
&lt;th&gt;Relative to input&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Input (fresh)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;p_in&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$3.00&lt;/td&gt;
&lt;td&gt;1.0×&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Output&lt;/td&gt;
&lt;td&gt;&lt;code&gt;p_out&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$15.00&lt;/td&gt;
&lt;td&gt;5.0×&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cache write&lt;/td&gt;
&lt;td&gt;&lt;code&gt;p_cw&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$3.75&lt;/td&gt;
&lt;td&gt;1.25×&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cache read&lt;/td&gt;
&lt;td&gt;&lt;code&gt;p_cr&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$0.30&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.1×&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That last row is why metering matters. In a long coding session the &lt;strong&gt;same context gets re-sent on every turn&lt;/strong&gt;, so without prompt caching your input cost grows roughly &lt;strong&gt;quadratically&lt;/strong&gt; in turns — turn 1 re-sends 1 chunk, turn 2 re-sends 2, ..., turn N re-sends N:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F43lb77po4kpxaq31ll9v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F43lb77po4kpxaq31ll9v.png" alt="growing input cost" width="589" height="112"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;for &lt;code&gt;N&lt;/code&gt; turns each adding &lt;code&gt;Δ&lt;/code&gt; tokens of context. Prompt caching collapses the re-sent prefix to the cache-read rate — one tenth the price — so the &lt;strong&gt;cache hit ratio&lt;/strong&gt; becomes the dominant lever on session cost:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fewjynmhqvrhuw20yzh1z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fewjynmhqvrhuw20yzh1z.png" alt="cache hit ratio" width="229" height="91"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the &lt;strong&gt;savings&lt;/strong&gt; from caching are exactly the delta you didn't pay at full price:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff63ssbthur451gsolgu9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff63ssbthur451gsolgu9.png" alt="savings" width="250" height="58"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A generic billing dashboard reports one blended number. A meter that separates these four classes tells you &lt;em&gt;why&lt;/em&gt; a task was cheap or expensive — and whether your context strategy is actually hitting cache. We validate all of this against a real run below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture: a Stop hook, a state file, a command
&lt;/h2&gt;

&lt;p&gt;Claude Meter is a Claude Code plugin (JavaScript, Node ≥ 18) installed from a marketplace. Naming to keep straight: &lt;code&gt;claude-meter&lt;/code&gt; is the &lt;strong&gt;marketplace/repo&lt;/strong&gt;; &lt;code&gt;session-manager&lt;/code&gt; is the &lt;strong&gt;plugin&lt;/strong&gt; you install, which exposes &lt;code&gt;/session-manager:meter&lt;/code&gt;. Three moving parts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; ┌──────────────────────────── Claude Code session ────────────────────────────┐
 │                                                                              │
 │   every turn ──► Stop hook (hooks.json)                                       │
 │                     │  reads local transcript                                │
 │                     │  accumulates 4 token classes + activity                │
 │                     ▼                                                         │
 │            .claude/sessions/active.json   ◄── live state                      │
 │                     │                                                         │
 │   end / clear ──────┴────► .claude/sessions/name-id.json   ◄── archive        │
 └──────────────────────────────────────────────────────────────────────────────┘

   Slash command  ── /session-manager:meter ─► reads/controls state
   Skill          ── natural-language trigger ─► same underlying logic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The &lt;code&gt;Stop&lt;/code&gt; hook&lt;/strong&gt; — registered via &lt;code&gt;hooks/hooks.json&lt;/code&gt;, fires after &lt;em&gt;every&lt;/em&gt; turn, reads the local transcript, and accumulates the four token classes plus activity counters into the active session. This is why tracking is zero-setup: the hook is the collector, and it's already wired.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Session state&lt;/strong&gt; — the live tally lives in &lt;code&gt;.claude/sessions/active.json&lt;/code&gt;; &lt;code&gt;end&lt;/code&gt;/&lt;code&gt;clear&lt;/code&gt; archives it to &lt;code&gt;.claude/sessions/name-id.json&lt;/code&gt;, so history is preserved and queryable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Command + skill&lt;/strong&gt; — drive it with the &lt;code&gt;/session-manager:meter&lt;/code&gt; slash command, or trigger the same logic via a natural-language skill.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Pricing&lt;/strong&gt; resolves from the &lt;a href="https://github.com/BerriAI/litellm" rel="noopener noreferrer"&gt;LiteLLM model-pricing list&lt;/a&gt;, fetched once and cached locally for 24h. If the fetch is blocked (corporate firewall), it falls back to a hardcoded price table — tracking degrades gracefully and &lt;strong&gt;no session data is ever transmitted off-box&lt;/strong&gt;. Everything above is computed locally against the local transcript.&lt;/p&gt;

&lt;h2&gt;
  
  
  The data model: what a session actually stores
&lt;/h2&gt;

&lt;p&gt;The archived session is plain JSON you own—no black box, nothing exfiltrated. Every number the report prints is a field you can inspect yourself:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fa1fevqssk39suov7f8v4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fa1fevqssk39suov7f8v4.png" alt="The raw archived session file — token counts per class, activity counters, estimatedCostUSD, cache savings, plus the git branch and commit captured at session start." width="760" height="640"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The schema is essentially the cost-model inputs plus provenance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json-doc"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"label"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"xyz"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"inputTokens"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="c1"&gt;// T_in&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"outputTokens"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;           &lt;/span&gt;&lt;span class="c1"&gt;// T_out&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"cacheCreationTokens"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;// T_cw&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"cacheReadTokens"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;411505&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="c1"&gt;// T_cr&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"turns"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;                 &lt;/span&gt;&lt;span class="c1"&gt;// N&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"toolCalls"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"bashCommands"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"estimatedCostUSD"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;0.3379&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// C_session&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"cacheSavingsUSD"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;1.1111&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="c1"&gt;// S&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"gitBranch"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="c1"&gt;// provenance: pins cost to repo state&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"gitCommit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"..."&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Capturing &lt;code&gt;gitBranch&lt;/code&gt; + &lt;code&gt;gitCommit&lt;/code&gt; at start is the detail that makes a session genuinely &lt;em&gt;tied to a moment in your repo's history&lt;/em&gt; — cost attribution with a commit anchor, not just a label.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reading the meter: a worked example
&lt;/h2&gt;

&lt;p&gt;Here's a real collated report from &lt;code&gt;/session-manager:meter stat xyz&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0x7d867ffgdgun7hyzej.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0x7d867ffgdgun7hyzej.png" alt="One session: 452,265 total tokens, $0.3379 actual cost. Cache read = 411,505 tokens (91% of all tokens), saving ~$1.11 versus full input price. Also 11 turns, 10 tool calls, 7 bash commands." width="800" height="714"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's plug the real numbers into the model and confirm it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxlraday3xc3v2c2nog1w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxlraday3xc3v2c2nog1w.png" alt="numbers" width="800" height="541"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;i.e. a blended rate &lt;strong&gt;4× below&lt;/strong&gt; the fresh-input rate of $3/M — a single scalar that tells you your context strategy is doing its job. &lt;em&gt;That's&lt;/em&gt; the difference between a bill and a diagnostic: the meter doesn't just say a task was cheap, it shows you the mechanism (&lt;code&gt;ρ ≈ 0.91&lt;/code&gt;) that made it cheap.&lt;/p&gt;

&lt;h2&gt;
  
  
  Modes and the work-unit lifecycle
&lt;/h2&gt;

&lt;p&gt;Invoke &lt;code&gt;/session-manager:meter&lt;/code&gt; with no argument for the menu, or pass a mode directly:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F51dg1ratke7mstztv99j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F51dg1ratke7mstztv99j.png" alt="The /session-manager:meter menu — eight modes in plain English; reply with a number or keyword." width="534" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Mode&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;th&gt;Maps to&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;start [label]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Begin a tracked session, labeled with the ticket&lt;/td&gt;
&lt;td&gt;task kickoff&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;show&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Live metrics mid-work&lt;/td&gt;
&lt;td&gt;in-flight monitoring&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;end&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Stop + print final report&lt;/td&gt;
&lt;td&gt;task done&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;clear&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Archive current, start fresh&lt;/td&gt;
&lt;td&gt;context reset&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;resume &amp;lt;name&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Continue an archived session&lt;/td&gt;
&lt;td&gt;multi-sitting work&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;stats &amp;lt;name&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Aggregate all runs for a name into one total&lt;/td&gt;
&lt;td&gt;durable roll-up&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;token-breakdown [name]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Attribute tokens: thinking / replies / tools&lt;/td&gt;
&lt;td&gt;root-causing cost&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A typical loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/session-manager:meter start &lt;span class="s2"&gt;"JIRA-1234"&lt;/span&gt;   &lt;span class="c"&gt;# kickoff&lt;/span&gt;
/session-manager:meter show                &lt;span class="c"&gt;# peek at live ρ and cost&lt;/span&gt;
/session-manager:meter end                 &lt;span class="c"&gt;# final report&lt;/span&gt;
&lt;span class="c"&gt;# later, across sittings:&lt;/span&gt;
/session-manager:meter resume &lt;span class="s2"&gt;"JIRA-1234"&lt;/span&gt;
/session-manager:meter stats  &lt;span class="s2"&gt;"JIRA-1234"&lt;/span&gt;  &lt;span class="c"&gt;# one honest number for the ticket&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two design choices carry the weight:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;resume&lt;/code&gt; + &lt;code&gt;stats&lt;/code&gt;&lt;/strong&gt; make the work unit &lt;em&gt;durable&lt;/em&gt;: a ticket spanning three sittings across two days still rolls up into a single figure — &lt;code&gt;C_ticket = Σ C_session_i&lt;/code&gt; over all runs sharing a label.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;token-breakdown&lt;/code&gt;&lt;/strong&gt; turns the meter into a profiler. Knowing a task spent its budget on &lt;em&gt;thinking&lt;/em&gt; tokens vs. &lt;em&gt;tool&lt;/em&gt; churn tells you something actionable about how the work was structured — the same way a flame graph tells you where CPU went.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why quantification compounds
&lt;/h2&gt;

&lt;p&gt;Measurement changes behavior. Once per-task cost is visible, value compounds on two timescales.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short term&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Immediate per-task cost.&lt;/strong&gt; The instant &lt;code&gt;end&lt;/code&gt; runs, you have tokens, dollars, and wall-clock for the ticket — no monthly-invoice lag.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Live course-correction.&lt;/strong&gt; &lt;code&gt;show&lt;/code&gt; mid-session catches a runaway &lt;em&gt;while it's running&lt;/em&gt;: if a "simple" fix is 5× the tokens you expected, that's a signal (bad context, thrashing, over-broad prompt) before you burn more.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Like-for-like comparison.&lt;/strong&gt; Session ≙ work unit, so "this refactor cost 2× that one — why?" becomes answerable via &lt;code&gt;token-breakdown&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero-friction adoption.&lt;/strong&gt; Tracks out of the box, stores locally, adds no external dependency — the cost of &lt;em&gt;starting&lt;/em&gt; to measure is ~0.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Long term&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Baselines per task class.&lt;/strong&gt; Aggregate enough sessions and a bug fix trends at &lt;code&gt;X&lt;/code&gt; tokens, a migration at &lt;code&gt;Y&lt;/code&gt;. Estimates become distributions, not vibes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Defensible ROI.&lt;/strong&gt; Pair &lt;code&gt;C_session&lt;/code&gt; against elapsed time: &lt;em&gt;this task cost $C and saved H hours.&lt;/em&gt; That's the sentence finance actually wants.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real optimization targets.&lt;/strong&gt; Attribution → attack: surface token-hungry task classes, tune prompt/context strategy (drive up &lt;code&gt;ρ&lt;/code&gt;), and &lt;em&gt;measure&lt;/em&gt; whether the number moved.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Forecasting.&lt;/strong&gt; Per-work-unit history turns "what will AI-assisted dev cost next quarter?" into a projection grounded in your own tickets.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cultural shift.&lt;/strong&gt; When engineers can &lt;em&gt;see&lt;/em&gt; the meter, token efficiency gets scoped in — the way visible latency dashboards made teams performance-aware.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;You cannot optimize what you cannot measure. Claude Meter's contribution is narrow but foundational: it makes token cost measurable at the one place it was invisible — the CLI/IDE coding session — and pins that measurement to the unit of work the rest of the org already speaks in.&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;Claude Meter is open source under the MIT license. Start a session named after your next ticket, end it when you're done, and read the receipt.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Repo, install instructions, and docs → &lt;a href="https://github.com/ankan4445/claude-meter" rel="noopener noreferrer"&gt;github.com/ankan4445/claude-meter&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If this was useful, a ❤️ or 🦄 helps, and I'd love to hear how per-task metering changes the way you scope work.&lt;/p&gt;

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