跪拜 Guibai
← All articles
Claude · AI Programming

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

By 孟健AI编程 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Cost savings from context compression in AI coding tools depend heavily on task complexity: simple edits barely benefit, while tool-heavy workflows can see major reductions. For developers paying per token, this experiment provides a realistic benchmark instead of the marketing 77% figure.

Summary

Anthropic's Code Mode for Claude Code, launched in v2.1.323, changes how Claude executes by having it first write a JavaScript script to chain multiple operations, compressing context and reducing token usage. A 36Kr report claimed it can cut costs by up to 77%. A developer who tracks token spending closely ran the same task three times with Code Mode on and off, using a 137-unit-test repository.

Averaged over three rounds, Code Mode cost $0.1586 per run versus $0.1816 for normal mode, a 13% reduction. Token reads (cache read) dropped by over 30% on average, but total cost only fell 13% because cache writes, which have a much higher unit price, made up a constant chunk of each run. Task completion times were essentially unchanged, ranging from 23 to 32 seconds in both modes.

The 77% figure applies to scenarios with heavy external tool calls, such as reading dozens of files or invoking external APIs repeatedly. This test's simple task of extracting config and re-running tests does not hit that profile, so the smaller savings are expected. The author also notes practical constraints: Code Mode only works in the terminal, not in VS Code plugin or desktop app; it requires an environment variable; and resuming a session demands the same variable.

Takeaways
— Averaged over three rounds, Code Mode cost $0.1586 per run vs $0.1816 for normal mode, a 13% saving on a simple refactor-and-test task.
— Token reads (cache read) dropped by over 30% on average, but costs only fell 13% because cache writes at a higher unit price stayed roughly constant.
— The 77% savings figure from 36Kr applies to tasks with heavy external tool calls, not simple single-file edits.
— Task completion times were similar: normal mode 26-28s, Code Mode 23-32s, with no consistent speed advantage.
— Code Mode requires setting the environment variable CLAUDE_CODE_EXPERIMENTAL_CODE_MODE='1' before launching claude, and the session must be resumed with the same variable.
— The feature only works in the terminal CLI; VS Code plugin, desktop app, and gateway/relay setups do not support it.
— The test had only three rounds, and round 2 showed almost no cost difference (26.5k vs 26.4k context read), indicating variance between runs.
Conclusions

The wide gap between token savings and cost savings shows that cache writes neutralize much of the benefit, so users paying per token need to watch both metrics, not just the headline percentage.

The 77% figure is real but conditional: it only appears in tool-heavy loops where context compression has a large impact. Simple tasks like this test won't see that level of savings, so cost expectations should be set by workload type.

A single 13% savings across three runs could still be noise; the second round showed nearly identical costs, suggesting variability is high enough that a longer test is needed to confirm the average.

Enabling Code Mode requires a manual environment variable and confirmation step, a friction that may deter casual users but is reasonable for an experimental feature.

Concepts & terms
Code Mode
An experimental Claude Code feature that makes Claude write a JavaScript script to chain multiple operations, compressing context and reducing token usage compared to normal turn-by-turn execution.
cache read
The number of context tokens read from cache (previously seen content) during a request. Lower cache read means less context reprocessing, which is a main driver of cost savings in Code Mode.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗