Open in Rex
cresume is on PATH (source: scripts/cresume.py in this skill). It finds a session by its title in the app sidebar, or by its Claude Code session ID. Then it runs claude --resume in the session's folder. While the app is busy with that session, it waits. So a Rex tab that you open for this session continues the same session after this turn ends.
Steps
- Choose the session.
- The user names no session: use this session. Its ID is
$CLAUDE_CODE_SESSION_ID. - The user names a session: run
cresume "<title>" --print. If it lists more than one session, show the list and ask which one. Use the ID of that session. - The user only wants the command (for example, to copy it): run
cresume ["<title>"] --print | pbcopy. Tell the user that the command is on the clipboard, and stop here.
- The user names no session: use this session. Its ID is
- Open the tab in Rex. Run
rex ls --json.- One Rex session: use its
session_idasS, then run:rex run -s "$S" --label "<session title>" -- cresume <session ID> - More than one Rex session: ask the user which one. Then do as for one session.
- No Rex session: run
rex new --json -- cresume <session ID>. Its first tab runscresume. Use.session_idasS.
- One Rex session: use its
- Show it in the Rex app.
open -acomes first, because the app cannot select a session when it has no window:
Ifopen -a "Rex Beta" C=$(rex client ls --json | jq -r '[.clients[] | select(.info.kind=="app")][0].client_id') rex -C "$C" do session.select session_id="$S"session.selectfails, continue. The tab is in Rex, and the user can select it. - Tell the user in one or two sentences that the session is open in Rex. For this session, say that the Rex tab starts when this turn ends. Then end the turn at once. Do no other work, because the Rex tab waits for this turn to end.
Rules
- Do not add
--fork-sessionunless the user asks for a copy. Without it, Rex continues the same session ID. - When the session continues in Rex, the user must not type in the app and in Rex at the same time, because both write to the same transcript. Tell the user this once.
- If
cresumefails, show its message. Do not guess a folder or a session ID.