[FEATURE] CLI to send a cross-session message to a running session without a model turn, addressable by session id
Problem
A local process that is not a Claude Code model turn — a script, a hook, or another coding agent running on the same machine — has no way to deliver a message to a running Claude Code session. Cross-session messaging exists (ListAgents / SendMessage, crossSessionInbound), but it can only be reached from inside a session, through a model tool call.
The only workaround is to start a headless claude -p --allowedTools ListAgents,SendMessage whose sole job is to call SendMessage. I measured it: it works (the message arrives in an idle session and starts its turn), but every message costs 10–15 s and a paid model turn (~$0.15–0.28 on the default model) for what is a transport operation. The model also has to map a name, because a session's local_<uuid> host id is rejected by SendMessage as "not reachable" (see #88970).
Proposal
A non-interactive command that needs no model turn, for example:
claude send <target> <text> # or --message-file <path>
<target>: the session id (thesessionIdin~/.claude/sessions/<pid>.json), the host id (local_<uuid>), or theListAgentsname.- It reuses the per-session messaging socket and key that already exist, with the same semantics as
SendMessage:crossSessionInbound, permission-mode holds, delivery notices. - It returns an exit code and a JSON result (
delivered/held/refused/not reachable, plus the message id), so scripts can act on it. - Optionally,
claude agents --jsoncould include each session's messaging address, so callers don't have to guess the name.
Why
- Other agents and hooks could coordinate with Claude Code sessions deterministically and cheaply. For example, a hook could tell an idle session that a teammate left it a message, without paying for a model turn.
- Model turns would no longer be spent on pure transport.
- The address would be stable. The session id never changes; names and titles drift (#90338, #86736).
Related
- #88970 —
local_<uuid>is unreachable from theListAgents/SendMessagenamespace - #90338 — no shared identifier between a session's messaging name and its title
- #92058 — scoping cross-session messaging
Environment: Windows 11, Claude Code 2.1.286 (desktop app sessions and CLI).
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗