Halving Claude Code requests cuts per-test cost by only 15%

This article has been automatically translated.
Loading article...
Merry Christmas & Happy New Year!
Loading article...

This article has been automatically translated.
If you're running a large test suite with Claude Code, you may have hit this: you're mid-afternoon in the middle of writing, the interface pops up a weekly limit notice, and for the next few days all test design, execution, and fix confirmation go back to manual. Motegi, a QA engineer at Deep Groove, ran into exactly this. He used local session logs to work out where the tokens were going, and ran an experiment to "halve a single request." The conclusion is a bit counterintuitive: input tokens per request were nearly halved, but main-session consumption per ticket dropped only about 15%, and the savings were quickly eaten up by newly added skills. This article breaks down his method and its trade-offs, to help you work out in your own environment how much "one test" actually costs.
Motegi 的做法很朴素:不再让 AI 自己记录开始和结束时间(那本身就要烧 token),而是直接读 Claude Code 留在本地的会话日志,也就是 ~/.claude/projects/ 目录下的 .jsonl 文件,用脚本汇总。
In a long session that reached 960 requests, he found that about 53% of consumption came from "context re-reading." The reason is that Claude Code re-reads the entire prior conversation on every request, so content from long ago that is irrelevant to the current task gets billed over and over.
This explains a key causal link: the longer the session, the higher the marginal cost of each subsequent request. So "shortening sessions" looks like the most direct way to save money, and it became the starting point of his experiment.
It's worth noting that Motegi assigned weights to different token types (input 1, cache read 0.1, cache creation 1.25–2, output 5). He set these himself based on the ratios in Claude API pricing; they are not an Anthropic-published calculation method. When reproducing, treat this as a relative comparison basis, not an official benchmark.
He split the work at the point where tests run automatically, writing only the necessary information into a new session to continue. When context exceeded 150,000 tokens, a hook sent a reminder.
The effect was clear at the single-request level: median input tokens per ticket fell from 490,000 to 260,000, nearly halved, and the weekly total dropped 39%.
But measured as "main-session consumption per ticket," the median fell only from 29.6M to 25.1M, a 15% drop. Comparing by "work per hour" gives the same 15%.
The gap comes from the cost of splitting itself: each new session has to rebuild context, and there are extra handoff requests. Motegi recorded about a 30% increase in main-session request count.
The lesson here is practical for anyone doing cost optimization: choose "per ticket" or "per hour" as your optimization metric, not "single request size"—otherwise you'll overestimate the benefit.
There was a very concrete pitfall in the experiment. He split into 40 sessions, and 22 of them were forced splits mid-work rather than at natural points.
The reason is that a new session's first request already reads in about 110,000 tokens (project instruction file CLAUDE.md, memory index MEMORY.md, etc.). If the threshold is 150,000, only about 40,000 is left for actual work, and another split triggers 13 minutes later.
After he raised the threshold to 300,000, cases of re-splitting within 15 minutes of startup fell from 7 to 0.
You can think of it this way: the threshold must leave enough headroom for "startup overhead + one complete piece of work." By analogy, it's like setting a refuel warning line on a fuel tank—if the warning line is too close to the bottom, you'll have to come back not long after filling up. This analogy only illustrates the idea of headroom; it doesn't involve specific fuel-consumption figures.
Motegi originally assumed the 50M-per-hour spikes were caused by running test execution in parallel.
But combining three weeks of data, test execution accounted for only about 10%, and nearly 70% of consumption was in the main session. In other words, concurrent subagents are conspicuous, but the steadily accumulating main-session context is the real volume.
This finding determined the optimization order: squeeze the main session first, then consider downgrading the model for subagents. He later switched the subagent default model from Opus to Sonnet, and Sonnet's share of subagent consumption rose from 29% to 52%. However, he also notes that browser-operation subagents are specified as Opus in the skill, so even with the default changed to Sonnet they still run on Opus.
This is the most memorable counterintuitive conclusion in the article.
In the week he saved 15%, he was still blocked by the weekly limit on Thursday afternoon, 4 days 17 hours after the week started; the previous time was 4 days 14 hours, a difference of only 3 hours. He found the limit notices in the logs and summed the consumption from the start of each week to the trigger time—all three stopped at around 600M.
His inference is that the weekly available amount is essentially fixed, and the saved portion was consumed by two subagent skills added in the same week.
The takeaway for readers is that saving tokens isn't the goal in itself. You need to measure "how much actual output each unit of token produces," otherwise optimization just shifts budget to new features. Motegi himself says he will next focus on comparing token consumption against business impact.
Here are the steps he gave, organized into a process for practicality:
grep -rhoE 'hit your weekly limit · resets [^"\\]+' ~/.claude/projects/ | sort | uniq -cNote that this command will also match sessions that merely quote that wording (such as article drafts), so look only at the date and time, not the count.
If you can't get data at some step, don't jump to conclusions: the log format is part of Claude Code's internal implementation and may change after version upgrades; logs are cleaned up after 30 days by default, controlled by cleanupPeriodDays, so confirm they haven't been cleared before measuring.
Motegi explicitly acknowledges several boundaries, and readers should keep these uncertainties in mind when reproducing:
What is really worth taking away is not the “halved” figure itself, but comparing the saved quota against the output of new skills, rather than assuming that saving means it will last longer.