◈AI Codex
Claude Codeupdate

Code Mode in Claude Code: Claude writes JavaScript that runs several tool calls in one step

In brief

Claude Code v2.1.323, released November 12, 2026, added Code Mode as an experimental opt-in. Claude writes a short piece of JavaScript that makes its tool calls, and Claude Code runs it in your session. It is off by default and works only in a terminal session on the Anthropic API. It also changes how auto mode reviews work, how your hooks get called, and which sessions you can resume. How to try it, what to check first, and how an admin blocks it.

9 min read··Claude Code

Contents

♡Sign in to save

Claude Code v2.1.323, released November 12, 2026, added Code Mode. It is experimental, off by default, and Anthropic says it may change or be removed in any release.

Code Mode changes how Claude uses its tools. A tool is an action Claude Code can take for you: run a shell command (Bash), read a file (Read), change a file (Edit).

  • Without Code Mode, Claude asks for one tool call, reads the result, then decides on the next one.
  • With Code Mode, Claude writes a short piece of JavaScript that makes several tool calls, and Claude Code runs that code in your session.

One piece of code can run commands in parallel, pass the result of one call into the next, and hand back only the part of the output Claude needs to read.

What the code looks like

Say you ask Claude to raise a retry limit. Anthropic's documentation gives this as the kind of code Claude might write:

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() });

That is a search, an edit, and a test run in one step. The last line returns the file path and the test output to Claude.

You do not see this code in the conversation. You see the tool calls, such as the diff for the edit. To read the code, press Ctrl+O to open the transcript viewer and expand a Code row.

Tasks where it helps

Anthropic suggests trying Code Mode on work that takes many related tool calls:

  • 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

A one-file bug fix will not look much different.

Turn it on

  1. Check your version. Run claude --version. If it is older than 2.1.323, run claude update.
  2. Start Claude Code with the variable set.
CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude

To turn it on for every new session, put it in ~/.claude/settings.json:

{
  "env": {
    "CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "1"
  }
}
  1. Confirm. Claude Code asks once before your first Code Mode session. Choose Yes, turn on Code Mode. It restarts and prints this line near the top:
Code Mode (experimental) is on · this session can be resumed only with Code Mode on
  1. Give it a task with many tool calls. For example: "Read every Markdown file in this project and list the links that point to local files that don't exist."

Claude Code ignores this variable in a project's settings files. A repository you clone cannot turn Code Mode on for you.

To turn it off, remove the variable or set it to 0, then start a new session. A 0 in either your shell or your user settings wins over a 1 in the other.

Where it works

Requirement What is supported
Version Claude Code 2.1.323 or later, native build
Account A Claude subscription or Console account
Not supported Gateways, Amazon Bedrock, Claude Platform on AWS, Google Cloud, Microsoft Foundry
Organization No HIPAA configuration and no zero data retention
Models Claude Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.2
Surface An interactive claude session in a terminal
Does not work in claude -p, the Agent SDK, the VS Code panel, the Desktop app, cloud sessions
Agent teams Needs 2.1.326 or later, and teammates in split panes start without Code Mode

Code Mode also refuses to start when an API key helper, OpenTelemetry export, or DISABLE_TELEMETRY is set. When it cannot start, the session prints Code Mode (experimental) isn't available followed by the reason, and /status shows the same reason.

That last point matters for companies. If you export Claude Code usage through OpenTelemetry, your developers cannot use Code Mode until they turn that export off. Most teams should keep the export.

What you give up

Read this list before you turn it on for real work.

  • Resume. A Code Mode session can only be resumed in the terminal with Code Mode still on. If you unset the variable, claude --continue and claude --resume refuse that session.
  • Moving the session. You cannot move it to the Desktop app or turn it into a background session.
  • Features that stop working. Remote Control, Claude in Chrome, and computer use are unavailable.
  • Long-running code. By default you wait for the code to finish, and it stops after ten minutes. That clock includes time you spend answering permission prompts. If you start the session in auto mode or bypassPermissions mode, code can run in the background for up to two hours while you keep talking to Claude.

What changes for permissions

Your deny and ask permission rules still apply. Each tool call inside the code goes through them under the tool's usual name, such as Bash.

The change is in auto mode, the permission mode where a classifier (a second model that screens actions) decides what is safe to run without asking you.

  • Without Code Mode, the classifier reviews each tool call.
  • With Code Mode, the classifier reviews the code before it runs, not each call.

The classifier cannot see values the code computes while running. If the code searches for a path and then deletes whatever it found, the classifier saw the code but never saw the path. Anthropic's guidance is direct: keep rules or hooks for the calls you must control.

In the other permission modes, the code starts without a review and you get a prompt for each tool call that would normally prompt you.

If you have hooks, check three things

A hook is a script Claude Code runs at a set point, such as before every tool call. Teams use PreToolUse hooks to block commands like git push to a protected branch. If you are deciding between hooks and written instructions, see CLAUDE.md vs. hooks.

1. Commands arrive in a different shape. In Code Mode, a git push in a folder named app can reach your hook as:

cd 'app' && git push

A hook that only checks whether the command starts with git push will miss it. Make the hook check each part of a compound command.

2. A hook that fails now refuses the call. On a call that comes from code, if your PreToolUse hook cannot start, crashes, or times out, the tool call is refused. Once Claude has run any code in a session, a hook timeout refuses other tool calls too. If you would prefer calls to go ahead when the hook breaks, set "onFailure": "continue" on that hook. For a hook that guards something important, leave it and raise its timeout instead.

3. You can inspect the code itself. The tool that runs the code is named REPL. A PreToolUse hook that matches REPL receives the JavaScript in tool_input.code:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "REPL",
        "hooks": [
          { "type": "command", "command": "./scripts/review-code-mode.sh" }
        ]
      }
    ]
  }
}

One more case: when code can run in the background, your UserPromptSubmit hooks also run on the code's output. If a hook blocks output you expected, change it to skip inputs where source is poll_event.

Some mods and plugins that check tool calls are not compatible yet. Code Mode names the one in the way when it fails to start.

Block it for your organization

Admins can turn Code Mode off for everyone with one entry in managed settings:

{
  "env": {
    "CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "0"
  }
}

Three things to know:

  • People already in a Code Mode session stay in it until they exit or restart.
  • After that they start without Code Mode, and they cannot resume their old Code Mode sessions while the 0 is in place.
  • You cannot turn Code Mode on for users from managed settings. Each person opts in.

If your security controls depend on PreToolUse hooks that match on command text, block Code Mode until someone has tested those hooks against compound commands. If you are still setting up those controls, start with Claude Code for operators.

Should you turn it on

Try it if you work in a terminal on the Anthropic API, your tasks involve repeated edits or broad searches, and you can live without resuming those sessions elsewhere.

Wait if you rely on Remote Control, the Desktop app, background sessions, or OpenTelemetry export, or if your team is on Bedrock, Google Cloud, or Foundry. None of those work with it today.

Test before allowing it if you run auto mode with few permission rules. The per-call review you were counting on becomes a review of code that may not contain the values that matter.

A fair test: pick one repetitive task you did last week, run it once with Code Mode and once without, and compare how long each took and how many times you were prompted. Then press Ctrl+O and read the code Claude wrote. If you cannot follow what it did, that is a reason to keep it off for now.

Sources

Related tools

Weekly brief

For people actually using Claude at work.

Each week: one thing Claude can do in your work that most people haven't figured out yet — plus the failure modes to avoid. No tutorials. No hype.

No spam. Unsubscribe anytime.

What to read next

All articles →