CLAUDE_CODE_MESSAGING_SOCKET
ユーザーではなく Claude Code が設定する変数である。インボックスソケットをバインドするセッションで、Claude Code はソケットをバインドする際にそのパスをフックと Bash コマンドへエクスポートする。メッセージング有効で始まるセッションでは、Claude Code は任意のフックが実行される前にソケットをバインドする。マシン上の他のセッションはこのパスへメッセージを配信する。各セッションは親から継承したものではなく自身のソケットをエクスポートし、そこに届いたメッセージはそのセッションの受信制御を通る。設定の env ブロックでは設定できない。Claude Code v2.1.224 以降が必要である
使い方・用途
- hooks や Bash コマンドからそのセッションの受信ソケットのパスを参照し、他のセッションからこのセッションへメッセージを届けられるようにする
- hooks が実行されるより前に Claude Code がソケットをバインドしてこの変数をエクスポートするため、SessionStart を含む SessionStart 時点の hooks でもセッションのメッセージ送付先を利用できる
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 when it binds the socket. In a session that starts with messaging on, Claude Code binds the socket 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