Enable Code Mode in Claude Code and cut token usage on multi-file tasks
One experimental setting makes Claude call tools in batches via JavaScript - fewer turns, fewer input tokens, same result
- 1.Check your Claude Code version. Open a terminal and run `claude --version`. If the version is older than 2.1.323, update with `claude update`. If you are on the stable channel and the update isn't arriving, switch to latest or wait.
Code Mode is available starting with version 2.1.323. On cloud providers (Amazon Bedrock, Google Cloud) you need version 2.1.331 or newer.
Claude Code ↗About this tool - 2.Launch Claude Code with Code Mode enabled. On macOS/Linux/WSL run the command below in your terminal. On Windows PowerShell set the variable via `$env:CLAUDE_CODE_EXPERIMENTAL_CODE_MODE = '1'` and then run `claude`.
Code Mode only works in an interactive terminal session - not in the VS Code panel, not in the Desktop app, and not with the `-p` flag.
Terminal ↗PromptCLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude
What this prompt doesCommand for macOS/Linux/WSL: launches Claude Code with Code Mode enabled in the current session. Nothing to replace. - 3.Confirm Code Mode is on. On first launch Claude Code will ask whether you want to enable Code Mode. Choose 'Yes, turn on Code Mode'. A line will appear at the top of the session: «Code Mode (experimental) is on · this session can be resumed only with Code Mode on».
If the line is missing, Code Mode did not start. Check that the environment variable is set and your Claude Code version is recent enough.
Claude Code ↗About this tool - 4.Give Claude a task that touches many files. For example - find all broken local links in the project's Markdown files. Code Mode pays off most on tasks with many chained tool calls: edits across dozens of files, filtered searches, parallel independent commands.
In the dialogue you will see the usual tool calls (edit diffs, command output), not the JavaScript code itself. To read the code, press Ctrl+O and expand the Code line in the transcript viewer.
Claude Code ↗About this toolPromptRead every Markdown file in this project and list the links that point to local files that don't exist.
What this prompt doesAn English prompt: 'Read every Markdown file in the project and list the links pointing to local files that don't exist'. Works for any project with .md files. You can swap in your own multi-file task, for example: 'Find and fix all TODO comments in src/ directory'. - 5.To enable Code Mode for all new sessions, add the variable to your `~/.claude/settings.json` file. Create or open the file and paste the env block. After that, a plain `claude` launch will turn on Code Mode automatically.
Claude Code ignores this variable in project settings files (.claude/settings.json in the repository), so a cloned repository cannot enable Code Mode for you - only your personal settings can.
Claude Code ↗About this toolPrompt{ 'env': { 'CLAUDE_CODE_EXPERIMENTAL_CODE_MODE': '1' } }What this prompt doesContents of the ~/.claude/settings.json file. Nothing to replace - just paste it into your settings file.
- subscriptionClaude Code (Code Mode)Code Mode is available on any Claude subscription (Pro, Max, Ultra, Team, Enterprise), as well as through a Console API account. Requires Claude Code v2.1.323+ and the Opus 5.5, Sonnet 5.5, Haiku 5.5, or Fable 5.2 model.
Why today
AI services change fast - interfaces and free limits may differ from what's described.