Model News · As of 2026-11-25

Claude Code Code Mode Explained: What Is Confirmed, How to Turn It On, and Why It Won't Start Behind a Custom Base URL

Code Mode is an experimental, off-by-default Claude Code feature in which Claude writes a piece of JavaScript that makes several tool calls in one step, instead of calling Bash, Read or Edit one at a time. It shipped in Claude Code v2.1.323 and is turned on with the environment variable CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1. As of 2026-11-25, Anthropic's documentation says Code Mode does not work through a gateway or with ANTHROPIC_AUTH_TOKEN, so a session that points ANTHROPIC_BASE_URL at a third-party endpoint such as https://api.qcode.cc/api is expected to start with Code Mode off. That setup is not tested here; everything else in Claude Code keeps working there as usual.

QCode is an independent third-party API service and is not affiliated with Anthropic. Statements about Code Mode in this article come from Anthropic's Code Mode page on code.claude.com and the v2.1.323 release notes, read on 2026-11-25. Anything we could not confirm is marked as such.

Updated 2026-11-26

Key facts

  • Confirmed: Code Mode was added in v2.1.323. The release note reads "an experimental opt-in in which Claude writes JavaScript to call its tools".
  • Confirmed: you turn it on with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 in your shell or in ~/.claude/settings.json. Project settings files are ignored for this variable, so a cloned repository cannot switch it on for you.
  • Confirmed: supported models are Claude Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable 5.2, in an interactive terminal session on the native build.
  • Confirmed: gateways are excluded, and ANTHROPIC_AUTH_TOKEN is one of the settings that blocks start-up. Cloud providers (Bedrock, Google Cloud's Agent Platform, Microsoft Foundry) need v2.1.331 or later.
  • Not documented: Anthropic's Code Mode page gives no token or cost figures. Any savings claims you read elsewhere are estimates.

What Code Mode actually does

In a normal Claude Code session, every tool call is a round trip. Claude asks for Grep, reads the result, asks for Read, reads that, asks for Edit, and so on. Each intermediate result lands in the conversation, and the model reads it before choosing the next step.

In Code Mode, Claude writes JavaScript that strings those calls together. The code runs inside your Claude Code session through a tool named REPL. It can run commands in parallel, feed one result into the next call and return only the part Claude needs. Anthropic's documentation gives this example for "raise the 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() });

In the conversation you still see the individual tool calls, such as the edit's diff, but not the code. Press Ctrl+O to open the transcript viewer and expand a collapsed Code row to read the JavaScript.

Anthropic suggests trying it on tasks with many related tool calls: a change repeated across many files, a search whose results need filtering before Claude reads them, and several independent commands that can run at the same time.

Confirmed vs. reported

Claim Status (2026-11-25) Source
Added in v2.1.323 as an experimental opt-in Confirmed GitHub release v2.1.323
Enabled by CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 Confirmed code.claude.com Code Mode page
Off by default; may change or be removed in any release Confirmed Code Mode page
Works through an LLM gateway or custom ANTHROPIC_BASE_URL No: gateways are not supported Code Mode page, Requirements
Works on Bedrock / Agent Platform / Foundry Yes from v2.1.331, with exceptions Code Mode page, Requirements
Works with claude -p, VS Code panel, Desktop app, cloud sessions No; interactive terminal only Code Mode page
"Saves X% tokens" Not documented for Code Mode Only related Anthropic material (see below)

How to turn on Code Mode (direct Anthropic connection)

These steps apply if you sign in to Claude Code with a Claude subscription or a Console account, or use a supported cloud provider.

  1. Check your version. Run claude --version. If it is older than 2.1.323 (2.1.331 for cloud providers), run claude update. If you are on the stable channel and it doesn't reach that version, wait or switch to latest.
  2. Set the variable. For one try:
CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude

On Windows PowerShell:

$env:CLAUDE_CODE_EXPERIMENTAL_CODE_MODE = "1"
claude

For every new session, put it in your user settings file ~/.claude/settings.json:

{
  "env": {
    "CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "1"
  }
}
  1. Confirm. On the first run, select Yes, turn on Code Mode. After a restart you should see: Code Mode (experimental) is on · this session can be resumed only with Code Mode on.
  2. Give it a multi-step task, for example: "Read every Markdown file in this project and list the links that point to local files that don't exist."
  3. Read the code with Ctrl+O.

To turn it off, remove the variable or set it to 0. A 0 anywhere (shell, user settings or a --settings file) keeps Code Mode off even if 1 is set elsewhere. Administrators can block it for everyone by setting the variable to 0 in managed settings; managed settings cannot turn it on.

Requirements at a glance

Requirement Detail
Version v2.1.323+; v2.1.331+ on cloud providers
Account Claude subscription, Console account, or supported cloud provider. Not a gateway, not Claude for Government
Organization Not using the HIPAA configuration or zero data retention
Model Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.2
Surface Interactive claude in a terminal
Other Native build; Git for Windows on Windows; agent teams need v2.1.326+, mods that hook tool calls v2.1.327+, OpenTelemetry events v2.1.329+ (tracing must stay off)

Does Code Mode work with a custom ANTHROPIC_BASE_URL (QCode)?

Not at the moment. A standard QCode setup for Claude Code looks like this:

export ANTHROPIC_BASE_URL=https://api.qcode.cc/api
export ANTHROPIC_AUTH_TOKEN=cr_your_key
claude

Anthropic's Code Mode page rules this out on two counts. Gateways are excluded ("it isn't offered yet through a gateway or proxy"), and the fix it lists for the "API key helper" reason is to remove apiKeyHelper, ANTHROPIC_AUTH_TOKEN and any auth header in ANTHROPIC_CUSTOM_HEADERS. A QCode setup uses both a gateway and ANTHROPIC_AUTH_TOKEN, so it is expected to start with Code Mode off. We have not tested this with QCode; if you rely on Code Mode, try a small request first and check what the session reports. Anthropic describes the check as running inside Claude Code, so the endpoint cannot switch it on. Please don't try workarounds such as editing the client.

What this means in practice:

  • Your normal workflow is unaffected. Standard tool calling, MCP servers, subagents, hooks, plan mode, auto mode and /compact all work with a custom base URL as before.
  • Remove the variable from your QCode profile to get rid of the warning line, or set it to 0.
  • If you want to try Code Mode, run it in a separate, direct Anthropic session that you sign in to with your own Claude subscription or Console account. Keep the two setups apart, because a Code Mode session can only be resumed with Code Mode on. You cannot continue it later in a QCode session.

A simple way to keep the two apart, for zsh or bash:

# Standard Claude Code through QCode (Code Mode explicitly off)
claude-qcode() {
  ANTHROPIC_BASE_URL=https://api.qcode.cc/api \
  ANTHROPIC_AUTH_TOKEN="$QCODE_KEY" \
  CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=0 \
  claude "$@"
}

# Direct Anthropic sign-in for experimenting with Code Mode
claude-codemode() {
  env -u ANTHROPIC_BASE_URL -u ANTHROPIC_AUTH_TOKEN \
  CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 \
  claude "$@"
}

If your QCode variables live in the env block of ~/.claude/settings.json rather than in your shell, env -u won't remove them. Switch profiles with a tool such as CC Switch, or use a separate settings file instead.

Code Mode, tool calls and MCP

Code Mode does not bypass your controls. According to Anthropic's page:

  • Each tool call inside Claude's code still goes through your deny and ask permission rules and your PreToolUse hooks, under the tool's usual name, such as Bash or an MCP tool's name. You don't need new rules for MCP tools.
  • In auto mode, the classifier reviews each piece of code before it runs, not each call, and it cannot see values computed at run time. Keep explicit rules for calls you must control, for example "ask": ["Bash(git push *)"].
  • To approve every piece of code yourself, add "ask": ["REPL"]. To inspect code in a hook, match REPL and read tool_input.code. A PostToolUse hook on REPL can redact what the code returns.
  • Sandbox settings apply to the shell commands the code runs. The JavaScript itself and its file, web and MCP tool calls run outside the sandbox. For full isolation, Anthropic points to a container or VM.
  • MCP calls and shell commands started by code can keep running after you stop the code. Check /tasks and press x to stop them.
  • Subagents with an explicit tools list need REPL added (tools: Read, Bash, REPL) to use Code Mode.

For setting up MCP servers in the first place, see our MCP servers guide for coding agents.

What about tokens and cost?

Anthropic's Code Mode page makes no token or cost claims, so treat any precise figure you see as an estimate. Here is what the documented design suggests, and where related numbers come from.

  • Why it could save tokens: intermediate results such as a long rg listing or a full test log can stay inside the code. Claude only reads what the code returns. Fewer model round trips also means the growing conversation is re-sent fewer times.
  • Why it might not: the JavaScript itself is model output, and output tokens cost more than input tokens. Code that fails and gets rewritten also adds tokens. On a subscription, Code Mode usage counts toward your plan limits like any other usage.
  • Related figures, attributed: in its engineering post "Code execution with MCP" (2025-11-04), Anthropic's worked example drops from 150,000 to 2,000 tokens when tools are exposed as code. Anthropic's programmatic tool calling docs report about 24% fewer input tokens on agentic search benchmarks. Neither figure measures Claude Code's Code Mode.

Getting part of the benefit through QCode today

Several documented levers keep intermediate output out of the context window with standard tool calling:

  • Ask for a script. "Write a small Node or Python script that finds X across the repo and prints only a summary, then run it." The script runs through the normal Bash tool, and only its summary reaches the model.
  • Filter before reading. Ask Claude to search with rg -l or narrow globs first, and to read only the matching files.
  • Cap MCP output. By default Claude Code warns when an MCP result passes 10,000 tokens and cuts it at 25,000. Lower the cap with MAX_MCP_OUTPUT_TOKENS if a server returns more than you need.
  • Delegate noisy exploration to a subagent, which returns a summary to the main thread.
  • Measure it. Use /context and /cost, plus the QCode usage dashboard, before and after. See tracking Claude Code token usage.

If you build your own agents with the Anthropic SDK, the closest API-level feature is programmatic tool calling: you mark a tool with "allowed_callers": ["code_execution_20260120"] and Claude calls it from the server-side code execution container. Whether a given third-party endpoint, QCode included, passes the code execution tool through has to be tested before you rely on it.

Troubleshooting: "Code Mode (experimental) isn't available"

Reason shown What it means / what to do
isn't open to your account yet Update if you're below v2.1.323; otherwise try again later
isn't offered yet through a gateway or proxy You're on a gateway or custom base URL. Turn Code Mode off in that profile
doesn't work with an API key helper ANTHROPIC_AUTH_TOKEN / apiKeyHelper is set. Expected with QCode
only works with Opus 5.5, Sonnet 5.5 and later models Pass a supported full model name, e.g. --model claude-opus-5-5
OpenTelemetry is on / tracing is on Update to v2.1.329+ for events and metrics; turn tracing off
can't be used together with agent teams yet Update to v2.1.326+ or unset CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS
this launch's tool options Drop --restricted, add REPL to --tools, remove REPL from deny rules

FAQ

What is Code Mode in Claude Code?

It is an experimental option in which Claude writes JavaScript that calls several tools in one step, runs it in your session through the REPL tool, and reads only what the code returns. It is off by default and may change or be removed in any release.

Which version added Code Mode?

Claude Code v2.1.323. Cloud providers such as Amazon Bedrock need v2.1.331 or later.

How do I enable Code Mode?

Set CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 in your shell or in the env block of ~/.claude/settings.json, start claude, and choose "Yes, turn on Code Mode". Project settings files can't enable it.

Does Code Mode work with QCode or another custom ANTHROPIC_BASE_URL?

Anthropic's documentation excludes gateways and lists ANTHROPIC_AUTH_TOKEN as a blocker, so a QCode setup is expected to start without Code Mode. We have not tested it with QCode; if you rely on Code Mode, try a small request first. Standard tool calling, MCP, subagents and hooks keep working normally.

Does Code Mode reduce token usage?

Anthropic hasn't published figures for Code Mode. The design can keep intermediate results out of the context, but the generated code is output tokens. Measure with /context and /cost on your own tasks.

Are my permission rules still enforced in Code Mode?

Yes. Each tool call in the code still goes through deny/ask rules and PreToolUse hooks under its normal name. In auto mode the classifier reviews the code as a whole, so keep explicit rules for sensitive commands.

Can I resume a Code Mode session without Code Mode?

No. Claude Code refuses to resume a Code Mode session with Code Mode off, so a session started on a direct Anthropic sign-in can't be continued in a QCode profile.

Keep the everyday workflow on a fixed daily budget

Code Mode is an experiment. Most of a Claude Code day is still standard tool calling, MCP and subagents, and all of that runs through a custom base URL. For daily use, QCode's Daily-35 plan gives $35 of usage per day for 30 days (see $53.57 on /pricing), billed at official price ×1.0 for Claude and GPT models with one key. For occasional use, pay-as-you-go packs start at $4.

Keep the everyday workflow on a fixed daily budget

One key for both the Anthropic Messages API and OpenAI-compatible APIs. Claude and GPT are billed at the official price ×1.0; live rates are on /models.

Not sure where to start?

Try it for a week

Small Pack: $4 for $30 of quota, valid 7 days

Use it every day

Starter: $9.00/month with $5 of quota every day — just $0.060 per $1 of quota, vs about $0.113 for the Medium Pack