Claude Code Mode: What Batched Tool Execution Changes
A coding agent can spend a surprising amount of time coordinating tools. Reading files, applying edits, inspecting results, and asking the model what to do next create repeated round trips even when the underlying task is straightforward. A faster model does not eliminate that orchestration overhead.
Claude Code's experimental Code Mode lets the agent express tool work as JavaScript in a persistent runtime. It can combine operations, retain intermediate data, and return only the information needed for the next decision. The main change is how work is organized between model calls, not a new ability to edit code. A controlled refactoring comparison shows where that organization helps and where performance or permission claims need qualification.
Tool orchestration becomes a program
In a conventional tool loop, a model requests an operation, receives its result, and decides what to do next. The sequence may already contain batch operations, but each model round trip has latency and context cost. Returning a large result also requires the model to process information that could have been reduced locally.
Code Mode gives the agent a JavaScript environment for composing native operations. File reads, edits, and shell commands remain connected to Claude Code's tools, while the surrounding program controls their sequence and transforms their outputs.
That creates two useful opportunities. Dependent actions can run as a short program instead of requiring the model to issue every action separately. Independent reads can be grouped, and their results can be filtered before returning to the conversation.
A model still needs to decide what work is appropriate. A batch program is helpful when the decision can be expressed clearly, such as examining a known group of files and collecting a small summary. It is less helpful when each intermediate result changes the task in an unpredictable way.
This is also different from giving the model a generic script runner with no connection to the development environment. Native edits can remain visible to Claude Code's file-change interfaces. The orchestration layer changes, while useful application-level semantics can remain attached to the operations.
Persistent data reduces repeated analysis
The JavaScript runtime persists across programs in a session. A file can be read once, parsed into a useful structure, and inspected again without returning its entire contents to the model or rereading it from disk on every turn.
This is particularly valuable for large logs or repeated repository analysis. One program can create a map of error patterns, while another examines a subset after the model asks a more specific question. The model receives a targeted answer instead of repeatedly consuming the raw dataset.
Persistence introduces state management, however. A cached file representation can become stale after an edit or an external process writes new data. The agent needs a clear understanding of which values are snapshots and which operations retrieve current state. Reusing an old value efficiently is not useful if it produces the wrong conclusion.
Session boundaries matter too. Persistent variables are not a substitute for durable files, and a resumed workflow may require the same mode and compatible session state. Anything needed for recovery or audit should be written to an appropriate artifact rather than left only in an in-memory variable.
This is the broader optimization: keep mechanical processing close to the data, and send concise evidence to the model. The gain can come from reduced context traffic and fewer decisions even when the actual file operations are not substantially faster.
A refactoring fixture with deliberate traps
The controlled comparison uses a TypeScript and Express store API containing 53 files and roughly 40 routes. It has 166 actual console calls that need to use an existing structured logger. The logger implementation is already present, so the task concerns wiring and replacement rather than designing logging from scratch.
The fixture also includes deliberate traps: comments and test strings containing console-like text, an existing type error, and existing lint issues. A successful refactor removes the real console calls while leaving those unrelated elements intact.
That distinction makes the test more meaningful than counting text replacements. An agent that blindly replaces every occurrence can alter fixtures or comments incorrectly. An agent that fixes every reported issue can exceed the requested scope, making its result harder to review even if the repository looks cleaner afterward.
Each run starts from the same reset repository. Three runs use Code Mode off and three use it on, with Opus 5.5, medium effort, and auto mode. The reset controls the starting state; repeating runs provides a small view of variability.
Three trials per condition remain a small sample. They can reveal a consistent result in this fixture, but they do not establish a universal performance distribution across repositories, models, or tasks. Provider load and implementation changes can also affect timings outside the agent's local work.
Correctness did not improve merely because the mode changed
All six runs remove the real console calls and pass the same 56 tests. The comment and test-string traps remain, as do the unrelated preexisting issues. The quality checks therefore show comparable success on the defined task.
Passing those tests does not prove the repository is free of every defect. It establishes that this acceptance suite passed after the requested transformation. The remaining type and lint findings were deliberately outside the task, so describing the result as an entirely clean typecheck would be inaccurate.
This separation is important when evaluating agents. A completion score should say what was checked. A narrow refactoring task can be successful without resolving every issue in the project, and extra unsolicited changes should not automatically be scored as better work.
The comparison also avoids a misleading baseline. Without Code Mode, Claude Code can already invoke Python or another script to batch changes. The baseline is not restricted to making 166 separate model calls for 166 replacements. The useful question is whether native programmatic orchestration improves the complete workflow beyond those existing techniques.
That is why the same quality outcome is informative. It allows timing and observability to be compared without claiming that a mode switch made the model fundamentally better at recognizing the required transformation.
Fewer round trips explain much of the timing result
The displayed average runtime falls from about 3 minutes 31 seconds with Code Mode off to 2 minutes 52 seconds with it on, roughly an 18% reduction. Average model round trips fall from 14.3 to 10.3, approximately 28% fewer.
The three Code Mode runs are also more tightly grouped in this sample, while the baseline runs vary by more than a minute. That is useful local evidence, but it does not establish a statistical guarantee that every task becomes more predictable.
The mechanism is plausible: a program can carry several related operations through without asking the model to coordinate each transition. Fewer transitions mean fewer opportunities to reread context, reconstruct intermediate state, or wait for another response.
However, fewer calls are not always better. A program that batches too much can continue after an assumption becomes invalid. Good orchestration includes checks that stop or summarize an unexpected result. The goal is to remove mechanical round trips while preserving decisions that need fresh judgment.
For interactive work, wall-clock duration is often more useful than the count of tool invocations. A batch can contain many native operations but require fewer model decisions. Comparing only the number of visible tool entries can hide that distinction.
Cost and speed need separate measurements
The displayed average costs are approximately $1.43 for the baseline and $1.32 for Code Mode. Individual runs vary, and the comparison characterizes the cost as broadly similar rather than a dramatic reduction.
This is consistent with the architecture. Fewer model round trips can reduce overhead, but larger programs, different reasoning paths, and the contents returned to the model still influence usage. A mode that saves time need not reduce the total bill by the same percentage.
The cost result should therefore stay attached to its task and sample size. It is not evidence for a fixed discount that can be applied to every development session. Longer investigations, large repositories, and failure recovery can produce different balances.
A practical evaluation would record successful completion, duration, model usage, and human review effort together. Saving thirty seconds while producing a harder-to-review change may not improve the overall workflow. Conversely, similar provider cost can still be worthwhile if the result arrives sooner and is easier to inspect.
This is also why automatic task repetition needs a clear budget. A faster orchestration mode can make it easier to start more work, and the total spend can rise even if each individual task becomes slightly cheaper.
Native edits improve visibility into what changed
One baseline path uses Python through the shell to modify files. That can produce correct changes, but the tool-specific edit telemetry may show no native edits because the writes occurred inside a shell command. Zero recorded native edit lines does not mean zero repository changes.
With Code Mode, changes can use the native Edit tool, preserving its diff and file-history behavior. The reported native edit summary includes 224 added lines and 171 removed lines for the refactor.
This is an observability improvement rather than a proof that shell-based editing is incorrect. A repository diff remains necessary in either case. Native integration makes it easier for the application to present what happened through its ordinary review surfaces.
The distinction is valuable for teams assessing agent activity. A tool's metrics describe the operations it observes, not necessarily every filesystem effect. A count of Edit calls, for example, misses modifications performed by a formatter, generator, or shell script.
Reliable review follows the resulting files and checks. Tool traces add context about intent and execution, while the final diff shows the actual artifact. Both are useful, and neither should be mistaken for a complete account of correctness on its own.
Large logs benefit from keeping data near execution
A second workload examines a log file of approximately 44 MB and 200,000 lines, containing JSON and plain-text records. Both approaches reach the correct grouping result, but Code Mode can retain the parsed data for subsequent analysis.
The useful boundary is between raw data and the evidence returned to the model. A program can aggregate repeated patterns and return counts or representative examples. That reduces the amount of repetitive log text included in context while retaining the ability to investigate a selected pattern later.
This does not authorize unrestricted access to log contents. Logs can contain credentials, personal data, or internal infrastructure details. Filtering before model exposure can reduce unnecessary disclosure, but only if the processing program and its output are designed around that boundary.
Persistent data also needs resource limits. Reading a 44 MB file into memory is manageable in many development environments, but the same approach may not suit a multi-gigabyte stream. The architecture supports local reduction; it does not remove ordinary concerns about memory, streaming, and retention.
Permissions still apply inside a program
Code Mode changes the unit submitted for review. Auto mode can inspect an entire program before it executes, but values computed at runtime may not be visible to that initial review. A path assembled from search results is a different case from a literal path written directly in the program.
The current documentation explains that deny and ask rules and relevant hooks still apply to individual tool operations. This is why a programmatic loop should not be treated as a way to bypass ordinary tool permissions.
There is also a sandbox distinction. Bash sandboxing does not automatically place every JavaScript operation or external tool call inside the same operating-system sandbox. The exact environment and permission boundaries need to be understood before giving a long-running program broad access.
Version details matter because the feature is experimental. Some compatibility limitations in early examples have changed. For example, current documentation permits OpenTelemetry events and metrics in supported versions while retaining limitations around tracing. An older blanket statement that telemetry cannot work should not be carried forward without checking the installed release.
The feature is most relevant when a task contains substantial mechanical orchestration: multi-file refactoring, repeated inspection, or large-data reduction. It provides less obvious benefit for a short question that needs one file read and no persistent processing.
Final thoughts
Code Mode turns tool coordination into a program that can retain data and combine related operations. In the six-run refactoring sample, it preserves the same tested outcome while reducing model round trips and average completion time. Native edit integration and persistent log analysis provide benefits beyond the raw timing figure.
The gain comes from better orchestration, while correctness, cost, and permission boundaries still need independent checks. The small benchmark supports using the feature for suitable mechanical workflows, not assuming a universal speedup or a new security boundary. A representative task with clear acceptance criteria remains the most useful way to evaluate it.