Skip to content

feat(cli): link a fujimoto new session to the session that started it - #57

Merged
jongracecox merged 1 commit into
mainfrom
worktree/20261013-cmux-session-management
Oct 13, 2026
Merged

jongracecox merged 1 commit into
mainfrom
worktree/20261013-cmux-session-management

Conversation

@jongracecox

Copy link
Copy Markdown
Owner

Summary

fujimoto new --parent NAME lets a Claude session that spins off work in a new worktree stay in touch with it, using Claude Code's built-in cross-session messaging (ListAgents / SendMessage).

  • --parent NAME records the starting session's peer address as parent_session in the worktree's .fujimoto/meta.json. This happens on create and on connect, so the latest caller wins.
  • The new session's system prompt names that address and tells it to use SendMessage to reach it.
  • On resume, that one sentence is passed as the system prompt. An appended system prompt does not carry over into a new claude process, so without it a resumed child would lose its parent.
  • --detach JSON gains parent_session.

The address is the peer name, not a Claude session id. I checked by experiment that SendMessage rejects a session id. A child's own address can be fixed up front with claude's --name after --. That is saved as a launch option, so it stays stable across relaunches. Claude Code's derived names (<dir>-<2 hex>) can't be predicted.

Deliberately only the mechanics: what a child should report, and when, is left to the prompt it is started with.

Test plan

  • uv run pytest: 1145 passed. New tests cover meta round-trip and malformed values, --parent passed through, recorded on create and connect, worktree system prompt with and without a parent, resume restates the parent, detach JSON.
  • End to end with this branch's build: a child launched with --parent messaged the parent using only its system prompt (its first message did not mention the address). The parent then messaged the child at its --name address and got a reply.

🤖 Generated with Claude Code

`fujimoto new --parent NAME` records the starting Claude session's peer
address in the worktree's meta.json. The new session's system prompt
names that address and tells it to reach it with SendMessage, so a
session spun off by another can report back. The link is restated on
resume, since an appended system prompt does not carry over into a new
claude process, and `--detach` reports it as `parent_session`.

The address is Claude Code's peer name, not a session id: SendMessage
rejects a session id. A child's own address can be fixed up front with
claude's `--name` after `--`, which is saved as a launch option.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jongracecox
jongracecox merged commit 1bf007b into main Oct 13, 2026
5 checks passed
@jongracecox
jongracecox deleted the worktree/20261013-cmux-session-management branch October 13, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant