Anthropic Adds Code Mode to Claude Code: Claude Now Chains Tool Calls in JavaScript

0


Anthropic has added Code Mode to Claude Code as an experimental, opt-in feature. Claude Code Code Mode is a mode in which Claude writes JavaScript that makes several tool calls in 1 step. It shipped in Claude Code v2.1.323 last week. For developers, it changes how the agent spends round-trips on multi-step work. You can check the deployment options and specs here through our GPULeaderboard.com chrome extension.

TL;DR

  • Works with: It works with Claude Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable 5.2.
  • Runs on: An interactive terminal session on the native build, v2.1.323 or later. Windows needs Git for Windows. Anthropic API or Claude subscription only.
  • Performance: Anthropic publishes no benchmark or token-saving figure for Code Mode.
  • Best: Background code can run for up to 2 hours while you keep talking to Claude.
  • Worst: Code that Claude waits on stops after 10 minutes. No Bedrock, Google Cloud, Foundry, -p, Agent SDK, VS Code or Desktop.
  • Bottom line: Best: related tool calls run as 1 program. Worst: narrow availability and coarser auto-mode review.

What is Code Mode in Claude Code?

Without Code Mode, Claude requests each Bash, Read or Edit call directly. It reads every result before choosing the next step. With Code Mode, Claude writes a piece of JavaScript, and Claude Code runs it in your session.

According to the docs, one piece of code can run commands in parallel. It can feed one result into the next call. It can also return only the output Claude needs to read.

Anthropic’s example raises a retry limit. The code finds the file, edits it and runs the tests:

Copy Code

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 see the tool calls, such as the diff. You do not see the code by default. Press Ctrl+O to open the transcript viewer and expand a collapsed Code row.

<iframe id="mtp-ccm-frame" title="Claude Code Code Mode interactive explainer" srcdoc="<!DOCTYPE html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>Claude Code Code Mode: interactive explainer</title>
<style>
#mtp-ccm{–bg:#141413;–card:#1F1E1D;–line:#3A3936;–cream:#FAF9F5;–muted:#B0AEA5;–clay:#D97757;–clay2:#E8A68D;–blue:#6A9BCC;–olive:#788C5D;
max-width:880px;margin:0 auto;background:var(–bg)!important;color:var(–cream)!important;border:1px solid var(–line)!important;border-radius:16px;
font-family:Inter,system-ui,-apple-system,Segoe UI,sans-serif;padding:24px;box-sizing:border-box;line-height:1.5}
#mtp-ccm *{box-sizing:border-box}
#mtp-ccm hr,#mtp-ccm p:empty,#mtp-ccm del,#mtp-ccm s{display:none!important}
#mtp-ccm .kick{font-size:12px;letter-spacing:.12em;text-transform:uppercase;color:var(–clay)!important;font-weight:700}
#mtp-ccm h2{font-family:Georgia,'Times New Roman',serif;font-weight:500;font-size:28px;margin:6px 0 4px;color:var(–cream)!important}
#mtp-ccm .sub{color:var(–muted)!important;font-size:14px;margin:0 0 18px}
#mtp-ccm .tabs{display:flex;gap:6px;flex-wrap:wrap;border-bottom:1px solid var(–line);margin-bottom:18px}
#mtp-ccm .tab{background:transparent!important;color:var(–muted)!important;border:0!important;border-bottom:2px solid transparent!important;padding:9px 12px;font:600 14px Inter,sans-serif;cursor:pointer}
#mtp-ccm .tab.on{color:var(–cream)!important;border-bottom-color:var(–clay)!important}
#mtp-ccm .panel{display:none;animation:fade .35s ease}
#mtp-ccm .panel.on{display:block}
@keyframes fade{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
#mtp-ccm .card{background:var(–card)!important;border:1px solid var(–line)!important;border-radius:12px;padding:16px}
#mtp-ccm .grid2{display:grid;grid-template-columns:1fr 1fr;gap:14px}
#mtp-ccm .lbl{font-size:12px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(–muted)!important;margin-bottom:10px}
#mtp-ccm .lbl.c{color:var(–clay)!important}
#mtp-ccm .flow{display:flex;flex-direction:column;gap:6px;min-height:236px}
#mtp-ccm .node{border:1px solid var(–line)!important;border-radius:8px;padding:7px 10px;font-size:13px;color:var(–muted)!important;background:#262523!important;transition:all .3s}
#mtp-ccm .node.lit{border-color:var(–clay)!important;color:var(–cream)!important;background:#2E2420!important;box-shadow:0 0 0 1px var(–clay)}
#mtp-ccm .node.m{border-style:dashed!important}
#mtp-ccm .node.lit.m{border-color:var(–blue)!important;background:#1E2630!important;box-shadow:0 0 0 1px var(–blue)}
#mtp-ccm .ctr{display:flex;gap:8px;align-items:center;margin-top:14px;flex-wrap:wrap}
#mtp-ccm .btn{background:var(–clay)!important;color:#141413!important;border:0!important;border-radius:8px;padding:8px 14px;font:700 13px Inter,sans-serif;cursor:pointer}
#mtp-ccm .btn.g{background:transparent!important;color:var(–cream)!important;border:1px solid var(–line)!important}
#mtp-ccm .note{font-size:13px;color:var(–muted)!important}
#mtp-ccm pre,#mtp-ccm code{background:#0E0E0D!important;color:#F0EEE6!important;border:1px solid var(–line)!important;border-radius:8px;font-family:ui-monospace,Menlo,Consolas,monospace!important}
#mtp-ccm pre{padding:12px;font-size:12.5px;overflow-x:auto;margin:10px 0 0;white-space:pre}
#mtp-ccm code{padding:1px 5px;font-size:12px}
#mtp-ccm pre code{border:0!important;padding:0}
#mtp-ccm .k{color:var(–clay2)!important}
#mtp-ccm .pill{display:inline-block;border:1px solid var(–line);border-radius:999px;padding:5px 11px;font-size:12px;margin:0 6px 6px 0;cursor:pointer;color:var(–muted)!important;background:transparent!important}
#mtp-ccm .pill.on{border-color:var(–clay)!important;color:var(–cream)!important;background:#2E2420!important}
#mtp-ccm .steps{counter-reset:s;list-style:none;padding:0;margin:0}
#mtp-ccm .steps li{counter-increment:s;padding:8px 0 8px 36px;position:relative;font-size:14px;border-bottom:1px solid var(–line)}
#mtp-ccm .steps li:before{content:counter(s);position:absolute;left:0;top:7px;width:24px;height:24px;border-radius:50%;background:var(–clay);color:#141413;font-weight:800;font-size:12px;display:flex;align-items:center;justify-content:center}
#mtp-ccm .bar{margin:14px 0}
#mtp-ccm .bar .t{display:flex;justify-content:space-between;font-size:13px;margin-bottom:6px}
#mtp-ccm .bar .tr{height:16px;background:#262523;border-radius:8px;overflow:hidden}
#mtp-ccm .bar .f{height:100%;width:0;border-radius:8px;transition:width 1.2s cubic-bezier(.2,.8,.2,1)}
#mtp-ccm .stat{font-family:Georgia,serif;font-size:30px;color:var(–clay)!important}
#mtp-ccm .x{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}
#mtp-ccm .warn{border-left:3px solid var(–olive);padding:8px 12px;background:#1E211A!important;font-size:13px;color:#DCD9CF!important;margin-top:14px;border-radius:0 8px 8px 0}
#mtp-ccm ul.l{margin:0;padding-left:18px;font-size:14px}
#mtp-ccm ul.l li{margin:4px 0}
#mtp-ccm .foot{display:flex;justify-content:space-between;gap:10px;flex-wrap:wrap;margin-top:20px;padding-top:12px;border-top:1px solid var(–line);font-size:12px;color:var(–muted)!important}
#mtp-ccm .foot b{color:var(–clay)!important}
#mtp-ccm a{color:var(–clay2)!important}
@media (max-width:640px){#mtp-ccm{padding:16px}#mtp-ccm h2{font-size:22px}#mtp-ccm .grid2,#mtp-ccm .x{grid-template-columns:1fr}#mtp-ccm .tab{padding:8px 8px;font-size:13px}}
</style></head><body style="margin:0;background:#141413">
<div id="mtp-ccm">
<div class="kick">Claude Code v2.1.323+ · Experimental</div>
<h2>How Code Mode works</h2>
<p class="sub">Claude writes JavaScript that makes several tool calls in 1 step. Source: Claude Code docs.</p>
<div class="tabs" role="tablist">
<button class="tab on" data-p="p1">How it works</button>
<button class="tab" data-p="p2">Turn it on</button>
<button class="tab" data-p="p3">Permissions</button>
<button class="tab" data-p="p4">Run limits</button>
<button class="tab" data-p="p5">Compare</button>
</div>

<div class="panel on" id="p1">
<div class="grid2">
<div class="card"><div class="lbl">Without Code Mode</div><div class="flow" id="fa">
<div class="node m">Model: request Bash (rg)</div><div class="node">Tool runs, result to model</div>
<div class="node m">Model: request Edit</div><div class="node">Tool runs, result to model</div>
<div class="node m">Model: request Bash (npm test)</div><div class="node">Tool runs, result to model</div></div></div>
<div class="card"><div class="lbl c">With Code Mode</div><div class="flow" id="fb">
<div class="node m">Model: writes 1 JavaScript program</div><div class="node">rg finds the file</div>
<div class="node">edit(): maxAttempts 3 to 5</div><div class="node">npm test runs</div>
<div class="node m">Only path + test output return</div></div></div>
</div>
<div class="ctr"><button class="btn" id="play"> Play side by side</button><button class="btn g" id="code">Show the code</button>
<span class="note">Blue dashed = model turn. Clay = tool work.</span></div>
<pre id="cb" style="display:none"><code><span class="k">const</span> files = <span class="k">await</span> $`rg -l "function retryPolicy" src`.text();
<span class="k">const</span> target = files.trim().split("n")[0];
<span class="k">await</span> edit(target, "maxAttempts: 3", "maxAttempts: 5");
({ edited: target, tests: $`npm test — retryPolicy`.nothrow() });</code></pre>
<p class="note" style="margin-top:10px">You see the tool calls (such as the diff), not the code. Press <code>Ctrl+O</code> to open the transcript and expand a Code row.</p>
</div>

<div class="panel" id="p2">
<div class="grid2">
<div class="card"><div class="lbl">Set the variable</div>
<span class="pill on" data-s="s1">macOS / Linux / WSL</span><span class="pill" data-s="s2">PowerShell</span><span class="pill" data-s="s3">settings.json</span>
<pre class="sv" id="s1"><code>CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude</code></pre>
<pre class="sv" id="s2" style="display:none"><code>$env:CLAUDE_CODE_EXPERIMENTAL_CODE_MODE = "1"
claude</code></pre>
<pre class="sv" id="s3" style="display:none"><code>// ~/.claude/settings.json
{ "env": { "CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "1" } }</code></pre>
</div>
<div class="card"><div class="lbl c">Steps</div><ol class="steps">
<li>Run <code>claude –version</code>; update if older than v2.1.323</li>
<li>Start with the variable set to 1</li>
<li>Pick "Yes, turn on Code Mode"</li>
<li>Give Claude a many-tool-call task</li>
<li>Press <code>Ctrl+O</code> to read the code</li></ol></div>
</div>
<div class="warn">A 0 in your shell or settings wins over a 1. Admins can set 0 in managed settings to block it org-wide, but cannot force it on.</div>
</div>

<div class="panel" id="p3">
<span class="pill on" data-m="auto">Auto mode</span><span class="pill" data-m="other">Other permission modes</span>
<div class="card" style="margin-top:8px" id="mtxt"></div>
<div class="warn">Every tool call inside the code still passes your deny and ask rules and PreToolUse hooks under its usual name. To inspect the code, hook the <code>REPL</code> tool and read <code>tool_input.code</code>.</div>
</div>

<div class="panel" id="p4">
<div class="card">
<div class="bar"><div class="t"><span>Claude waits for the code</span><b>10 min max</b></div><div class="tr"><div class="f" data-w="8.33" style="background:#B0AEA5"></div></div></div>
<div class="bar"><div class="t"><span>Code runs in the background (you keep chatting)</span><b style="color:#D97757">2 hr max</b></div><div class="tr"><div class="f" data-w="100" style="background:#D97757"></div></div></div>
<p class="note">The 10-minute limit includes time spent at permission prompts. Background runs need a session started in auto or bypassPermissions mode.</p>
</div>
</div>

<div class="panel" id="p5">
<div class="x">
<div class="card"><div class="lbl c">Claude Code Code Mode</div><div class="stat">JS</div><p class="note">Built-in tools in the CLI. No published token figure.</p></div>
<div class="card"><div class="lbl">Claude API PTC</div><div class="stat">37%</div><p class="note">Python. Avg tokens 43,588 to 27,297 on complex research tasks.</p></div>
<div class="card"><div class="lbl">Code execution with MCP</div><div class="stat">98.7%</div><p class="note">150,000 to 2,000 tokens in 1 Anthropic example.</p></div>
</div>
<div class="warn">Figures come from different tasks and setups. They are not a head-to-head benchmark. Cloudflare coined "Code Mode" (TypeScript, V8 isolates) on Sept 26, 2025.</div>
</div>

<div class="foot"><span>Sources: code.claude.com/docs/en/code-mode · anthropic.com/engineering</span><b>© Marktechpost</b></div>
</div>
<script>
(function(){var r=document.getElementById(‘mtp-ccm’);
function rs(){try{parent.postMessage({mtpH:r.offsetHeight+40,id:’mtp-ccm’},’*’)}catch(e){}}
r.querySelectorAll(‘.tab’).forEach(function(t){t.onclick=function(){r.querySelectorAll(‘.tab’).forEach(function(x){x.classList.remove(‘on’)});r.querySelectorAll(‘.panel’).forEach(function(x){x.classList.remove(‘on’)});t.classList.add(‘on’);var p=document.getElementById(t.dataset.p);p.classList.add(‘on’);if(t.dataset.p===’p4′)bars();rs()}});
var timers=[];function play(){timers.forEach(clearTimeout);timers=[];var a=[].slice.call(document.querySelectorAll(‘#fa .node’)),b=[].slice.call(document.querySelectorAll(‘#fb .node’));a.concat(b).forEach(function(n){n.classList.remove(‘lit’)});
a.forEach(function(n,i){timers.push(setTimeout(function(){n.classList.add(‘lit’)},450*(i+1)))});
b.forEach(function(n,i){timers.push(setTimeout(function(){n.classList.add(‘lit’)},i===0?450:(i===4?1350:900)))});}
document.getElementById(‘play’).onclick=play;
document.getElementById(‘code’).onclick=function(){var c=document.getElementById(‘cb’);var s=c.style.display===’none’;c.style.display=s?’block’:’none’;this.textContent=s?’Hide the code’:’Show the code’;rs()};
r.querySelectorAll(‘[data-s]’).forEach(function(p){p.onclick=function(){r.querySelectorAll(‘[data-s]’).forEach(function(x){x.classList.remove(‘on’)});p.classList.add(‘on’);r.querySelectorAll(‘.sv’).forEach(function(x){x.style.display=’none’});document.getElementById(p.dataset.s).style.display=’block’;rs()}});
var M={auto:'<b>A classifier reviews each piece of code before it runs, not each tool call.</b><br><span class="note">It does not see values computed at run time, such as a path taken from search output. Keep rules or hooks for calls you must control. You can still be prompted when new code starts while earlier code runs.</span>’,other:'<b>The code starts without a review.</b><br><span class="note">You are prompted for each tool call that would prompt you in that mode, exactly as without Code Mode.</span>’};
var mt=document.getElementById(‘mtxt’);mt.innerHTML=M.auto;
r.querySelectorAll(‘[data-m]’).forEach(function(p){p.onclick=function(){r.querySelectorAll(‘[data-m]’).forEach(function(x){x.classList.remove(‘on’)});p.classList.add(‘on’);mt.innerHTML=M[p.dataset.m];rs()}});
function bars(){r.querySelectorAll(‘.f’).forEach(function(f){f.style.width=”0″;setTimeout(function(){f.style.width=f.dataset.w+’%’},60)})}
window.addEventListener(‘load’,function(){rs();setTimeout(play,400)});window.addEventListener(‘resize’,rs);setInterval(rs,1500);
})();
</script>
</body></html>
” style=”width:100%;height:600px;border:0;display:block;background:#141413;border-radius:16px;” loading=”lazy”>

window.addEventListener(“message”,function(e){if(e.data&&e.data.id===”mtp-ccm”&&e.data.mtpH){document.getElementById(“mtp-ccm-frame”).style.height=e.data.mtpH+”px”;}});

How do you turn on Code Mode?

Set CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 in your shell, or in the env block of ~/.claude/settings.json. Before the first session, Claude Code asks you to confirm. Select “Yes, turn on Code Mode”.

Claude Code then restarts and shows ‘Code Mode (experimental) is on’.

A Code Mode session resumes only with the variable still set to 1. Setting 0 anywhere turns it off, even if 1 is set elsewhere. Admins can block it org-wide with a 0 in managed settings. They cannot force it on.

When should developers use Code Mode?

Anthropic recommends it for tasks with 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

How does Code Mode handle permissions and long-running code?

Each tool call inside the code still passes your deny and ask rules. It also passes PreToolUse hooks under the tool’s usual name, such as Bash.

Review differs by permission mode:

  • Auto mode: a classifier reviews each piece of code, not each tool call. It cannot see values computed at run time, such as a path from search output.
  • Other modes: code starts without review, and you are prompted per tool call as usual.

Hook authors should check each part of a command. A git push can arrive as cd ‘app’ && git push. To inspect the code itself, match the REPL tool and read tool_input.code.

If Claude waits, the code stops after 10 minutes, including time at permission prompts. In the background, it can run for up to 2 hours while you keep chatting. Background runs need a session started in auto or bypassPermissions mode.

What are the requirements and limitations?

  • Version: v2.1.323 or later; v2.1.326 or later with agent teams
  • Account: Claude subscription or Console account. Not available through gateways, Amazon Bedrock, Claude Platform on AWS, Google Cloud, or Microsoft Foundry
  • Organization: no HIPAA configuration or zero data retention
  • Surface: interactive terminal only. No -p, Agent SDK, VS Code panel, Desktop app or cloud sessions
  • Blocked settings: API key helper, OpenTelemetry export or DISABLE_TELEMETRY
  • Unavailable features: Remote Control, Claude in Chrome and computer use

How does Code Mode compare with other code-first tool calling?

Cloudflare coined ‘Code Mode’ on September 26, 2025. Its Agents SDK turns MCP schemas into a TypeScript API that runs in V8 isolates.

Anthropic then published code execution with MCP. In one example, token use fell from 150,000 to 2,000, a 98.7% saving. Its API feature, Programmatic Tool Calling, uses Python. It cut average usage from 43,588 to 27,297 tokens on complex research tasks.

Claude Code’s version applies the pattern to the CLI’s own tools. The docs give no token figure. One independent test reported system-tool context of 11.1k tokens with Code Mode versus 24.6k without. Treat that as a single third-party measurement.

FeatureClaude Code Code ModeClaude API Programmatic Tool CallingCloudflare Code ModeStandard tool callingWhere it runsClaude Code CLI, your session (docs)Code execution tool, Claude API (Anthropic)Agents SDK, V8 isolates (Cloudflare)Any tool-use APILanguage Claude writesJavaScriptPythonTypeScriptNone (JSON calls)Tools it orchestratesBuilt-in tools (Bash, Read, Edit)Developer-defined toolsMCP servers as TypeScript APIsAnyStatusExperimental, off by defaultLaunched Nov 2025Worker Loader API in closed betaGAPublished token figureNot disclosed43,588 to 27,297 avg (37%)Not disclosed in launch postBaselineMax run time10 min waiting, 2 hr backgroundNot disclosedNot disclosedPer callCloud providersAnthropic API onlyNot on Bedrock or Google Cloud (docs)Cloudflare WorkersBroad

Key Takeaways

  • Claude writes JavaScript that chains Bash, Read and Edit calls in 1 step.
  • Opt in with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 on v2.1.323 or later.
  • Background code runs up to 2 hours; waiting code stops at 10 minutes.
  • Auto mode reviews the code, not each tool call.
  • Terminal and Anthropic API only: no Bedrock, Google Cloud, SDK or IDE panel.

Check out the Code Mode documentation and the Claude Code changelog. You can check the deployment options and specs here through our GPULeaderboard.com chrome extension.

Also, feel free to follow us on Twitter and don’t forget to join our 150k+ML SubReddit and Subscribe to our Newsletter. Wait! are you on telegram? now you can join us on telegram as well.

Need to partner with us for promoting your GitHub Repo OR Hugging Face Page OR Product Release OR Webinar etc.? Connect with us

The post Anthropic Adds Code Mode to Claude Code: Claude Now Chains Tool Calls in JavaScript appeared first on MarkTechPost.



Source link

You might also like
Leave A Reply

Your email address will not be published.