Claude Code v2.1.323 added an experimental feature called Code Mode. When it's on, Claude writes JavaScript and runs its tools (reading files, running commands) from inside that code. The docs explain the mechanism, but I couldn't picture what would actually change in day-to-day work.
So I gave the same job to normal Claude Code and to Code Mode on my Windows PC: fix a server path in 30 PowerShell scripts, then count errors in 60 days of logs. Both got every number right. Code Mode needed 6 round trips to the model instead of 9 and wrote about 40% fewer output tokens, but it took 74 seconds instead of 66. My take: it's worth turning on for a session where Claude has to read a lot of files and you care about usage limits. I'd leave it off the rest of the time, because it switches off Claude in Chrome and computer use.

What Code Mode is
Normally, Claude Code calls one tool at a time (read this file, run this command), reads the result, then decides the next step. In Code Mode, Claude writes a piece of JavaScript that makes the tool calls, and Claude Code runs it in your session. To check 30 files, Claude doesn't read them one by one. It writes code that reads all 30, counts what it needs, and hands back only the counts.
The official docs list three jobs it fits well:
- A change that repeats across many files
- A search whose results need filtering before Claude reads them
- Several independent commands that can run at the same time
| Normal | Code Mode | |
|---|---|---|
| How tools are called | One call at a time, result read every time | Many calls from one script |
| What Claude reads back | The raw tool output | Values already counted by the code |
| Shell for commands (Windows) | Usually the PowerShell tool | The script's $ helper, which runs bash |
| Default | On | Off. You opt in with an environment variable |
It's marked experimental, and the docs say it may change or be removed in any release.
How to turn it on
Set the environment variable CLAUDE_CODE_EXPERIMENTAL_CODE_MODE to 1 before starting claude. In PowerShell, these two lines turn it on for that window only:
$env:CLAUDE_CODE_EXPERIMENTAL_CODE_MODE = "1" claude
To keep it on, put it in the env block of your user settings file, ~/.claude/settings.json (on Windows, C:\Users\<you>\.claude\settings.json). A project's settings file can't turn it on, so a repository you clone can't switch it on for you.
{
"env": {
"CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "1"
}
}
To turn it off, remove the setting or set it to 0. A 0 anywhere wins over a 1 somewhere else.
$env:CLAUDE_CODE_EXPERIMENTAL_CODE_MODE = "0"
The first time, Claude Code asks you to confirm. Pick Yes, turn on Code Mode and it restarts in Code Mode.

Two lines on that screen are worth reading twice. A session started in Code Mode can only be resumed with Code Mode on. In auto mode, the safety check reads each piece of JavaScript once before it runs, not every tool call the code makes.
Where you can't use it
Here are the requirements and limits from the docs, as of November 29, 2026:
| Situation | What happens |
|---|---|
| VS Code extension, Desktop app, cloud sessions | Not supported. Only an interactive claude session in a terminal works |
| Claude in Chrome, computer use, Remote Control | Turned off while Code Mode is on |
| Models | Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.2 |
| Windows | Needs Git for Windows plus the native install |
| Bedrock, other cloud providers | Supported from v2.1.331. Not through a gateway |
| Organization settings | Not available with HIPAA setups, nor with zero data retention. Admins can block it with 0 in managed settings |
| Long-running code | Stops after 10 minutes (up to 2 hours in the background) |
| Resuming/moving a session | Resume only with Code Mode on. Can't be moved to the Desktop app. Can't become a background session either |
Remote Control is the one that got me. I usually drive Claude Code on my PC through Remote Control from the Claude app, and Code Mode can't run in that session. For this test, I opened a separate interactive claude in a terminal on the PC.
Same job, normal vs Code Mode
I set up two everyday admin tasks: updating a server path after a file server migration, and counting errors in application logs.
- scripts folder: 30 PowerShell backup scripts with 95 copies of the old path
\\fs-old01\share\. 12 of them are written in caps as\\FS-OLD01\Share\, and 20 are inside comment lines. - logs folder: one log file per day for 60 days (21,257 lines), with 1,257 ERROR lines tagged E1001 to E1012.
I counted the right answers separately beforehand. Both runs got the same prompt. I wrote it in Japanese, and this is the English version:
In the scripts folder here, change every old file server path \\fs-old01\share\ in the PowerShell scripts to \\fs-new01\share\. Include different casing (such as \\FS-OLD01\Share\) and paths inside comment lines. When you're done, tell me how many files and how many places you changed. Then count the ERROR lines in the logs folder by error code, and show them in a table from most to least.
I started both runs like this so they wouldn't stop on permission prompts. That's fine for a throwaway test folder, but I wouldn't use these flags on a folder that matters.
claude "<prompt>" --permission-mode acceptEdits --allowedTools Bash Read Edit Grep Glob PowerShell
Setup: Windows 11, Claude Code v2.1.330, Opus 5.5, signed in with a Max plan.
Results
| Item | Normal | Code Mode |
|---|---|---|
| Prompt to final answer | 66 s | 74 s |
| Round trips to the model | 9 | 6 |
| Tools Claude called directly | PowerShell ×8 | JavaScript runs ×5 |
| Tools called from inside the code | None | File reads ×61, bash ×9 |
| Output tokens | 4,979 | 2,898 |
| Cache reads | 522,507 | 173,358 |
| Cache writes | 26,663 | 40,416 |
| Path changes | 30 files, 95 places (0 left) | 30 files, 95 places (0 left) |
| Error counts | All 12 codes correct | All 12 codes correct |
Accuracy was identical. Both caught the uppercase paths and the ones in comments, and both kept the original encoding and line endings. Both also copied the scripts folder as a backup before editing, even though I hadn't asked.



The difference was in tokens, not time
What surprised me was that normal mode didn't edit the files one by one either. Claude wrote its own PowerShell loop to replace the path in all 30 scripts in a single call. Since normal mode wasn't making dozens of tool calls in the first place, there was no time to save.
The gap showed up in how much Claude had to read. In Code Mode, the step that reads the 30 scripts and counts the old paths looked like this (part of what Claude wrote):
const re = /\\\\fs-old01\\share\\/gi;
const files = (await $`ls scripts`.text()).trim().split('\n').map(f=>'scripts/'+f);
const loose = /fs-old01/gi;
const info = [];
for (const f of files) {
const t = await file(f).text();
const m = t.match(re)||[]; const l = t.match(loose)||[];
if (l.length) info.push({f, strict:m.length, loose:l.length, lines: t.split('\n').filter(x=>/fs-old01/i.test(x))});
}
The file contents stay inside the code, and Claude only gets back a list of which files have how many matches. Every round trip rereads the whole conversation, so going from 9 trips to 6 cut cache reads to about a third. Cache writes went up, likely from the extra Code Mode instructions. If you keep bumping into your plan's usage limits, that's where Code Mode can help.
What I noticed on Windows
1. Commands in the script run in bash, not PowerShell
Normal mode used PowerShell commands. Code Mode used bash tools like grep, perl and file. On Windows, the script's $ helper appears to run through Git for Windows' bash, which is probably why Git for Windows is required.
That caused one failure. Claude tried to add up the ERROR counts with bc, which Git for Windows doesn't include, and got Exit code 127 (command not found). It switched to another method on the next step, and the result wasn't affected.

2. It doesn't use the Edit tool
Code Mode skipped Claude Code's Edit tool and changed all 30 files at once with perl -pi. Here's that part of the script:
await $`cp -r scripts scripts_backup_20261129`; await $`perl -pi -e 's/\\\\\\\\fs-old01\\\\share\\\\/\\\\\\\\fs-new01\\\\share\\\\/gi' scripts/*.ps1`;
With the Edit tool you see a diff on screen. A shell command doesn't show one, and since I had allowed bash, nothing asked me first. As the confirmation screen says, even auto mode only checks the script once. If you let Code Mode edit files, do it in a folder under git or one you've backed up.
3. It restarts once and isn't faster
After you confirm, it shows Restarting Claude Code in Code Mode… and starts again. The job itself took 8 seconds longer this time. I see Code Mode as a way to cut what Claude reads, not a speed boost. With many more files, the gap in round trips should get wider.
Summary
Code Mode lets Claude call its tools from JavaScript, and you turn it on with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1. On the same job, accuracy was the same, tokens went down, and time didn't improve. It only works in a terminal, it turns off Chrome, computer use and Remote Control, and on Windows its commands run in bash. I'd turn it on in one window on days when Claude has to churn through lots of files.


Comments