Repository navigation
feat(cli): link a fujimoto new session to the session that started it - #57
Merged
Merged
Conversation
`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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fujimoto new --parent NAMElets 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 NAMErecords the starting session's peer address asparent_sessionin the worktree's.fujimoto/meta.json. This happens on create and on connect, so the latest caller wins.SendMessageto reach it.--detachJSON gainsparent_session.The address is the peer name, not a Claude session id. I checked by experiment that
SendMessagerejects a session id. A child's own address can be fixed up front with claude's--nameafter--. 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,--parentpassed through, recorded on create and connect, worktree system prompt with and without a parent, resume restates the parent, detach JSON.--parentmessaged the parent using only its system prompt (its first message did not mention the address). The parent then messaged the child at its--nameaddress and got a reply.🤖 Generated with Claude Code