Report how another session can reach this one: harness, session ID, working directory, transcript, resume command, PID, and git branch.
Rules
-
Read the ID from the environment, never guess it. Each harness sets it in the shell tool's env:
Harness Detect by Session ID Transcript Resume PID Claude Code CLAUDECODE=1$CLAUDE_CODE_SESSION_ID~/.claude/projects/*/<id>.jsonlclaude -r <id>$CLAUDE_PIDpi PI_CODING_AGENT=true$PI_SESSION_ID$PI_SESSION_FILEpi --session <id>none OpenCode OPENCODE=1none — see rule 2 none (stored in SQLite) opencode -s <id>$OPENCODE_PIDResolve the Claude Code transcript with the glob rather than rebuilding the encoded directory name. Omit any field marked none, and omit the pi transcript when
PI_SESSION_FILEis unset (ephemeral session). -
For OpenCode, take the newest session for the current directory. OpenCode sets no session-ID env var. Run
opencode session list --format json -n 10and pick the most recentlyupdatedentry whosedirectoryequals$PWD. The live session updates on every turn, so it is usually the newest. If two sessions in this directory updated within the last few minutes, say the ID is ambiguous and list both. -
Print only the env vars you need. Never dump the whole environment; it holds API keys.
-
Include the working directory and git branch. Claude Code and pi group sessions by project directory, so another session must resume from it. Omit the branch outside a git repo.
-
Warn against resuming a live session. Two processes writing one session interleave or fork its history. A live peer should read the transcript; resume only after this session exits.
-
Reply in this format and nothing else:
harness: <Claude Code | pi | OpenCode> session: <id> cwd: <absolute path> branch: <git branch> pid: <pid> transcript: <absolute path> resume: cd <cwd> && <resume command> (only after this session exits) -
If no harness matches, say so. Don't fall back to a made-up ID.