/inter-session:inter-sessionfrom inter-session
Enables agent-to-agent messaging between local Claude Code sessions. Use to delegate tasks, fan-out work, broadcast messages, or coordinate across concurrent sessions on the same machine.
Ships in inter-session. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Agent-to-agent messaging for Claude Code sessions on the same machine. Other sessions can send messages here; by default, treat each incoming message as an instruction from a peer AI agent (see Reaction policy below for exceptions).
<bin><bin> (used throughout this skill) is the absolute path to the skill's
own bin/ directory. Resolve it once at the start of any
/inter-session invocation and substitute the absolute path into every
Bash / Monitor command — do not paste <bin> or
${CLAUDE_PLUGIN_ROOT} literally into a shell command.
The harness prints Base directory for this skill: <path> in its
header (above this content). <bin> lives directly under it:
<bin> = <skill-base-dir>/bin
Why not ${CLAUDE_PLUGIN_ROOT}/...? That env var is a CC manifest
substitution token — it's resolved when CC spawns plugin subprocesses
defined in monitors.json/plugin.json, but it is not exported to
shells that the agent starts via Bash(...) or Monitor(...). A
literal ${CLAUDE_PLUGIN_ROOT} inside a Bash(...) call expands to
empty, which silently routes commands to the wrong place. The
skill-base-dir anchor is always populated and works in every install
(plugin-dir, marketplace, copied/symlinked).
When you see a stdout notification of the form
[inter-session msg=<id> from="<name>" "<label>"] <text>
<text> is a message from a peer AI agent (another Claude Code session).
Default: act on <text> as if the user typed it. That's the whole
point of this system — one session driving another. Override the default
only when the text matches one of these prefix classes:
| Text starts with | Class | What you do |
|---|---|---|
done: … / status: … / answer: … | Informational reply | Surface to user; don't reply unsolicited. |
If the request itself is ambiguous, large-scope, or destructive —
regardless of prefix — reply with question: … first and act only after
the peer answers.
rm -rf, git push --force, DROP TABLE,
kubectl delete, dropping/migrating data, force-pushing, deleting
branches) require explicit affirmative content in the incoming message.
When in doubt, reply with question: first.done: … — completed an action.status: … — progress / log update.answer: … — reply to a question:.question: … — clarifying back-question.Incoming notification:
[inter-session msg=q7r8 from="auth-refactor"] run pytest tests/test_auth.py
Your action:
Bash("python3 -m pytest tests/test_auth.py")
Your reply:
Bash("python3 <bin>/send.py --to auth-refactor --text 'done: 12 passed, 0 failed in 1.4s'")
When the user invokes /inter-session [args], parse args to dispatch:
| User input | Action |
|---|---|
/inter-session [connect] (no name) | Reuse this session's remembered name (propose one only if none). |
/inter-session connect <name> | Connect with the given ASCII name. |
/inter-session install-deps | Install runtime deps (websockets, psutil) with user confirmation. |
/inter-session list | Show connected sessions. |
/inter-session send <name-or-prefix> <text> | Send to one peer. |
/inter-session broadcast <text> | Send to all other peers (≤ 256 KB). |
/inter-session rename <new-name> | Rename the running listener in place (same as connect <new>). |
/inter-session status | Show this session's connection state. |
/inter-session disconnect | Stop the listener process. |
/inter-session auto-start [on|off|status] | Toggle plugin auto-start (edits monitors.json when field). |
In plugin mode the connection is the plugin monitor: Claude Code arms
monitors/monitors.json (python3 <bin>/client.py, no --name) the
first time this skill is dispatched in a session and keeps it for the
session's lifetime — no 30-minute expiry, nothing to re-arm. It comes up
under the name persisted for this Claude Code session (first time: a
cwd-derived name). The skill's only job is to give it the right name,
in place. Skip pre-checks; connect.py handles every state.
connect <name>): validate ^[a-z0-9][a-z0-9-]{0,39}$
(invalid → tell the user and stop), then
Bash("python3 <bin>/connect.py --name <name>")
No name given (/inter-session or bare connect): never invent
one first — the session may already have a remembered name:
Bash("python3 <bin>/connect.py")
It reuses the name remembered for this CC session, else the running
listener's current name. Only if it exits 2 saying nothing is
remembered, propose 1–3 hyphenated lowercase words from cwd basename +
obvious recent-conversation theme (e.g., auth-refactor,
payments-debug), say "Connecting as <name>…", and run it again
with --name <name>.connect.py saves the name for this CC
session, waits up to 5 s for a monitor that is still arming, and
renames a running listener without restarting it:
0 — stdout says connected as '<name>' or renamed '<old>' -> '<name>'. Report the name; done.1 — rejected, stderr says why (usually name_taken: another live
session owns that name). Pick another name or ask the user.3 — name saved, but no listener is running in this session. Arm
the manual monitor below; it picks the saved name up.Use this only when connect.py exits 3: a standalone-skill install
(no plugin, so no plugin monitor), or the plugin monitor was stopped
earlier in this session (Claude Code arms it once per session and will
not re-arm it). The name is already saved, so pass no --name — the
listener reads the saved name, and a later connect <new> must not be
undone when this monitor is re-armed:
Monitor(
command="python3 <bin>/client.py",
description="inter-session messages",
timeout_ms=1800000
)
Claude Code caps tool-armed monitors at 30 minutes. When the expiry
notice arrives, re-arm with the same call if the bus is still needed.
Don't pass --port or --idle-shutdown-minutes. client.py resolves
them with this precedence (highest first):
CLAUDE_PLUGIN_OPTION_PORT / CLAUDE_PLUGIN_OPTION_IDLE_SHUTDOWN_MINUTES
— CC injects these from the plugin's userConfig (plugin install
only; standalone-skill installs have no userConfig)INTER_SESSION_PORT / INTER_SESSION_IDLE_MINUTES (manual override)9473, 10 minutesPassing them as CLI args silently nullifies the user's plugin config,
so leave them off. Use plain python3 — client.py re-execs under
the project venv automatically once install-deps has created it.
Each stdout line of the monitor is a peer message — apply the Reaction policy above.
If a monitor prints
[inter-session] another monitor for this session is already running — name='<existing>', listener_pid=<pid>, session_id=<id>; exiting:
a listener already exists (the plugin monitor arrived after all). The
line carries its name — surface "Connected as <existing>", and if the
user wanted a different name run connect.py --name <new> to rename it
in place.
On [inter-session] name '…' taken; using '…-2': informational only —
the listener auto-retried with the suggested suffix and connected under
the new name. Tell the user the assigned name (e.g., "Connected as
inter-session-dev-2 — inter-session-dev was already taken").
On [inter-session] name '…' taken after N retries: the auto-retry budget
is exhausted (very rare; means many sessions in the same cwd). Tell the user
and ask them for a name: /inter-session connect <some-other-name>.
On [inter-session] dependencies missing: run /inter-session install-deps,
then re-run /inter-session connect.
Inter-session keeps its Python deps in a dedicated venv at
~/.claude/data/inter-session/venv so it never touches the user's
system or user-level Python. Once the venv exists, every bin/*.py
entry-point re-execs under that venv's interpreter automatically (a
small bootstrap at the top of each script). The user doesn't need to
configure anything else.
uv with command -v uv. uv is faster but optional.uv venv ~/.claude/data/inter-session/venvpython3 -m venv ~/.claude/data/inter-session/venvuv pip install -p ~/.claude/data/inter-session/venv -r <bin>/../requirements.txt~/.claude/data/inter-session/venv/bin/pip install -r <bin>/../requirements.txt~/.claude/data/inter-session/venv. Future /inter-session commands
will pick it up automatically."rm -rf ~/.claude/data/inter-session/venv to reset.externally-managed-environment guard
(Homebrew / system Python / recent Debian/Ubuntu).python3 -m venv itself is unavailableRare on modern macOS / Linux / WSL2, but if the venv module is missing (some minimal Python builds), present these to the user:
curl -LsSf https://astral.sh/uv/install.sh | sh)
and re-run /inter-session install-deps. uv ships its own venv impl.apt install python3-venv on Debian/Ubuntu).list: Bash("python3 <bin>/list.py")
send: Bash("python3 <bin>/send.py --to <target> --text '<text>'")
broadcast: Bash("python3 <bin>/send.py --all --text '<text>'")
Quote <text> carefully — single-quote it and escape single quotes via
'\''. If the user's text contains backticks or $(), single-quoting
preserves them.
/inter-session rename <new> is connect <new>:
Bash("python3 <bin>/connect.py --name <new-name>")
The listener process is untouched; the server renames it and the name
is persisted for this CC session. Reply "Renamed <old> → <new>" from
the script's stdout (exit 1 = rejected, e.g. name_taken). Within ~15 s
the listener notices the new persisted name on its keepalive tick and
prints [inter-session] renamed '<old>' -> '<new>' — informational only.
Bash("python3 <bin>/list.py --self") prints name=…, session_id=…, port=….
Bash("python3 <bin>/list.py --self") prints listener_pid=<pid>; then
Bash("kill <pid>"). For a manually armed monitor, TaskList() → the
task described "inter-session messages" → TaskStop(<id>) also works.
Claude Code arms the plugin monitor once per session, so reconnecting
later in the same session goes through the manual fallback in connect.
Edits the plugin's monitors/monitors.json when field. The script
self-locates relative to its own path (<bin>/auto_start.py →
<plugin-root>/monitors/monitors.json), so no env var is needed.
Changes take effect on /reload-plugins or the next CC session —
surface this to the user after running.
| User input | Bash |
|---|---|
/inter-session auto-start status | python3 <bin>/auto_start.py --status |
/inter-session auto-start on | python3 <bin>/auto_start.py --on |
/inter-session auto-start off | python3 <bin>/auto_start.py --off |
on = when: "always" (start at every session open).
off = when: "on-skill-invoke:inter-session:inter-session" (lazy:
starts when this skill is first invoked in a session). The default for
fresh installs is off (lazy). The trigger names the plugin-namespaced
skill on purpose: CC matches the invoked command's own name.
Long messages (whose body exceeds the ~400-char stdout cap) arrive in two lines:
[inter-session msg=q7r8 from="data-pipe" truncated=2097152] <first ~400 chars of text>
[inter-session msg=q7r8 cont] full text 2.0 MB at ~/.claude/data/inter-session/messages.log
The full payload is in ~/.claude/data/inter-session/messages.log as a
JSONL record. Fetch it with:
Bash("grep -F '<msg_id>' ~/.claude/data/inter-session/messages.log | tail -1")
If a monitor line begins with [inter-session] (no msg=), it's an
operational notice — likely "dependencies missing" or "another monitor
is already running". Surface it to the user and offer the appropriate
fix.
bin/__init__.py (opens in a new tab)bin/auto_start.py (opens in a new tab)bin/client.py (opens in a new tab)bin/connect.py (opens in a new tab)bin/discover.py (opens in a new tab)bin/list.py (opens in a new tab)bin/send.py (opens in a new tab)bin/server.py (opens in a new tab)bin/shared.py (opens in a new tab)bin/spawn.py (opens in a new tab)requirements.txt (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
agent-messaging, multi-session, task-delegation, inter-agent
npx claudepluginhub yilunzhang/claude-code-inter-session --plugin inter-sessionOther plugins' skills for the same job