Claude Code Code Mode: How to Turn It On and What It Changes

TL;DR
Claude Code Code Mode lets Claude write JavaScript that makes several tool calls in one step. Turn it on with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 on v2.1.323+.
Last updated: November 19, 2026 - Claude Code v2.1.329 (November 19) lets Code Mode start with OpenTelemetry events and metrics on (tracing still blocks it) and with telemetry, nonessential traffic or feature flags off, and reverses the rule that a failing PreToolUse hook refuses a script's tool call. Checked against the v2.1.328 and v2.1.329 binaries. Earlier: November 16, 2026 - Claude Code v2.1.326 (November 16) lets Code Mode run with agent teams on, tightens Code Mode's permission checks, and makes its $ shell helper refuse some values. Requirements and troubleshooting below are updated, checked against the v2.1.326 binary.
Code Mode is an experimental Claude Code feature, added in v2.1.323, in which Claude writes JavaScript that makes several tool calls in one step instead of asking for each Bash, Read or Edit call and reading every result. To try it, start Claude Code v2.1.323 or later with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 and confirm the prompt. It is off by default, only works in an interactive terminal session on the Anthropic API, and the docs warn that it "may change or be removed in any release."
Everything below is from the Code Mode docs and the v2.1.323 changelog, read on November 13, 2026, plus one check against the v2.1.325 binary. Code Mode needs an interactive terminal, so I did not run a Code Mode session; I checked what the binary does when you ask for it in -p.
What changes#
Without Code Mode, Claude requests one tool call, reads the result, and decides the next step. With it, Claude writes a piece of JavaScript that makes the calls, and Claude Code runs it in your session. The docs' example for "raise a retry limit":
const files = await $`rg -l "function retryPolicy" src`.text();
const target = files.trim().split("\n")[0];
await edit(target, "maxAttempts: 3", "maxAttempts: 5");
({ edited: target, tests: $`npm test -- retryPolicy`.nothrow() });
One piece of code can run commands in parallel, feed one result into the next call, and return only the part of the output Claude needs to read. In the conversation you still see the tool calls, such as the edit's diff, not the code. Press Ctrl+O to open the transcript viewer, where each piece of code is a collapsed Code row.
The docs suggest it for "tasks that take many related tool calls": a change that repeats across many files, a search whose results need filtering before Claude reads them, and several independent commands that can run at once.
%% title: One tool call per step versus Code Mode
flowchart LR
subgraph Default[Without Code Mode]
A1[Claude asks for Bash] --> A2[Reads result] --> A3[Asks for Edit] --> A4[Reads result] --> A5[Asks for Bash]
end
subgraph CM[With Code Mode]
B1[Claude writes JavaScript] --> B2[REPL tool runs it: rg, edit, npm test] --> B3[Returns only what Claude needs]
endRequirements#
Code Mode has a long list of conditions. Per the docs:
- Version: Claude Code v2.1.323 or later, on either release channel.
- Account: a Claude subscription or Console account. Not through a gateway, Amazon Bedrock, Claude Platform on AWS, Google Cloud's Agent Platform or Microsoft Foundry.
- Organization: not using the HIPAA configuration or zero data retention.
- Model: Claude Opus 5.5, Sonnet 5.5, Haiku 5.5 or Fable 5.2.
- Surface: an interactive
claudesession in a terminal. It "doesn't work with-p, the Agent SDK, the VS Code panel, the Desktop app, or cloud sessions." - Agent teams: v2.1.326 or later if agent teams are on. Per the docs, teammates "run in Code Mode in the default in-process display mode, and start without it in split panes".
- Installation: the native build. On Windows, Git for Windows.
It also won't start with an API key helper or with OpenTelemetry tracing on. Since v2.1.329 that is narrower than it was: the changelog says Code Mode now starts "while OpenTelemetry events and metrics are enabled; each tool call the code makes sends its events; tracing still keeps it off", and "also start[s] when telemetry, nonessential traffic or feature flags are turned off". The binaries agree. In v2.1.328 the refusal reads "OpenTelemetry is on (CLAUDE_CODE_ENABLE_TELEMETRY or ENABLE_BETA_TRACING_DETAILED ...)", and the reason it needs settings that Claude Code downloads from Anthropic exists. In v2.1.329 it reads "OpenTelemetry tracing is on (CLAUDE_CODE_ENHANCED_TELEMETRY_BETA, ENABLE_ENHANCED_TELEMETRY_BETA or ENABLE_BETA_TRACING_DETAILED ...)", and the feature-flag reason is gone. The Code Mode docs still described the old rules when I checked on November 19. Agent teams were on that list until v2.1.326, whose changelog says: "Added support for turning on Code Mode while agent teams are enabled; if you already turned it on, sessions with teams on now start in Code Mode". I checked the binaries: v2.1.325 contains the reason it can't be used together with agent teams yet and v2.1.326 no longer does. Its reason for unattended sessions now reads "for now it doesn't work in background jobs, in teammates' panes or with Remote Control".
I checked the -p rule on the v2.1.325 binary: CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude -p "say ok" printed "Warning: Code Mode (experimental) isn't available: for now it only works in the interactive terminal. Starting with the ordinary tools." and then answered normally. So scripts and CI that pick up the variable keep working, without Code Mode.
How to turn it on#
-
Run
claude --versionand update if it is older than v2.1.323. On thestablechannel you may need to wait or switch tolatest. -
Start with the variable set:
TerminalCLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claudeOr, to turn it on for every new session, put it in
~/.claude/settings.json:JSON{ "env": { "CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "1" } }Claude Code ignores this variable in a project's settings files, "so a repository you clone can't turn on Code Mode for you."
-
Select Yes, turn on Code Mode at the confirmation. Claude Code restarts and shows
Code Mode (experimental) is on · this session can be resumed only with Code Mode on. -
Give it a task with many tool calls, then press
Ctrl+Oto read the code.
Two things to remember. A Code Mode session can only be resumed in the terminal with the variable still set to 1; "With Code Mode off, Claude Code refuses to resume the session." And to turn it off, remove the variable or set it to 0: "With a 0 in one place, Code Mode stays off even if you set 1 in the other."
For administrators: set "CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "0" in the env block of managed settings to block it. Users already in a Code Mode session stay in it until they exit or restart, and then cannot resume those sessions. You cannot turn Code Mode on for users from managed settings.
Permissions: what to check before you try it#
This is the section to read twice. Each tool call Claude's code makes still goes through your deny and ask rules and your PreToolUse hooks, so existing rules for Bash keep working. What changes is review:
- In auto mode, "the classifier reviews each piece of code before it runs, not each tool call. It doesn't see values computed at run time, such as a path taken from search output, so keep rules or hooks for calls you must control." If you rely on auto mode as your main guardrail, that is a real change in what gets checked.
- In other permission modes, the code starts without a review, and you are prompted for each tool call that would prompt you in that mode.
- To inspect the code itself, write a
PreToolUsehook that matchesREPL, the tool that runs Claude's code, and read the JavaScript fromtool_input.code. Our hooks guide covers the hook basics. - Hook failures no longer refuse calls (v2.1.329). Until v2.1.328, a
PreToolUsehook that failed or timed out on a call from Claude's code refused that call "even whenonFailureis unset". v2.1.329 reverses this: a hook "that errors no longer refuses a script's tool call, as outside Code Mode; set"onFailure": "block"on a command, HTTP or MCP tool hook that must refuse." If a guard hook was relying on the old behavior to fail closed, add"onFailure": "block"before you update. - Stricter checks since v2.1.326. The changelog lists "Improved permission checks in Code Mode; more sandboxed commands now ask or are refused" and "Changed Code Mode's
$shell helper to refuse some values with an error; nothing runs". Neither entry says which values, so if code that ran on v2.1.325 now stops with an error from$, that is the likely cause rather than a bug in your rules.
The docs repeat a general warning that applies with or without Code Mode: Bash rules match command text, so a denied command can run in a form the rule does not match. Use sandboxing for limits that do not depend on text. If unattended sessions are the concern, permissions.denyInsteadOfPrompting is the other recent setting to know.
Long-running code and limits#
- Waiting: by default Claude waits for the code to finish, and the code "stops after ten minutes, including time you spend at permission prompts."
- Background: started in auto or
bypassPermissionsmode, code can keep running for up to two hours while you keep talking to Claude. - Countdown prompts: in auto mode, if Claude starts new code while earlier code still runs, the earlier code loses its classifier review, and you get a prompt with a countdown such as "Claude Code will automatically block this request in 1:59". Miss it and the call is refused.
- Not available in Code Mode: Remote Control, Claude in Chrome and computer use. You also cannot move the session to the Desktop app, turn it into a background session, or start a background copy with
/fork.
Troubleshooting the start line#
If the session starts with Code Mode (experimental) isn't available, the reason follows on the same line and in /status. The common ones from the docs' table:
| Reason includes | Fix |
|---|---|
it only works with the Anthropic API | Remove settings that route through a cloud provider, gateway or custom ANTHROPIC_BASE_URL |
it doesn't work with an API key helper | Remove apiKeyHelper, ANTHROPIC_AUTH_TOKEN and auth headers in ANTHROPIC_CUSTOM_HEADERS |
it only works with Opus 5.5, Sonnet 5.5 and later models | Start with a supported model, for example --model opus |
OpenTelemetry tracing is on (v2.1.329+) | Unset CLAUDE_CODE_ENHANCED_TELEMETRY_BETA, ENABLE_ENHANCED_TELEMETRY_BETA and ENABLE_BETA_TRACING_DETAILED; events and metrics can stay on |
OpenTelemetry is on (v2.1.328 and earlier) | Update to v2.1.329, or unset CLAUDE_CODE_ENABLE_TELEMETRY and ENABLE_BETA_TRACING_DETAILED |
it can't be used together with agent teams yet | Update to v2.1.326 or later to keep agent teams on, or unset CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS |
it doesn't work in background jobs, in teammates' panes or with Remote Control | Start in the foreground without --remote-control; for teammates, use the in-process display mode instead of split panes |
your organization's settings don't allow it | Ask your administrator about the managed setting |
Should you turn it on?#
For repetitive multi-file edits and searches that need filtering, Code Mode is worth an afternoon on a project you know well, which is what the docs suggest. Keep it off for now if you depend on Remote Control, teammates in split panes, OpenTelemetry tracing, a gateway or a cloud provider, or if your safety model relies on the auto mode classifier seeing each individual call. It is experimental and the docs say so plainly.
FAQ#
How do I turn on Code Mode in Claude Code?#
On Claude Code v2.1.323 or later, start claude with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 in your shell, or put it in the env block of ~/.claude/settings.json, then confirm with "Yes, turn on Code Mode". Project settings files cannot turn it on.
Does Code Mode work with claude -p or the Agent SDK?#
No. Code Mode only works in an interactive claude session in a terminal. In claude -p, v2.1.325 prints a warning that Code Mode is not available and starts with the ordinary tools.
Can I use Code Mode on Bedrock, Vertex or through a gateway?#
No. It needs a Claude subscription or Console account on the Anthropic API, and one of Opus 5.5, Sonnet 5.5, Haiku 5.5 or Fable 5.2. It does not work through a gateway, Amazon Bedrock, Claude Platform on AWS, Google Cloud or Microsoft Foundry.
How do permissions work in Code Mode?#
Each tool call the code makes still goes through your deny and ask rules and your PreToolUse hooks. In auto mode the classifier reviews each piece of code before it runs, not each tool call, so it does not see values computed at run time.
How do I block Code Mode for my organization?#
Set CLAUDE_CODE_EXPERIMENTAL_CODE_MODE to "0" in the env block of your managed settings. Users already in a Code Mode session keep it until they exit or restart, and cannot resume Code Mode sessions afterwards.
Sources#
- Run tool calls from code with Code Mode - Claude Code Docs
- Claude Code CHANGELOG, v2.1.323 - "Added Code Mode, an experimental opt-in"
- Claude Code permission modes
- Claude Code hooks reference
Continue Reading#
- Claude Code Just Got Code Mode: Save a Ton of Tokens - the Short, with a real run: 11 tool calls in one 6 second step
- Claude Code Auto Mode Explained - the classifier that now reviews code instead of calls
- Claude Code Hooks Explained - write the
PreToolUsehook that readstool_input.code - Claude Code denyInsteadOfPrompting - the other recent permissions setting for unattended work
- Claude Code Mods - the built-in easel chart mod whose chart tool 2.1.330 fixed in Code Mode, and how to turn it off
- Claude Code tool page - what the CLI does, pricing and setup links
- Claude Code /loop Now Runs 30 Days, Not 7 - 2.1.330, which also fixes Code Mode's chart tool and a long pause on large reads
- Claude Code Mastery course - install, core workflows and CLAUDE.md, start to finish
Get the next deep dive like this in your inbox
One email a week on Claude Code and the rest of the AI dev stack. Free.
Read next on Claude Code
Claude Code Auto Mode Explained: Permissions Without Prompts
Claude Code auto mode swaps permission prompts for a background safety classifier. How the Shift+Tab cycle, hard_deny rules and glob deny patterns fit together.
8 min readClaude Code Hooks Explained
Claude Code hooks run shell commands at exact lifecycle points. Set up auto-format, dangerous-command blocking, tests before stopping and desktop notifications.
12 min readClaude Code denyInsteadOfPrompting: Deny Permission Prompts Everywhere
Claude Code 2.1.319 adds permissions.denyInsteadOfPrompting: any call that would wait on a permission prompt is denied and the turn carries on, subagents included.
6 min read




