Video 03 · Four builds · 138 hidden tests
How to save tokens in Claude Code: 18M to 3M on one app
The short answer
To save tokens in Claude Code, make fewer calls, give fresh sessions a written memory and switch off what you don’t use. On the same 13 tickets, one long chat used 18 million tokens and fresh sessions with a written memory used 3 million. Both builds ran once, in November 2026, and passed all 138 hidden tests on the first run. The bill at Sonnet 5.5 list prices fell only 9%: the saved tokens were cheap cache reads, which also count less against plan limits.
- Written for
- Founders and CTOs whose Claude limits run out before the work does
- Video
- Read
- Published
- Drawn
- AI draft, from the video
- Checked
- Marko Živić
Video 03 · · 15:00 CET
Plays on YouTube · nothing loads until you press play
Watch on YouTube (opens in a new tab)In this video
20 chapters
- One app, four builds: 18M to 3M tokens (opens in a new tab)
- Four builds, one judge: the token totals (opens in a new tab)
- How do you compare two AI builds fairly? (opens in a new tab)
- Why does one long Claude chat burn so many tokens? (opens in a new tab)
- Do fresh sessions save tokens? (opens in a new tab)
- What do fresh sessions really cost? (opens in a new tab)
- Should you trust AI when it says the tests pass? (opens in a new tab)
- Cache writes: the cost you don’t see (opens in a new tab)
- Build 2: the four changes that cut tokens to 3M (opens in a new tab)
- What goes in a CLAUDE.md that saves tokens? (opens in a new tab)
- What cut the tokens most? Fewer calls (opens in a new tab)
- Which Claude Code settings should you switch off? (opens in a new tab)
- Why Claude forgets between calls, and how build 2 remembered (opens in a new tab)
- Where build 2 saved its tokens (opens in a new tab)
- Isn’t a bigger CLAUDE.md bad practice? (opens in a new tab)
- When is a written memory worth the effort? (opens in a new tab)
- 6 times fewer tokens, only 9% cheaper: why? (opens in a new tab)
- Why fewer tokens cost 2.6 times as much (opens in a new tab)
- Should you optimize for tokens or for the bill? (opens in a new tab)
- What to check in your own AI usage today (opens in a new tab)
Four builds, one judge: the token totals
The same 13 tickets took 18 million tokens in one long Claude Code chat and 3 million in fresh sessions with a written memory. Both builds passed all 138 hidden tests on the first run. They ran on 4 and 5 November 2026.
A developer on my team handled the 13 tickets in a single chat. A ticket is one written task, and a token is about 4 characters of English. He ended up spending about 18 million tokens.
Then I changed one thing on purpose. I stopped Claude Code after every ticket, with /exit. That was build 1, and it ended at 11.4 million tokens after four fix sessions.
Build 2 was me optimizing for fewer tokens. It ended at just 3 million, and all the tests were green after the first run. That’s fewer than his one-shot of a smaller app, which took 3.9 million, almost half of it for one bug fix.
A3 · Four builds, one judge Drawn for this page · Video 03
Tokens per build
- One long chat : 18M , 138 of 138 · first run
- Build 1 · fresh sessions : 11.4M , 120 of 138 · first run , 4 fix sessions included
- Build 2 · fresh sessions + written memory : 3M . Marko’s note: fewer calls made. , 138 of 138 · first run
- A smaller app : One-shot from a spec : 3.9M , 132 of 132 · its own tests , 1 bug fix included
Judge · 138 hidden tests · no session opened them
I never told him to be careful about tokens, so he just built the app the way he normally would. A token count alone can’t compare two builds, so hidden tests judged every one. Other things differed too, and the box says which.
How this was tested
- What ran
- One test app, a strength-training tracker, built three ways from the same 13 tickets. Plus a one-shot of a smaller app.
- Held equal
- Claude Code 2.1.311, Sonnet 5.5, medium effort. The same tickets and hidden tests, written by a third party.
- Measured
- Every token, fix sessions included, from Claude Code’s own session files. The video shows the totals. The detail on this page comes from the same session files.
- Bill
- An index: each kind of token times its list-price ratio. Not what anyone paid.
- Judged by
- 138 hidden tests that no session ever opened, 24 of them in a real browser. Fix sessions saw only the failing tests’ names and messages.
- When
- 4 and 5 November 2026.
Limits
- Each build ran once.
- The one-shot built a smaller app with its own 132 tests, so its total is a reference only.
- A developer ran the long chat by hand. In my two builds a script pasted the prompts and committed the code.
- The skills each build’s sessions listed differed.
- I designed build 2 after build 1 failed.
- I counted tokens, not plan usage: cached tokens count less against plan limits.
Why does one long Claude chat burn so many tokens?
Because every call sends the whole chat again. In one long Claude Code chat, a short commit message cost 127,659 tokens after ticket 1 and 372,796 after ticket 11.
AI models keep nothing between calls (a call is one request to the model). It’s logical to us that the model knows what was said earlier in the chat, but it doesn’t. So between every two calls he made, Claude Code sent the full conversation again.
A commit saves the work. Eight of his messages only asked for a commit, 129 typed characters in all. Together they cost more than 2 million tokens.
The same commit messageOne long chat · 8 commit messages
In one long chat, a short commit message cost 127,659 tokens after ticket 1 and 444,726 after ticket 13.
The numbers
| Commit message | Tokens |
|---|---|
| After ticket 1 | 127,659 |
| After ticket 2 | 170,375 |
| After ticket 3 | 196,401 |
| After ticket 4 | 217,036 |
| After ticket 5 | 235,977 |
| After ticket 9 | 305,264 |
| After ticket 11 | 372,796 |
| After ticket 13 | 444,726 |
That’s why AI gets so expensive the longer you use it. Every new prompt pays for everything above it.
And 4.4 million of his 18 million tokens went to calls nobody typed. Claude Code sends prompt suggestions and session recaps on its own.
On a Claude plan, tokens are what uses up your limits: a session limit that resets every five hours, plus weekly limits. But they don’t all count the same. Claude’s help center says cached content, text that was stored and is read again, counts less against your limits than new content. It gives no number.
There is a good side. The chat carried every earlier decision, so all 138 hidden tests were green from the first go. He wasn’t careful at all, because he didn’t have to be. He paid for that peace of mind with 18 million tokens.
Do fresh sessions save tokens?
Yes per call, but fresh sessions forget. Build 1, a fresh Claude Code session for every ticket, used 37% fewer tokens than the long chat: 11.4 million against 18 million. The average call fell from about 128,000 tokens in the long chat to about 65,000. But build 1 failed 18 of the 138 hidden tests on its first full run.
Ticket 1 set a rule for how the app knows what day it is. Its own session noted that nothing in that ticket used a date yet, and left the rule for later. No later ticket session saw that rule. 17 of the 18 failures came from ticket 1’s rules.
In the fix sessions I had a fun experience. Claude Code said it fixed everything, and the tests still failed. Then it told me the tests were bad and not the code.
“the test clock, not ... a bug in the code”
Rejected
The app had never read ticket 1’s date rule.
So should you trust AI when it says the tests pass? No, you should never do that. When the same agent writes the tests and the code, it usually builds tests that pass around the code it wrote.
I’ve seen the same with reviews. Claude reviewed an app it had just built and reported 2 minor issues, and a separate review found 31 findings.
The first two fix sessions spent 1.5 million tokens and fixed 2 of the 18. The third got ticket 1’s rule quoted, cost 390,029 tokens and fixed 15. A fourth fixed the last one.
Build 1’s road to 138Hidden tests passed · 4 fix sessions
Build 1 passed 120 of 138 hidden tests on its first run. Four fix sessions and 2,783,336 more tokens took it to 138.
- 120 of 138first full run
- 122 of 138fix 1 · 1,003,350 tokens
- 122 of 138fix 2 · 506,680 tokens · blamed the tests
- 137 of 138fix 3 · 390,029 tokens · quoted ticket 1’s rule
- 138 of 138fix 4 · 883,277 tokens
The numbers
| Step | What happens | Note |
|---|---|---|
| 1 | 120 of 138 | first full run |
| 2 | 122 of 138 | fix 1 · 1,003,350 tokens |
| 3 | 122 of 138 | fix 2 · 506,680 tokens · blamed the tests |
| 4 | 137 of 138 | fix 3 · 390,029 tokens · quoted ticket 1’s rule |
| 5 | 138 of 138 | fix 4 · 883,277 tokens |
What do fresh sessions really cost?
More than the saving per call suggests. Build 1, a fresh Claude Code session per ticket, spent 2.8 million tokens on fixes and about 1.55 million on skills it never used. It also wrote almost 4 times as much into the cache as one long chat.
Up to 83 skills were listed on every call (a skill is saved instructions Claude can load for one job). The build never used them. The long chat’s sessions listed 46 skills too, and its files don’t show what those cost.
Each fresh session also had to store what it read again, for reuse: 800,820 cache-write tokens, against 213,902 in the long chat. Writing into the cache is expensive.
The question I keep seeing is whether you should start a new chat for every task. My answer is yes, in an ideal world where the task is completely defined. That includes what earlier tasks agreed on, and build 1’s sessions didn’t have it.
Build 2: the four changes that cut tokens to 3M
Build 2 kept a fresh Claude Code session for every ticket and changed four things. The same 13 tickets took 3 million tokens, and all 138 hidden tests passed on the first run.
- A written memory in CLAUDE.md, the file Claude Code reads when a session starts. It held 12 working rules, the rules each ticket set and a map of the files.
- A new test file for every ticket, 95 tests by ticket 13.
- As few calls as possible. Read once. Write everything and run the checks. Then answer in one short sentence.
- A lean setup. One settings file told Claude Code not to load skills, prompt suggestions or recaps.
CLAUDE.md is the main character of this build. It was like Claude’s working memory, the same idea I run my business on with a Claude + Obsidian second brain. Take the date rule that broke build 1. In build 2, ticket 1’s session put it off again, but this time it wrote the rule down first.
“(No test yet: nothing uses today.)”
Holds
Ticket 2’s session started with that line, built the rule and wrote a test for it.
Ticket 1 took 2 calls, against 10 in build 1. One thing I want to flag. Ticket 6 cost the most, because it changed rules from tickets 3 and 5. With a written memory, changing behavior costs more than building something new.
Build 2, ticket by ticket13 ticket sessions · one run
In build 2, the ticket that changed earlier rules cost the most: ticket 6, with 427,611 tokens and 8 calls.
| Ticket | Tokens | Calls |
|---|---|---|
| 1 · project setup and the exercise catalogue | 127,879 | 2 calls |
| 2 · logging workouts | 352,542 | 5 calls |
| 3 · personal records | 233,654 | 4 calls |
| 4 · kg or lb | 162,317 | 3 calls |
| 5 · warm-up sets, working sets and volume | 164,439 | 3 calls |
| 6 · more kinds of records | 427,611 | 8 calls |
| 7 · shorter default title | 179,810 | 4 calls |
| 8 · progress per exercise | 164,352 | 3 calls |
| 9 · dashboard, weekly goal and streaks | 326,132 | 5 calls |
| 10 · statistics API | 154,552 | 3 calls |
| 11 · workout templates | 197,433 | 3 calls |
| 12 · CSV export and import | 375,240 | 6 calls |
| 13 · reorder exercises, repeat a workout, filter History | 166,951 | 3 calls |
| All 13 tickets | 3,032,912 | 52 calls |
What cut the tokens most? Fewer calls
Fewer calls. Build 2 was told to work in as few calls as possible, and Claude Code made 52 in its 13 ticket sessions. Build 1 made 119. No other change cut more tokens.
Receipt 01 · My own count · n = 1 Built 5 Nov 2026
52 calls against 119
Calls to the model in the 13 ticket sessions, build 2 against build 1.
Source Session files of build 1 and build 2, video 03 youtube.com (opens in a new tab)Take out the unused skills, and a call in build 1 was about as big as a call in build 2. By my estimate, both carried about 58,000 tokens. Same size per call, half the calls.
Build 2 used 8.39 million fewer tokens than build 1. Almost half of that came from doing the same tickets in fewer calls, and a quarter from fix sessions that never happened. The two switches (skills and calls nobody typed) explain the last 30% or so.
Where build 2 savedAgainst build 1 · my estimate
By my estimate, fewer calls saved about 3.92 million of the 8.39 million tokens build 2 saved against build 1.
The numbers
| Change | Tokens saved, about | Build 1 to build 2 |
|---|---|---|
| Fewer calls, same tickets | 3.92 million | 119 calls down to 52 |
| Fixes that never happened | 2.04 million | 4 fix sessions down to none |
| Skill listings | 1.55 million | on every call, then off |
| Calls nobody typed | 0.88 million | 911,626 to 28,271 tokens |
The fix sessions cost 2.8 million tokens in all. The split counts their skill listings and calls nobody typed under the two switches, so it shows 2.04 million.
Which Claude Code settings should you switch off?
The ones for things you don’t use. In one long Claude Code chat, calls nobody typed took 4.4 million of 18 million tokens. With prompt suggestions and session recaps switched off, build 2 spent 28,271 tokens on them.
Calls nobody typed4 builds · switched off in build 2
Calls nobody typed took 4,383,983 tokens in the long chat and 911,626 in build 1. Switched off, build 2 spent 28,271.
The numbers
| Build | Tokens in calls nobody typed |
|---|---|
| One long chat | 4,383,983 |
| Build 1 · fresh sessions | 911,626 |
| Build 2 · fresh sessions + written memory | 28,271 |
| One-shot · a smaller app | 460,249 |
Build 2 started every session with one settings file. It holds seven settings, and Claude Code’s settings docs explain each one.
- syncClaudeAiSkills: false. Stops loading the skills from your claude.ai account.
- syncClaudeAiPlugins: false. The same for plugins.
- disableClaudeAiConnectors: true. Turns off the claude.ai connectors.
- disableBundledSkills: true. Turns off the skills that ship with Claude Code.
- promptSuggestionEnabled: false. No suggested next prompt after each reply.
- awaySummaryEnabled: false. No recap when you come back to the terminal.
- enableArtifact: false. Turns off the Artifact tool.
There’s one catch. The two sync keys are ignored in a project’s shared settings file. Put them in your user settings, or pass a file with --settings.
Did you know about these settings?
Marko’s note: you’re paying for it in every single prompt you run
Even a lean session has a floor. Build 2’s first call carried 37,029 tokens, and about 30,000 of them were Claude Code’s own setup.
Isn’t a bigger CLAUDE.md bad practice?
Not at this size. Over 13 tickets, the CLAUDE.md that Claude Code kept in build 2 grew to 75 lines. Claude Code’s docs set the target at under 200. By the last ticket, a session’s first call was about 4,000 tokens bigger.
Receipt 02 · Official docs Read 16 Nov 2026
“target under 200 lines per CLAUDE.md file”
Longer files take more context, and Claude follows them less closely.
Source Claude Code docs, How Claude remembers your project code.claude.com (opens in a new tab)The file almost tripled, from 5,431 characters after ticket 1 to 15,631 at the end. At 4 characters a token, that’s about 2,500 of the 4,000 tokens. The session files don’t split the rest.
That’s the price in tokens, against half the calls and no fix sessions. But I had to pay for it with my own thinking and my own rules.
On a serious product I wouldn’t keep it all in CLAUDE.md. I’d build memory files that CLAUDE.md points to. And for a small project like this one, a single chat is fine.
Marko’s note: go ahead waste tokens
I think a written memory starts to pay once the build takes AI more than 2 hours.
6 times fewer tokens, only 9% cheaper: why?
Because two tokens do not cost the same. On the same 13 tickets, fresh sessions with a written memory used about 6 times fewer tokens than one long Claude Code chat. The bill at Sonnet 5.5 list prices was only 9% lower.
Maybe I’m weird, but I find this part the most interesting. Six times the tokens, and almost the same bill. Against build 1, build 2’s bill was 38% lower.
Tokens against the billLong chat = 100 · Sonnet 5.5 list prices
Build 2 used about 6 times fewer tokens than one long chat. Its bill at Sonnet 5.5 list prices was only 9% lower.
The numbers
| Measure | One long chat | Build 2 · fresh sessions + written memory |
|---|---|---|
| Tokens | 100 | 16.9 |
| Bill at list prices | 100 | 91.2 |
A token comes in four kinds, and each kind has its own price. Reusing stored text (a cache read) is the cheapest. Storing text for reuse (a one-hour cache write) costs 40 times as much, and what the model writes (output) costs 100 times as much. The ratios are from Anthropic’s price list for Sonnet 5.5, as of 16 Nov 2026.
What each kind of token costsSonnet 5.5 list prices · cache read = 1
If a cache read costs 1 at Sonnet 5.5 list prices, input costs 20, a one-hour cache write 40 and output 100.
The numbers
| Kind of token | Price per token, cache read = 1 | What it is |
|---|---|---|
| Cache read | 1 | reusing stored text |
| Input | 20 | new text sent |
| Cache write, one hour | 40 | storing text for reuse |
| Output | 100 | what the model writes |
Build 2 cut the cheap kind. Of the long chat’s 18 million tokens, 17.6 million were cache reads. Build 2 used more of every other kind: its cache writes more than doubled, and its output rose 12%.
The one-shot shows it best. It used more tokens than build 2: 3.9 million on its smaller app, bug fix included. What do you think the difference in the bill was? Build 2’s was 2.6 times as high, with 4.6 times the cache writes and 2.5 times the output.
Should you optimize for tokens or for the bill?
It depends on how you pay. On a Claude plan, optimize for fewer tokens, because tokens use up your limits. When AI runs inside your product and you pay per token, optimize for the bill.
On a plan, fewer tokens still means more room, but less than 6 times more. Every token build 2 saved was a cache read, and Claude says cached content counts less against your limits. I can’t tell you how much less.
For the bill, cache everything that doesn’t change often. Be careful not to write a lot into the cache. And cut the output you don’t need, because we all know AI likes to be chatty.
My verdict from four builds: build 2 used about 6 times fewer tokens than one long chat, and the same tests stayed green. Each build ran once. No single change did it. Against build 1, fewer calls saved the most.
Before your next ticket, write down the rules your project must never lose. Then start it in a fresh session.
Before your next Claude Code build.
- A fresh session starts with that file, the ticket and the code. Nothing else.
- A passing test the builder wrote is a claim, not proof.
- Fewer calls were the biggest saving.
- You pay for them in every prompt.
- Two tokens don’t cost the same.
Think thrice, prompt twice, inspect always.
If you want to dig deeper, the AI usage audit is free.
If your app has paying users and you want to add or improve its AI features, book a 20-minute call.
Free · one Claude skill
Run the AI usage audit on your own code.
- AI usage audit · finds where your tokens leak, with the fix
If you want to dig deeper, start here. It reads how your product calls AI and writes one report: every token leak, its file and line, the cause and the fix.
Free, by email. Copy it, share it, change it.
Sources · 9
Checked
- Manage costs effectively, Claude Code docs, page undated, read 16 Nov 2026 code.claude.com (opens in a new tab)
- How do usage and length limits work?, Claude Help Center, page undated, read 16 Nov 2026 support.claude.com (opens in a new tab)
- Usage limit best practices, Claude Help Center, page undated, read 16 Nov 2026 support.claude.com (opens in a new tab)
- All settings, Claude Code docs, page undated, read 16 Nov 2026 code.claude.com (opens in a new tab)
- Settings files and precedence, Claude Code docs, page undated, read 16 Nov 2026 code.claude.com (opens in a new tab)
- How Claude remembers your project, Claude Code docs, page undated, read 16 Nov 2026 code.claude.com (opens in a new tab)
- What are tokens?, OpenAI Help Center, page undated, read 16 Nov 2026 help.openai.com (opens in a new tab)
- Pricing, Claude Platform Docs, page undated, Sonnet 5.5 rows read 16 Nov 2026 platform.claude.com (opens in a new tab)
- Video 03: Same app, 600% less tokens. Four builds with Claude, Marko Živić, YouTube, 20 Nov 2026 youtube.com (opens in a new tab)
Corrections
None yet. Found a mistake? Email marko@inspectedbymarko.com. I pin every correction here, with the date.