I asked Claude Code the same "find every saved key" question four times. With Code Mode off, it read about 530,000 tokens on average. With it on, about 240,000.
TL;DR
- Code Mode is an experimental Claude Code feature. Instead of calling tools one at a time, the model writes a small JavaScript program that calls them in a batch. One environment variable turns it on.
- On an iOS project with about 850 Swift files, a "find every saved key" task read about 530k tokens on average with Code Mode off, and about 240k with it on. Less than half.
- The gap only shows up on search-heavy tasks. For a one-line edit, both finished in seconds and I couldn't feel any difference.
Watching the tool calls scroll by
Ask Claude Code "where does this app use X?" and you get a long scroll of tool calls. Grep, Bash, Read, Grep again. I used to watch that and think: wow, very polite, one at a time.
Code Mode is the experimental feature that stops the one-at-a-time part. The 2.1.332 release on November 25 had a pile of related fixes, so it's clearly still being worked on.
I wanted to know if it really makes things lighter. So I ran the same task twice with it off and twice with it on.
What Code Mode actually changes
Normally, Claude Code calls one tool, gets the result, reads it, and decides the next step. And every time, it rereads the whole conversation so far, including every tool result. More round trips means the amount it reads grows like a snowball.
With Code Mode on, the model writes a short JavaScript program instead. Something like: grep this folder, read every file that matched, pull out only the key names. The intermediate results stay inside the code. Only the final summary comes back into the conversation.
It's the difference between calling the grocer, the butcher, and the fishmonger one by one and listening to each report, versus handing someone a shopping list and saying "go to all three, tell me what you got."
Turning it on
Start Claude Code with one environment variable:
CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude
My first attempt was from the desktop app I normally use. It stopped me with a message saying Code Mode only works in the terminal, with claude -p, and in Agent SDK apps for now. So, terminal it is.
The setup
- Project: a copy of one of my iOS side projects, about 850 Swift files
- Task: "Find every key saved with UserDefaults and AppStorage. List the key name, the type, and the files that use it."
- Model: Sonnet 5.5, same for both
- Runs: off and on, alternating, two each
- Measurement: I counted round trips and tokens read from the session transcripts
Result: search got a lot lighter
- Off, run 1: 12 round trips. Grep and Bash called one at a time, 12 times. About 670k tokens
- Off, run 2: 7 round trips. It searched a bit smarter. About 380k
- On, run 1: 5 round trips, but 58 Bash and Read calls ran inside the code. About 220k
- On, run 2: 6 round trips, 13 calls inside the code. About 260k
Average: about 530k off, about 240k on. Less than half. Comparing just the first runs, it was a third. I did not expect a gap this big and checked my numbers twice.
Time was closer: 33 and 36 seconds with it on, 47 and 36 with it off. "Sometimes a bit faster" is as far as I'd go.
I also compared the answers. Both found the same keys, and both noticed the file where key names were collected. The Code Mode answer went further: it pointed out that AppStorage wasn't actually used anywhere, and that there was exactly one SceneStorage. So it didn't get lighter by skipping work.
For a one-line edit, it doesn't matter
I also tried a task where the location is known: "add a comment line above line 1 of this script."
On: about 5 seconds and 60k tokens. Off: about 8 seconds and 130k. On paper Code Mode halves it again, but both were done before I could blink. Round trips were 2 vs 3. There's nothing to batch when there's only one tool call. If you only need one shop, writing a shopping list is just extra work.
Before you turn it on
- Limited places. Terminal, claude -p, and the Agent SDK only. Not the desktop app, not cloud sessions.
- Code stops after 10 minutes. A job that crawls a huge repo might get cut off.
- The JavaScript runs outside the sandbox. I wouldn't try it first on a repo you don't know.
- Resume with it on, too. If you continue a Code Mode session with --resume, start with the same environment variable.
- It's not consistent. My two Code Mode runs made 58 and 13 calls inside the code. Same task, very different paths.
Wrap-up
- Code Mode pays off on tasks that search all over the codebase. In my test, tokens read dropped by more than half.
- For a small edit where the location is known, there's no difference you'd notice.
- It's terminal-only for now, and its code runs outside the sandbox.
So now I turn it on only for "where in this app does…" questions, in the terminal. Try it once on your biggest repo.
Start Claude Code with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude, then paste this:
Find every place in this repository that reads or writes settings or saved keys. List each key name, its type, and the files that use it.
On a small dummy project, this prompt found all six keys. It also flagged a key that gets saved but never read back, and an onboarding flag that never gets set to true. I hadn't asked for either of those.
Over to you: what's the search you ask Claude Code to do most often? Tell me in the comments.
Want to cut tokens further? I let Opus decide and Sonnet do the reading, and my parent context went from 280k to 80k. 👉 Get the model-split skill ($9)
If this was useful, a ❤️ and a follow would mean a lot. I write about practical ways to put AI to work in indie development, with the numbers from what I actually tried.
Top comments (0)