5 ファイル変更 +22 -8

この更新の概要

サブエージェントの会話ログの保存場所が定義され、履歴管理の仕様が明確化されました。フック設定において、シェルのクォート問題を回避するためのexec形式とargsオプションの使い分けが詳細に解説されています。セキュリティ強化のため、ルート権限やsudo環境下で特定の権限スキップモードが実行不可となる制約が追加されました。プラグイン開発者向けに、環境変数の安全な参照方法やパスの取り扱いに関するベストプラクティスが更新されています。

claude-directory +1 -0

サブエージェントの会話ログが保存されるディレクトリパスと、セッション終了時の削除ルールが追記されました。

@@ -92,6 +92,7 @@ Files in the paths below are deleted on startup once they're older than [`cleanu
| Path under `~/.claude/` | Contents |
| - | - |
| `projects/<project>/<session>.jsonl` | Full conversation transcript: every message, tool call, and tool result |
| `projects/<project>/<session>/subagents/` | [Subagent](/en/sub-agents) conversation transcripts, removed with the parent session transcript when it ages out |
| `projects/<project>/<session>/tool-results/` | Large tool outputs spilled to separate files |
| `file-history/<session>/` | Pre-edit snapshots of files Claude changed, used for [checkpoint restore](/en/checkpointing) |
| `plans/` | Plan files written during [plan mode](/en/permission-modes#analyze-before-you-edit-with-plan-mode) |
hooks-guide +1 -1

コマンドが見つからないエラーへの対策として、exec形式を使用してシェルを介さずスクリプトを直接実行する方法が追加されました。

@@ -846,7 +846,7 @@ You see a message like "PreToolUse hook error: ..." in the transcript.
echo '{"tool_name":"Bash","tool_input":{"command":"ls"}}' | ./my-hook.sh
echo $? # Check the exit code
```
- If you see "command not found", use absolute paths or `$CLAUDE_PROJECT_DIR` to reference scripts
- If you see "command not found", use absolute paths or `${CLAUDE_PROJECT_DIR}` to reference scripts. To avoid shell quoting entirely, add `"args": []` to switch to [exec form](/en/hooks#exec-form-and-shell-form), which spawns the script directly without a shell
- If you see "jq: command not found", install `jq` or use Python/Node.js for JSON parsing
- If the script isn't running at all, make it executable: `chmod +x ./my-hook.sh`
hooks +11 -6

フック設定の各サンプルにargsプロパティが追加され、環境変数を安全に展開するための新しい記述形式が示されています。

@@ -63,7 +63,8 @@ To see how these pieces fit together, consider this `PreToolUse` hook that block
{
"type": "command",
"if": "Bash(rm *)",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-rm.sh"
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/block-rm.sh",
"args": []
}
]
}
@@ -429,7 +430,8 @@ This example uses `${CLAUDE_PROJECT_DIR}` to run a style checker from the projec
"hooks": [
{
"type": "command",
"command": "\"${CLAUDE_PROJECT_DIR}\"/.claude/hooks/check-style.sh"
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/check-style.sh",
"args": []
}
]
}
@@ -452,7 +454,8 @@ This example runs a formatting script bundled with the plugin:
"hooks": [
{
"type": "command",
"command": "\"${CLAUDE_PLUGIN_ROOT}\"/scripts/format.sh",
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/format.sh",
"args": [],
"timeout": 30
}
]
@@ -1899,7 +1902,8 @@ This example logs all configuration changes for security auditing:
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/audit-config-change.sh"
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/audit-config-change.sh",
"args": []
}
]
}
@@ -2574,7 +2578,8 @@ Then add this configuration to `.claude/settings.json` in your project root. The
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/run-tests-async.sh",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/run-tests-async.sh",
"args": [],
"async": true,
"timeout": 300
}
@@ -2609,7 +2614,7 @@ Keep these practices in mind when writing hooks:
- **Validate and sanitize inputs**: never trust input data blindly
- **Always quote shell variables**: use `"$VAR"` not `$VAR`
- **Block path traversal**: check for `..` in file paths
- **Use absolute paths**: specify full paths for scripts, using `"$CLAUDE_PROJECT_DIR"` for the project root
- **Use absolute paths**: specify full paths for scripts. In exec form, use `${CLAUDE_PROJECT_DIR}` and the path needs no quoting. In shell form, wrap it in double quotes
- **Skip sensitive files**: avoid `.env`, `.git/`, keys, etc.
## Windows PowerShell tool
permission-modes +8 -0

セキュリティ上の理由から、管理者権限での実行時に権限確認のスキップを拒否する仕様と、コンテナ環境での推奨構成が追記されました。

@@ -253,6 +253,14 @@ claude --permission-mode bypassPermissions
The `--dangerously-skip-permissions` flag is equivalent.
On Linux and macOS, Claude Code refuses to start in this mode when running as root or under `sudo`:
```text
--dangerously-skip-permissions cannot be used with root/sudo privileges for security reasons
```
The check is skipped automatically inside a recognized sandbox. To run autonomously in a container, use the [dev container](/en/devcontainer) configuration, which runs Claude Code as a non-root user.
`bypassPermissions` offers no protection against prompt injection or unintended actions. For background safety checks without prompts, use [auto mode](#eliminate-prompts-with-auto-mode) instead. Administrators can block this mode by setting `permissions.disableBypassPermissionsMode` to `"disable"` in [managed settings](/en/permissions#managed-settings).
## Protected paths
plugins-reference +1 -1

プラグインのルートパスを参照する際、フックの種類に応じてexec形式とシェル形式を使い分ける具体的な手法が更新されました。

@@ -537,7 +537,7 @@ For all path fields:
Claude Code provides three variables for referencing paths. All are substituted inline anywhere they appear in skill content, agent content, hook commands, monitor commands, and MCP or LSP server configs. All are also exported as environment variables to hook processes and MCP or LSP server subprocesses.
**`${CLAUDE_PLUGIN_ROOT}`**: the absolute path to your plugin's installation directory. Use this to reference scripts, binaries, and config files bundled with the plugin. In hook and monitor commands, wrap it in double quotes, as in `"${CLAUDE_PLUGIN_ROOT}"`, so paths containing spaces or special characters are passed as a single argument. This path changes when the plugin updates. The previous version's directory remains on disk for about seven days after an update before cleanup, but treat it as ephemeral and do not write state here.
**`${CLAUDE_PLUGIN_ROOT}`**: the absolute path to your plugin's installation directory. Use this to reference scripts, binaries, and config files bundled with the plugin. In hook commands, use [exec form](/en/hooks#exec-form-and-shell-form) with `args` so the path is passed as one argument with no quoting. In shell-form hooks and monitor commands, wrap it in double quotes, as in `"${CLAUDE_PLUGIN_ROOT}"`. This path changes when the plugin updates. The previous version's directory remains on disk for about seven days after an update before cleanup, but treat it as ephemeral and do not write state here.
When a plugin updates mid-session, hook commands, monitors, MCP servers, and LSP servers keep using the previous version's path. Run `/reload-plugins` to switch hooks, MCP servers, and LSP servers to the new path; monitors require a session restart.