Code Mode in Claude Code: What It Does and How to Try It

Code Mode lets Claude write a short JavaScript program that runs many steps at once. What it changes, who can use it, how to turn it on, and its limits.

claude codecode modeexperimentaljavascripttool calls
↻ Updated 2026-11-18EAEvgenii ArsentevEvgenii Arsentev · PhD

Reviewed for accuracy by Evgenii Arsentev, PhD · 2026-11-18

Claude Code’s Code Mode is a beta feature that allows you to send a single request to Claude Code to execute multiple actions at once. Instead of requesting actions sequentially, Claude Code generates a small script written in JavaScript, which it then executes to perform the requested actions.

Note that this is currently a beta feature and may be altered or deprecated in future releases. We recommend experimenting with Code Mode, but don’t rely on it for regular use.

What does Code Mode change?

Claude Code uses tools like Bash (to execute a command), Read (to open a file) and Edit (to edit a file). Usually, when we ask Claude to do something, he’ll ask us for a tool, read some output and then decide on his next action.

When using Code Mode, we write everything in JavaScript. This allows us to execute multiple commands simultaneously, feed the output from one command into another and return just the relevant information back to Claude.

There are no performance metrics or pricing details provided in the documentation. You’ll need to determine whether there are any cost savings yourself.

What does it look like on screen?

No code is shown here. You get what you normally do (like seeing the diff for the change). If you want to see the code, just press Ctrl+O. That takes you to the transcript viewer, where all the code appears under Code (which is collapsed). Then press Ctrl+O again to return.

Here’s an example from the documentation. When asked to increase the retry limit, Claude could write some code to locate the file, modify the value, and run tests. In this case, the final line of the code returns the file location and test results to Claude.

When is Code Mode worth trying?

The documentation points to tasks with many related tool calls. It names three kinds. The first is a change that repeats across many files. The second is a search whose results need filtering before Claude reads them. The third is a set of independent commands that can run at the same time.

A one-file edit or a short question is not the place to start. The documentation names no benefit for those.

What do you need before you turn it on?

This is a fairly extensive list, but this is the big gotcha. If any of these aren’t met, then Code Mode won’t work at all.

Check before you start

  1. 1Claude Code version 2.1.323 or later. Run claude --version to check and claude update to upgrade.
  2. 2A Claude subscription or a Console account. Code Mode does not work through a gateway, Amazon Bedrock, Claude Platform on AWS, Google Cloud's Agent Platform, Microsoft Foundry, or Claude Models on Google Cloud (Anthropic managed).
  3. 3An organization that does not use the HIPAA configuration or zero data retention.
  4. 4One of these models: Claude Opus 5.5, Sonnet 5.5, Haiku 5.5, or Fable 5.2.
  5. 5An interactive claude session in a terminal. It does not work with the -p flag, the Agent SDK, the VS Code panel, the Desktop app, or cloud sessions.
  6. 6The native build of Claude Code. On Windows, Git for Windows must also be installed.
  7. 7No API key helper, no OpenTelemetry export, and no DISABLE_TELEMETRY setting. Each of these stops Code Mode from starting.

How do I turn Code Mode on and off?

This is enabled via an environment variable. Environment variables are values that programs can read when they start up. The environment variable we’re interested in is named CLAUDE_CODE_EXPERIMENTAL_CODE_MODE, and its value should be set to 1.

Try it for one session
CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude

This works on macOS, Linux, and WSL. In Windows PowerShell, first run $env:CLAUDE_CODE_EXPERIMENTAL_CODE_MODE = "1" and then run claude.

Setting the variable in your ~/.claude/settings.json file’s env section will cause Code Mode to be enabled by default for all future sessions. This variable is ignored when set within a project’s settings file. Thus, it is not possible for a repository to enable Code Mode for you.

Keep it on in your user settings
{
  "env": {
    "CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "1"
  }
}

Save this in ~/.claude/settings.json and start claude as usual.

The first time, Claude Code asks you to confirm. Select Yes, turn on Code Mode. Claude Code restarts and shows this line near the top: Code Mode (experimental) is on · this session can be resumed only with Code Mode on.

To turn it off, remove the variable from your shell and from settings.json, then start a new session. You can also set its value to 0. A 0 in either place wins over a 1 in the other.

Is Code Mode safe to use?

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

Auto mode works differently. Its classifier, the checker that decides whether an action is allowed, reviews each piece of code before it runs. It does not review each tool call. It also cannot see values that the code works out while it runs, such as a file path taken from search results.

For that reason the documentation advises keeping rules or hooks for any call you must control. It adds that Bash rules match command text, so a denied command can run in a form the rule does not match. For limits that do not depend on text, it points to sandboxing.

Administrators can block Code Mode for a whole organization by setting the same variable to 0 in managed settings. They cannot turn it on for their users from there.

What are the downsides?

There are some restrictions. See the docs here. You can only continue/resume a Code Mode session from the command line, while in Code Mode. Make sure you have the variable set to 1 when running claude --continue or claude --resume. When not in Code Mode, Claude Code will not allow you to continue/resume a session.

Foreground code execution will timeout at 10 minutes. Background code execution can last up to 2 hours, while still being able to chat with Claude. To run code in the background, begin your session in auto/bypassPermissions mode.

There are some missing features. This includes Remote Control, Claude in Chrome, using computers. You also won’t be able to migrate your session to the Desktop app or make it a background session.

Hooks may pose issues as well. A PreToolUse hook that errors/times out will prevent the tool call from happening.

Why does Code Mode not start?

Near the top of the session you may see the line Code Mode (experimental) isn't available. It means Claude Code started without the feature. The reason follows on the same line, and the /status command shows it as well.

Most reasons come from the checklist above. An old version is one. A setting that routes requests through a cloud provider or a gateway is another. A third is telemetry turned off with DISABLE_TELEMETRY. Fix the cause and start a new session. If no Code Mode line appears at all, check the version and make sure the variable is 1 and not 0.

!Experimental means it can change

The documentation says Code Mode may change or be removed in any release. Treat it as a trial. Use it on a task where a mistake costs little, and keep your usual setup for everything else. Feedback goes to Anthropic through the /feedback command.

Lab: watch Claude write its own script

0/5

If you have tasks that require lots of repeating instructions to Claude, this mode may be useful for you. It’s experimental, so there could be bugs. If you don’t need to work in the VS Code extension, the desktop app, Bedrock, or via a gateway, then this isn’t relevant to you. I recommend trying it out for a single task that requires repetition and seeing how it goes. If it doesn’t work well, switch back to regular mode.

Free course

Stop reading about AI — start building with it

The free Claude Code course: your first site, tool or game — no coding. No upsells, no cross-sells — nothing to buy here.

Start free →
EAEvgenii Arsentev

Author

Evgenii Arsentev

PhD · Founder & CEO, Dad4Kids

Reading is a good start

Want to actually build this?

Guides explain. The free course transforms — personalized, gamified, and built to get you shipping fast.

Start the free course →