環境変数

CLAUDE_CODE_MESSAGING_SOCKET

ユーザーではなくClaude Code自身によって設定され、インボックスソケットをバインドするセッションにおいて、フックが実行される前にそのソケットのパスをフックやBashコマンドへ公開するために使用される環境変数です(Claude Code v2.1.224以降が必要です)。

使い方・用途

  • 同一マシン上の他のセッションからこのパスを通じてメッセージを受け取れるように、セッションごとに独自のソケットパスをフックやBashに自動公開する際にシステム内部で利用されます
  • 各セッションは親から継承したソケットではなく自身のソケットをエクスポートし、到着したメッセージはインバウンド制御を通ります
  • ユーザーが手動で settings の env ブロック等に設定しても無視されます
英語原文(公式ドキュメントより)

Set by Claude Code, not by you: in sessions that bind an inbox socket, Claude Code exports that socket's path to hooks and Bash commands before any hook runs. Other sessions on the machine deliver messages to this path. Each session exports its own socket rather than one inherited from a parent, and messages arriving on it go through the session's inbound controls. Settings env blocks can't set it. Requires Claude Code v2.1.224 or later