
Key Updates in Claude Code v2.1.324–v2.1.325 - Changes to the Permission Flow for Bash in the Sandbox and Fixes to Bash Permission Checks
This page has been translated by machine translation. View original
I'm Ishikawa from the Cloud Business Division. This article summarizes the Claude Code v2.1.324 to v2.1.325 (2026-11-13) updates. v2.1.324 is published on npm but has no CHANGELOG entry, so this article covers the changes in v2.1.325. In addition, the Code Mode documentation that returned 404 in the previous article is now published, so I also tried the experimental feature "Code Mode".
The previous update article is here.
Update Summary
This covers 2 versions (v2.1.324 to v2.1.325, 2026-11-13), and the CHANGELOG lists 139 entries for v2.1.325. In this article's categorization: 68 fixes, 31 security items, 13 developer experience items, 9 breaking changes, 9 improvements, 6 new features, 2 performance items, and 1 deprecation. Many items concern permission checks and the sandbox, including default behavior changes that alter whether confirmation is required.
Notable Updates
Bash in the sandbox now follows the normal permission flow by default (v2.1.325)
Bash commands inside the sandbox now follow the normal permission flow by default. To run them without confirmation as before, set sandbox.autoAllowBashIfSandboxed: true. If you enable the sandbox through managed settings, set sandbox.autoAllowBashIfSandboxed: true in the highest-priority managed settings source.
If you relied on automatic approval by the sandbox, you may see confirmations or permission denials after updating, so I think it's worth checking your settings.
Bash permission check fixes (v2.1.325)
The following 3 issues in Bash permission checks were fixed.
- deny and ask rules were not applied to some Bash commands
- Some compound commands could run without confirmation (now they ask for confirmation)
- A Bash allow rule could run a program different from the one written in the rule
These fixes matter to anyone restricting operations with Bash allow, ask, and deny rules, so I think it's best to update early.
Fixed token counting sending data to Amazon Bedrock even when allowedProviders does not allow it (v2.1.325)
Fixed an issue where, even though the managed setting allowedProviders did not allow Amazon Bedrock, token counting via Amazon Bedrock sent the conversation to Bedrock.
For administrators of organizations that do not allow Amazon Bedrock in allowedProviders, this fixes a bug that sent conversations to Bedrock during token counting, so I think rolling it out early is worthwhile.
Security fix in decoding zstd-compressed responses (v2.1.325)
Fixed a security issue in the decoding of zstd-compressed responses.
The CHANGELOG gives no details, but since it's a security fix, I think it's best to update early.
Target Versions and Period
| Version | Release date | CHANGELOG entries |
|---|---|---|
| v2.1.324 | 2026-11-13 | None |
| v2.1.325 | 2026-11-13 | 139 |
New Features
- Added a line under the error shown when an organization policy blocks a request, explaining how to continue (change the message with
/rewind, or run/clear) (v2.1.325) - Added a note passed to Claude when
git checkout,git stash, or a pull with autostash inside the sandbox cannot update protected files such as those in.claude(v2.1.325) - After Claude reads or edits a Jupyter notebook, a spinner hint about re-running notebook cells is now shown in integrated terminals such as VS Code (v2.1.325)
New VS Code extension features are covered in "Other Platforms".
Improvements
- For subagents cut off by the output token limit, Claude is now asked to redo the whole answer more concisely instead of returning only the tail of the answer (v2.1.325)
CLAUDE_CODE_MAX_CONTEXT_TOKENSnow also sets the context window for unknown model IDs starting withclaude-, such as a gateway'sclaude-sonnet-latest(v2.1.325)claude remote-controlnow exits with status 4 when it stops by itself (a single-session run remains 0) and 69 when it cannot register, so a service manager can restart it (v2.1.325)- Claude is now told that an MCP task is waiting for the user's answer, so Claude can point to
/tasks(v2.1.325) - For questions from background MCP tasks, Esc now means "answer later". Nothing is sent to the server, and the question remains in
/tasks(v2.1.325) claude -pwithout cached account data now waits for that data before the first request. A first run in a clean environment may start a few seconds later (v2.1.325)/cost,$.session.usage(),--max-budget-usd, and the cost and token metrics now also count a mod's$.model.completeand$.model.classifycalls (v2.1.325)- After 8 consecutive turns started by background or scheduled tasks, the terminal prompt suggestions are refreshed less often, keeping usage low until you press a key or return to the terminal (v2.1.325)
- Plugin MCP bundles (
.mcpb,.dxt) are now extracted under the plugin directory instead of.mcpb-cacheinside the plugin's folder, so they can load even from read-only plugin folders (v2.1.325) - New sessions opened in tmux and iTerm2 teammates, and from the agent view by pressing ←, now start in the session's folder rather than where the shell last did
cd(v2.1.325) - Also improved: startup with keyless Console sign-in, the
HTTPS authentication failedmessage for private plugin marketplaces,claude --desktopsign-in errors, the "No audio detected" message of/voiceon macOS and Windows, and advice in the bundled dataviz skill (v2.1.325)
Security
In addition to the items covered in the notable updates, there are the following fixes and changes.
- Permission rules
- Fixed relative-path deny and ask permission rules such as
Read(./.env)no longer targeting the project after acd. They now also apply to additional directories (v2.1.325) - Fixed deny and ask permission rules starting with
mcp__plugin_*_not matching plugin MCP servers or tools written with different letter case (v2.1.325) - Fixed deny rules not being applied to permission approvals that arrive after a Claude Code restart in self-hosted runner and
claude remote-controlsessions (v2.1.325) - Fixed a committed
.claude/settings.local.jsonsometimes being treated as the user's own when Claude Code is started in a particular subfolder of a repository (v2.1.325) - Fixed permissions granted by a slash command's
allowed-toolsalso applying to background agents started during or after that turn (v2.1.325) - Fixed the agent and skill lock from the managed setting
strictPluginOnlyCustomizationnot being reflected in running sessions (v2.1.325) - Fixed deny and ask permission rules and hooks not being applied to the Artifact tool in some cloud sessions, and connector tool approval prompts being answered automatically while plugins load in cloud sessions (v2.1.325)
- Fixed relative-path deny and ask permission rules such as
- Sandbox
- Fixed commands inside the sandbox sometimes being able to write to the native updater's download folder (v2.1.325)
- Fixed cases where the Bash sandbox did not fully protect worktree settings and hooks, and the shared git folder of linked worktrees (v2.1.325)
- Writes from inside the sandbox to
.claudesettings, skills, agents, commands, and hooks in additional directories are now denied, as they are in the launch folder (v2.1.325)
- Credentials and personal information
- Programs that the Claude Code sandbox launches for itself (such as the network bridge) now run without Claude Code's sign-in token and API key in their environment variables (v2.1.325)
- ripgrep, local git commands, and sandbox runtime helper programs now run without the mTLS client key passphrase in their environment variables (v2.1.325)
- Expanded the account email address check so that scripts run by commands, file writes, web fetches, and MCP calls are also refused when they use the user's email address as a client identifier (v2.1.325)
/feedbackand/bugnow upload other sessions only if they were recorded under the signed-in account or organization (v2.1.325)
- Artifact
- Fixed some subagents changing, or uploading files to, Artifacts viewable by people outside the organization without confirmation when an allow rule is set or uploads were previously approved (v2.1.325)
- Fixed confirmation sometimes being skipped when publishing pages viewable by people outside the organization after choosing "don't ask again" for Artifacts (v2.1.325)
- Fixed auto mode judging only the first change to an Artifact viewable by people outside the organization. The approval now applies to that change only (v2.1.325)
- Other changes include showing that plugins can run code in plugin install warnings, denying
git bisect runand similar in worktree-isolated sessions, skipping unsafe paths in plugin folders, and confirming before changing privacy settings in/login(v2.1.325)
Fixes
Excerpts focused on fixes related to stability and usability.
- Fixed subagents with their own model switching to the plan-mode model when the model setting is
opusplanorhaiku, and subagents running on a different model than the main session sizing file reads and MCP results based on the main session's model (v2.1.325) - Fixed sessions with many third-party gateways and Foundry stopping every turn on a context length error without being compacted (v2.1.325)
- Fixed the most recent turns sometimes missing from a session resumed after Claude Code did not exit cleanly (v2.1.325)
- Fixed shell commands running in the launch directory after the working directory was deleted. Commands now fail with a message and can be re-run (v2.1.325)
- Fixed edits to an approved plan being lost when the
plansDirectoryfolder is not writable. The plan is now saved in the default plans folder, and a warning shows where and why (v2.1.325) - Fixed a saved
sonnet[1m]model setting being rewritten on fresh install to a model ID the API does not accept (v2.1.325) - Fixed short-lived commands such as
claude auth statusleaving a lock on the Console profile and stalling the next session for about 1 minute (v2.1.325) - Fixed background sessions started with a claude.ai login using, and being billed to, the API key or token of the shell that launched the background service. Also fixed cases where a session switched to a different sign-in in the background (v2.1.325)
- Fixed the AWS
credential_processhelper and Google Cloud default credentials failing when Claude Code is launched without theHOMEenvironment variable (v2.1.325) - Fixed a single invalid value in an Agent SDK
applyFlagSettings()call silently discarding the settings from all earlier calls. The offending call is now rejected with an error (v2.1.325) - Fixed MCP servers staying "needs authentication" and
mcp_toolhooks being skipped after a temporarily rejected token refresh, and MCP tool calls from an SDK host returning "Not connected" even after the MCP server reconnected on a tool call (v2.1.325) - Many other small bugs were also fixed, including those related to Code Mode, the OpenTelemetry
user_promptevent, MCP tasks,/resumeon Windows, and Bash inside the Linux sandbox.
Breaking Changes and Deprecations
Permission flow for Bash in the sandbox (v2.1.325)
Bash commands inside the sandbox follow the normal permission flow by default.
Before (up to v2.1.323): With the following setting, Bash commands in the sandbox ran without confirmation.
{
"sandbox": {
"enabled": true
}
}
After (v2.1.325 onward): The same setting follows the normal permission flow. To run without confirmation as before, add autoAllowBashIfSandboxed.
{
"sandbox": {
"enabled": true,
"autoAllowBashIfSandboxed": true
}
}
If you enable the sandbox through managed settings, put this setting in the highest-priority managed settings source.
According to the official documentation (settings-reference), even when it is true, commands that cannot run inside the sandbox follow the normal permission flow, and deny rules and ask rules with specified content such as Bash(git push *) still apply. When it is false, the decision is made by allow rules and the permission mode. Note that at the time of writing (2026-11-14), the official documentation (sandboxing, settings-reference) lists the default of autoAllowBashIfSandboxed as true, which does not match the CHANGELOG.
Running skills in scheduled tasks and /loop (v2.1.325)
Scheduled tasks and /loop now ask for confirmation before running skills that declare allowed-tools or hooks.
Before (up to v2.1.323): Scheduled tasks and /loop did not ask for confirmation before running these skills.
(スキルの実行前の確認なし)
After (v2.1.325 onward): To run unattended, add Skill(name) to permissions.allow. Below is a configuration example (name is the target skill name).
{
"permissions": {
"allow": ["Skill(name)"]
}
}
List of breaking changes and deprecations
| Target | Before | After / required action |
|---|---|---|
| Bash in the sandbox | Runs without confirmation | Follows the normal permission flow. To run without confirmation, set sandbox.autoAllowBashIfSandboxed: true |
| Enabling the sandbox via managed settings | Runs without confirmation | Set sandbox.autoAllowBashIfSandboxed: true in the highest-priority managed settings source |
| Read-only git commands in repositories that are neither the project nor trusted | Runs without confirmation | Asks for confirmation before running. To run without confirmation, specify the repository with --add-dir instead of the additionalDirectories setting |
Skills declaring allowed-tools or hooks in scheduled tasks and /loop |
Runs without confirmation | Asks for confirmation before running. To run unattended, add Skill(name) to permissions.allow |
| "Always allow" in Desktop, IDE, and SDK hosts | Offers a rule by itself | A rule by itself is offered only if saving it would allow that command again. Scheduled tasks that relied on this may wait for user action |
.claude/skills inside a --plugin-dir plugin |
Loaded from sessions started in a parent folder | No longer loaded from sessions started in a parent folder. Launch Claude Code in the plugin's folder |
-p and SDK runs in worktrees and submodules mounted in a container |
Applied allow rules from .claude/settings.local.json before trust |
Applied only after the folder is trusted |
Marketplace ref |
— | Accepts the full ID of any commit on a branch or tag. Clients older than v2.1.325 cannot clone with this setting and cannot load that marketplace |
Plugin marketplaces and plugin downloads with only ALL_PROXY set |
— | Uses a CONNECT tunnel. Fails with proxies that reject CONNECT |
pluginDigests (deprecated) |
— | Deprecated and ignored. Plugins from remote marketplaces that managed settings declare and enable and that are listed in prependPlugins or appendPlugins are treated as organization plugins |
All items in the list are changes in v2.1.325.
Other Platforms
VS Code extension
- The extension now also shows prompt suggestions where the terminal shows them. Accept with Tab, and disable by setting
promptSuggestionEnabled: falsein Claude Code's settings.json (v2.1.325) - Added Console sign-in that does not create an API key (v2.1.325)
- In SSH, WSL, and container windows, added a field for pasting the redirect URL when signing in to an MCP server from the panel (v2.1.325)
- Also fixed the model picker checkmark, effort options, the sign-in screen, MCP tool permission prompts, and the message shown when organization settings fail to load, and improved notes and error messages for untrusted folders (v2.1.325)
Claude Code on the web and cloud sessions
- Fixed MCP tool descriptions loaded via tool search being cut at 4,096 characters in new cloud sessions. They are now 16,384 characters, the same as other Claude Code sessions (v2.1.325)
- Claude Code on the web, cloud scheduled tasks, and Cowork cloud sessions now start even with
sandbox.failIfUnavailable. Hosted containers have no command sandbox (v2.1.325)
Claude Desktop and Claude Tag
- Fixed third-party deployments of Claude Desktop staying on "Stopping" until the token refresh finishes. This takes effect once Claude Desktop incorporates this version (v2.1.325)
- Fixed Claude Tag not attaching a card to Artifact links pasted into Slack when the poster's Claude sign-in has expired in a workspace not managed by the organization. A plain card is shown instead (v2.1.325)
Trying Code Mode
In the previous article, the Code Mode documentation returned 404 as of 2026-11-13, so I could not check the steps. When I checked on 2026-11-14 it was published, so I enabled Code Mode and ran the same task without and with Code Mode to compare. v2.1.325 also includes 3 Code Mode fixes, such as one for Code Mode scripts ignoring a worktree entered with EnterWorktree.
The test environment was macOS (Darwin 25.6.0, arm64) and Claude Code v2.1.325.
How Code Mode works
According to the documentation, without Code Mode, Claude directly requests tool calls such as Bash, Read, and Edit, reads the results, and then decides the next step. With Code Mode, Claude writes JavaScript that makes the tool calls, and Claude Code runs that code inside the session. Within a single piece of code, you can run commands in parallel, use the result of one call in the next, and return only the part of the output that Claude needs to read.
Code Mode is experimental and disabled by default. The main prerequisites listed in the documentation are as follows.
- Claude Code v2.1.323 or later, native build
- An interactive
claudesession in a terminal (not available with-p, the Agent SDK, the VS Code panel, the Desktop app, or cloud sessions) - A Claude subscription or Console account (not available via gateways, Amazon Bedrock, Claude Platform on AWS, Google Cloud's Agent Platform, or Microsoft Foundry)
- The model is one of Claude Opus 5.5, Sonnet 5.5, Haiku 5.5, or Fable 5.2
- The organization does not use a HIPAA configuration or zero data retention
- On Windows, Git for Windows is installed
- It does not start if you use an API key helper, agent teams, OpenTelemetry export,
DISABLE_TELEMETRY, and so on
Enabling it
Launch with the CLAUDE_CODE_EXPERIMENTAL_CODE_MODE environment variable set to 1. To always enable it, set it in env of ~/.claude/settings.json (it is ignored if written in a project settings file).
My environment sets CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 in the user settings (env in ~/.claude/settings.json), so launching with the following command as is displayed a line saying Code Mode could not be used, and it started with normal tools.
% CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude --model opus

So I removed the agent teams environment variable and launched with --setting-sources project,local so that user settings were not loaded. To keep the comparison conditions the same, I fixed the permission mode with --permission-mode default and the model with --model opus, and specified the fullscreen display I normally use via --settings.
The screens were captured by running the session in tmux and displaying it in an iTerm2 window. Because I ran this from inside another Claude Code session, I put env -i at the start of the launch command when creating the tmux session, so that only minimal environment variables were passed and the parent session's environment variables were not inherited. iTerm2 just connects to that session with tmux attach to display it.
The answer to the confirmation dialog is saved in codeModeCaveatsAcceptedV1 in ~/.claude.json. I had already chosen "Yes, turn on Code Mode" once before capturing, so I backed up ~/.claude.json, deleted only this key, and had the dialog shown again. The commands used for capturing are below (the backup destination has been changed). ~/docs-site is the test project used in the next section.
# Back up ~/.claude.json and delete only the answer to the confirmation dialog
% cp -p ~/.claude.json ~/.claude.json.bak
% python3 - <<'EOF'
import json, os
p = os.path.expanduser("~/.claude.json")
d = json.load(open(p))
assert d.pop("codeModeCaveatsAcceptedV1", None) is True
tmp = p + ".tmp-cm"
json.dump(d, open(tmp, "w"), indent=2, ensure_ascii=False)
os.chmod(tmp, os.stat(p).st_mode & 0o777)
os.replace(tmp, p)
EOF
# Start the tmux server, hide the status bar, and set the window title to claude
% tmux -L cmtest new-session -d -s keep "cat"
% tmux -L cmtest set -g status off
% tmux -L cmtest set -g set-titles on
% tmux -L cmtest set -g set-titles-string "claude"
# Pass only minimal environment variables with env -i and start a Code Mode session
% CLEAN="env -i HOME=$HOME USER=$USER LOGNAME=$USER PATH=$PATH SHELL=/bin/zsh TERM=xterm-256color LANG=ja_JP.UTF-8 TMPDIR=$TMPDIR"
% tmux -L cmtest new-session -d -s cm2 -x 120 -y 40 -c "$HOME/docs-site" "$CLEAN CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude --model opus --permission-mode default --setting-sources project,local --settings '{\"tui\":\"fullscreen\"}'"
# Run in a 120-column x 40-row iTerm2 window
% tmux -L cmtest attach -t cm2
Because env -i does not pass CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS, the agent teams environment variable inherited from the parent Claude Code session is not passed on. The settings in env of ~/.claude/settings.json are not loaded because of --setting-sources project,local.
On the first run, the following confirmation dialog appears. The default selection is "No, start without it", so choose "Yes, turn on Code Mode".

Claude Code restarted, and a line indicating Code Mode was enabled appeared at the top of the session. A session started in Code Mode can be resumed only when Code Mode is enabled. At this point, codeModeCaveatsAcceptedV1 in ~/.claude.json had returned to true.

Comparing the same task without and with Code Mode
I prepared a test project with 5 Markdown files. 5 of the links to local files point to files that do not exist. The file structure and contents are as follows.
docs-site/
├── README.md
├── docs/
│ ├── setup.md
│ └── usage.md
└── examples/
├── advanced.md
└── basic.md
README.md
# Sample Docs
- [セットアップ](./docs/setup.md)
- [使い方](./docs/usage.md)
- [コントリビュートの方法](./CONTRIBUTING.md)
- [公式サイト](https://example.com)
docs/setup.md
# セットアップ
[README に戻る](../README.md)
詳しいインストール手順は [install.md](./install.md) を参照してください。

docs/usage.md
# 使い方
インストールは [セットアップ](./setup.md#install) を参照してください。
サンプルは [基本の例](../examples/basic.md) にあります。
examples/basic.md
# 基本の例
API の詳細は [API リファレンス](../docs/api.md) を参照してください。
次は [応用の例](./advanced.md) です。
examples/advanced.md
# 応用の例
[README](../README.md) / [よくある質問](../docs/faq.md)
The 5 links pointing to nonexistent files are ./CONTRIBUTING.md in README.md, ./install.md and ../images/arch.png in docs/setup.md, ../docs/api.md in examples/basic.md, and ../docs/faq.md in examples/advanced.md.
I placed the same content in a folder without Code Mode (~/docs-site-normal) and one with Code Mode (~/docs-site), and sent the same prompt to each session.
このプロジェクトの Markdown ファイルをすべて読み、存在しないローカルファイルを指しているリンクを一覧にしてください。
This is the screen without Code Mode (the answer's table and notes are omitted).
❯ このプロジェクトの Markdown ファイルをすべて読み、存在しないローカルファイルを指しているリンクを一覧にしてください。
Searched for 1 pattern, read 5 files
⏺ Markdown ファイル 5 つ(README.md、docs/setup.md、docs/usage.md、examples/basic.md、examples/advanced.md)をすべて読み
ました。存在しないローカルファイルを指しているリンクは次の 5 件です。
✻ Worked for 13s · done 9:36
This is the screen with Code Mode. The conversation shows not the code but a summary of the tool calls executed from within the code (Searched for 1 pattern, read 5 files, ran 12 shell commands).

Both sessions listed the same 5 links to nonexistent files.
The JavaScript Claude wrote
The code Claude wrote can be read in the transcript viewer opened with Ctrl+O. The code is collapsed into a line like "Code(…) · 29 lines (click to show)", and the tool calls executed from within the code are listed below it.

Clicking the Code line expands the code.

I extracted the full code from the session transcript (JSONL under ~/.claude/projects/) as the input of the REPL tool that runs code.
% jq -r 'select(.type=="assistant") | .message.content[]? | select(.type=="tool_use" and .name=="REPL") | .input.code' cm_transcript.jsonl
const files = (await $`find . -type f \( -name '*.md' -o -name '*.markdown' -o -name '*.mdx' \) -not -path '*/node_modules/*' -not -path '*/.git/*'`.text()).trim().split('\n').filter(Boolean);
const results = [];
for (const f of files) {
const lines = await file(f).lines();
const dir = f.replace(/\/[^/]*$/, '');
let inCode = false;
const refDefs = [];
lines.forEach((line, i) => {
if (/^\s*(```|~~~)/.test(line)) { inCode = !inCode; return; }
if (inCode) return;
const l = line.replace(/`[^`]*`/g, '');
const targets = [];
for (const m of l.matchAll(/!?\[[^\]]*\]\(\s*<?([^)\s>]+)>?(?:\s+["'][^)]*["'])?\s*\)/g)) targets.push(m[1]);
const rd = l.match(/^\s*\[[^\]]+\]:\s*<?(\S+?)>?(\s|$)/); if (rd) targets.push(rd[1]);
for (const m of l.matchAll(/(?:src|href)=["']([^"']+)["']/g)) targets.push(m[1]);
for (const t of targets) results.push({f, line: i+1, t, dir});
});
}
const broken = [];
for (const r of results) {
let t = r.t;
if (/^[a-z][a-z0-9+.-]*:/i.test(t) || t.startsWith('#') || t.startsWith('//')) continue;
let p = decodeURIComponent(t.split('#')[0].split('?')[0]);
if (!p) continue;
const full = p.startsWith('/') ? '.' + p : r.dir + '/' + p;
const ok = (await $`test -e ${full}`.nothrow()).exitCode === 0;
if (!ok) broken.push(`${r.f}:${r.line} ${r.t}`);
}
({count: files.length, files, linkCount: results.length, broken})
This code lists Markdown files with find, reads each file, and extracts links. Then, for the 12 links remaining after excluding external URLs and in-page links, it runs test -e one at a time in a for loop, and returns the number of files, the file list, the number of links, and the nonexistent links as the result. What Claude received as the result of running this code is as follows.
<repl-output>
<tools-used-before-summary>Bash, Read</tools-used-before-summary>
<result>{
count: 5,
files: [
'./README.md',
'./docs/setup.md',
'./docs/usage.md',
'./examples/basic.md',
'./examples/advanced.md'
],
linkCount: 13,
broken: [
'./README.md:5 ./CONTRIBUTING.md',
'./docs/setup.md:5 ./install.md',
'./docs/setup.md:7 ../images/arch.png',
'./examples/basic.md:3 ../docs/api.md',
'./examples/advanced.md:3 ../docs/faq.md'
]
}</result>
</repl-output>
Comparing the numbers
I aggregated the transcripts of both sessions. metrics.py is a script I wrote that counts model requests per message.id and separately counts tool calls executed from within the code. In the transcript, calls executed from within the code were recorded as messages whose model is <synthetic>. The elapsed time (elapsed_sec) is from the recorded time of the prompt to the recorded time of the last assistant message.
metrics.py
#!/usr/bin/env python3
"""セッションのトランスクリプト(JSONL)から、モデルへのリクエスト数・ツール呼び出し・トークン・所要時間を集計する"""
import json
import sys
from collections import Counter, OrderedDict
from datetime import datetime
path = sys.argv[1]
rows = [json.loads(l) for l in open(path)]
msgs = OrderedDict() # message.id -> {"types": [...], "usage": {...}}
tool_uses = []
inner = [] # Tool calls executed from within the code (<synthetic>)
for r in rows:
if r.get("type") != "assistant":
continue
m = r["message"]
if m.get("model") == "<synthetic>" or r.get("isVirtual"):
for c in m.get("content", []):
if c["type"] == "tool_use":
inner.append(c)
continue
e = msgs.setdefault(m["id"], {"types": [], "usage": None})
for c in m.get("content", []):
e["types"].append(c["type"])
if c["type"] == "tool_use":
tool_uses.append(c)
e["usage"] = m.get("usage") # Use the last usage for the same id
def ts(r):
return datetime.fromisoformat(r["timestamp"].replace("Z", "+00:00"))
prompt_rows = [r for r in rows if r.get("type") == "user" and isinstance(r["message"].get("content"), str)]
asst_rows = [r for r in rows if r.get("type") == "assistant"]
start, end = ts(prompt_rows[0]), ts(asst_rows[-1])
tot = Counter()
for e in msgs.values():
u = e["usage"] or {}
for k in ("input_tokens", "cache_creation_input_tokens", "cache_read_input_tokens", "output_tokens"):
tot[k] += u.get(k) or 0
result = {
"model_requests": len(msgs),
"tool_calls_requested_by_model": dict(Counter(t["name"] for t in tool_uses)),
"tool_calls_inside_code": dict(Counter(t["name"] for t in inner)),
"tokens": dict(tot),
"elapsed_sec": round((end - start).total_seconds(), 1),
}
print(json.dumps(result, ensure_ascii=False))
nm_transcript.jsonl (without Code Mode) and cm_transcript.jsonl (with Code Mode) are copies of each session's transcript under ~/.claude/projects/.
% python3 metrics.py nm_transcript.jsonl
{"model_requests": 3, "tool_calls_requested_by_model": {"Bash": 1, "Read": 5}, "tool_calls_inside_code": {}, "tokens": {"input_tokens": 6, "cache_creation_input_tokens": 20479, "cache_read_input_tokens": 127939, "output_tokens": 1145}, "elapsed_sec": 13.5}
% python3 metrics.py cm_transcript.jsonl
{"model_requests": 2, "tool_calls_requested_by_model": {"REPL": 1}, "tool_calls_inside_code": {"Bash": 13, "Read": 5}, "tokens": {"input_tokens": 4, "cache_creation_input_tokens": 12735, "cache_read_input_tokens": 38641, "output_tokens": 1373}, "elapsed_sec": 15.3}
I also counted the number of characters Claude received as tool results (excluding records of calls executed from within the code).
% jq -s '[ .[] | select(.type=="user" and (.isVirtual|not)) | .message.content[]? | select(type=="object" and .type=="tool_result") | .content | if type=="array" then map(.text // "") | join("\n") else . end | length ] | add' nm_transcript.jsonl
651
% jq -s '[ .[] | select(.type=="user" and (.isVirtual|not)) | .message.content[]? | select(type=="object" and .type=="tool_result") | .content | if type=="array" then map(.text // "") | join("\n") else . end | length ] | add' cm_transcript.jsonl
513
| Item | Without Code Mode | With Code Mode |
|---|---|---|
| Requests to the model | 3 | 2 |
| Tool calls requested by the model | Bash 1, Read 5 | REPL 1 |
| Tool calls executed from within code | None | Bash 13 (find 1, test -e 12), Read 5 |
| Output tokens | 1,145 | 1,373 |
| Input tokens (cache creation) | 20,479 | 12,735 |
| Input tokens (cache read) | 127,939 | 38,641 |
| Tool results Claude received | 651 characters | 513 characters |
| From prompt record to last response | 13.5 sec | 15.3 sec |
With Code Mode, requests to the model dropped from 3 to 2, and the input tokens (cache creation and cache read) and the number of characters in tool results Claude received were also smaller. On the other hand, output tokens and elapsed time were higher with Code Mode. Before capturing, I also ran it once with the classic display and the test project in a different folder. Requests to the model also went from 3 to 2 then, but the relative sizes of tool result characters (without Code Mode 652, with 1,020) and elapsed time (without 17.1 sec, with 13.9 sec) were the reverse of this time. Each was a single run, so treat these as reference values.
Permission checks and how to disable it
According to the documentation, deny and ask permission rules and PreToolUse hooks also apply to each tool call executed from within the code. In auto mode, the safety check is done per piece of code before execution rather than per tool call (the confirmation dialog says the same). If you want to check the code itself, a PreToolUse hook matching REPL can read tool_input.code. This time I ran in manual mode (--permission-mode default), and no permission prompts appeared for calls such as test -e.
To stop using Code Mode, remove CLAUDE_CODE_EXPERIMENTAL_CODE_MODE from both the shell and ~/.claude/settings.json, or set it to 0 in either one, and start a new session. If one is 0, Code Mode is disabled even if the other is 1. To prevent use in your organization, set CLAUDE_CODE_EXPERIMENTAL_CODE_MODE to "0" in env of the managed settings. A running Code Mode session continues until it ends or restarts, and afterward Code Mode sessions cannot be resumed while 0 is set. Code Mode cannot be enabled from managed settings.
Also, Claude in Chrome and computer use cannot be used in a Code Mode session, and the following notice was shown at the bottom of the screen.
No Chrome or computer use: exit and run CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=0 claude for a new session without Code …
For this task, which combines listing, reading, and existence-checking files, Claude put the processing into a single piece of code, and requests to the model dropped from 3 to 2. This was a single comparison on a small project, so the difference is only a reference value, but I think it's worth trying for use cases that check across many files.
Conclusion
In v2.1.325, changes that add confirmation to operations that previously ran without it stand out: Bash in the sandbox, read-only git in repositories that are neither the project nor trusted, and running skills that declare allowed-tools or hooks in /loop. If you run unattended jobs or scheduled tasks, I think it's best to check their behavior after updating and to specify the necessary settings and allow rules explicitly.
References
