跪拜 Guibai
← Back to the summary

Claude Code's Experimental Code Mode: A Real 3-Round Test Shows 13% Savings, Not 77%

Hello everyone, I'm Meng Jian.

I spend about 17,000 RMB a year on AI tools. I mainly use Claude Code for coding, so I pay close attention to token costs. Anthropic added an experimental feature called Code Mode to Claude Code. The idea is not to change models, but to have Claude first write a piece of JavaScript that chains multiple operations together, compressing context and reducing tokens. A 36Kr report titled it "can save up to 77%." I ran the same task three times with it on and off, to see what the real numbers are.

The first round in normal mode ended like this:

Normal mode first round, the reply shows config extracted to lib/config.js, top right shows $0.1813

Results first

Dimension Round 1 Round 2 Round 3
Normal mode cost $0.1813 $0.1794 $0.1841
Code Mode cost $0.1480 $0.1763 $0.1516
Normal mode task time 26s 28s 28s
Code Mode task time 23s 32s 25s

Averaging over three rounds, normal mode cost $0.1816, Code Mode cost $0.1586, saving about 13%. Speed is about the same: normal mode 26 to 28 seconds, Code Mode 23 to 32 seconds, fluctuations within normal range.

Tokens saved more than money. In the /cost statistics, for cache read (reading context), normal mode was 317k, 264k, 381k across three rounds, while Code Mode was 178k, 265k, 178k, averaging over 30% less. Money only saved a bit over 10% because each round also has about 28k of cache writes, which have a much higher unit price, and that's similar whether Code Mode is on or not.

The 77% figure comes from a 36Kr report dated November 18, referring to scenarios with high-frequency external tool calls, where the total tokens processed by the model dropped by 62% to 77%. The same report's cost calculations show multi-step development tasks saving 22% to 23%, e.g., adding a command-line parameter with tests, dropping from $0.45 to $0.35 per run. My test task only modifies one local file and re-runs tests, simpler than both, so 13% is not surprising.

What is Code Mode and who can use it

The feature launched in v2.1.323, off by default, officially noted as experimental and subject to change or removal at any time. Before enabling, confirm the following:

How to enable

The current version (v2.1.332) does not provide the command-line argument --experimental-code-mode. The official docs recommend setting an environment variable in PowerShell before launching:

$env:CLAUDE_CODE_EXPERIMENTAL_CODE_MODE='1'; claude

This setting only lasts for the current terminal window; closing the window clears it, and you need to set it again next time.

After setting the variable and starting, terminal shows Restarting Claude Code in Code Mode…

Then an interactive confirmation page appears. Press the down arrow to move the cursor to "Yes, turn on Code Mode" and press Enter.

Code Mode (experimental) confirmation page with options No, start without it and Yes, turn on Code Mode

After entering the interactive interface, the top shows "Code Mode (experimental) is on", indicating the feature is active.

Top line shows Code Mode (experimental) is on, input box empty

How I tested

The test project used is the open-source repository javascript-todo-list-tutorial from dwyl, which comes with 137 unit tests and no database dependency. I originally planned to use an Express + Postgres project, but that repo was 404 and could not be cloned, so I switched to this one.

git clone https://github.com/dwyl/javascript-todo-list-tutorial.git target-project
cd target-project
npm install
npm test

Running npm install produces a few deprecated warnings, which don't affect actual execution. First run npm test to confirm the baseline all passes:

Baseline: npm test shows total 137, passing 137

During testing, each round used exactly the same prompt:

提取 lib/todo-app.js 里硬编码的配置到新建的 lib/config.js,保证测试还是过的。做完跑一遍 npm test

After the task completes, run /cost to read cost and token data, then /exit to end the session. Before the next round, restore the workspace code with:

git checkout . ; git clean -fd

Pitfalls encountered during testing

After sending the prompt with Code Mode on, the terminal looks like this:

Code Mode top line shows is on, prompt sent, Claude executing

In the very first round, the test failed: the workspace wasn't fully cleaned, Claude detected the config had already been extracted, only checked the changes and ran tests, finishing in about ten seconds. The time anomaly was obvious, so that data was discarded.

Then I exited the session, ran git checkout . ; git clean -fd ; git status, confirmed the terminal output nothing to commit, working tree clean, and restarted. Every round must verify this status before starting.

Another detail: sessions created via Code Mode must be resumed with the same environment variable; if not, the command is rejected, and you need to re-declare the variable and re-enter.

Comparison of three rounds

The first round re-run with Code Mode cost about 3 cents less than normal mode:

Code Mode first round complete, $0.1480 is the cost for this round

Compare with normal mode second round execution:

Normal mode second round complete, reply says all 137 tests pass, coverage 100%

In Code Mode's second round, cost barely decreased: $0.1763 vs normal mode's $0.1794:

Code Mode second round /cost, Estimated cost $0.1763

In the third round, the drop reappeared:

Code Mode third round /cost, Estimated cost $0.1516

Round 3's total wall time shows 5m9s, but actual API processing time was only 20s.

Final data summary

Looking at details, Code Mode's second round read 265k context, nearly equal to normal mode's 264k, so costs didn't diverge.

Across three rounds, Code Mode was cheaper each time, but round 2 only marginally, speed didn't change noticeably, and the sample is only three rounds. Following 36Kr's methodology, the 70%+ savings apply to tasks that repeatedly call tools, like checking dozens of files or calling external tools. My task wasn't complex enough. If you have that kind of workload, follow the steps above, and remember to clean the code before each round.


👋 I'm Meng Jian, former Tencent T11, former ByteDance tech leader, now full-time AI programming.

🔥 More AI programming practice:

Found this useful? Like + Bookmark is the biggest support 🙏

This article was compiled with AI assistance and reviewed by the author after testing.