Skip to content

feat(cli): p export claude takes --session-id and --cwd - #233

Closed
ecalifornica wants to merge 2 commits into
mainfrom
ecalifornica/export-claude-cwd-session-id
Closed

feat(cli): p export claude takes --session-id and --cwd#233
ecalifornica wants to merge 2 commits into
mainfrom
ecalifornica/export-claude-cwd-session-id

Conversation

@ecalifornica

@ecalifornica ecalifornica commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Claude Code resumes a session from ~/.claude/projects/<slug of directory>/<session ID>.jsonl and expects the cwd and sessionId keys inside the file to match that directory and ID.

--session-id takes a UUID and sets every entry's sessionId and every sessionId key in every preamble line, nested keys included. With --project it also names the session file.

--cwd takes a directory and sets the cwd of every entry, so the file matches the directory where the session is resumed. The directory does not have to exist on this machine. --cwd conflicts with --project, which already fixes the directory. --project does not rewrite cwd. The file keeps the session's recorded cwd. Follow-up: #239.

--project writes into this machine's ~/.claude/projects/ and requires the directory to exist here. The new flags change only the values in the output and work with --output and stdout, so the file can target a directory that exists only on another host.

scripts/resume-remote.sh uses both flags to ship a local session to an ssh host under the remote project directory and a fresh ID, and checks that the output carries both values.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown

🔍 Preview deployed: https://69e4a578.toolpath.pages.dev

@ecalifornica
ecalifornica force-pushed the ecalifornica/export-claude-cwd-session-id branch 2 times, most recently from 39f2bd3 to 928da47 Compare August 25, 2026 19:41
`--session-id <uuid>` renames the session: the ID becomes the
conversation's session ID, every entry's `sessionId`, and every
`sessionId` key in every preamble line, nested keys included (Claude
Code copies the ID into `worktreeSession.sessionId` on `worktree-state`
lines). Any UUID form is accepted; the output uses the hyphenated
lowercase form. With `--project` it names the session file.

`--cwd <dir>` roots the session: the directory becomes the `cwd` of
every entry that carries one. It must be an absolute POSIX path in
normalized form (no `.`, `..`, or empty component; one trailing `/` is
dropped) and does not have to exist on this machine. It conflicts with
`--project`.

Message content and tool results are not touched. Each rewrite runs
only when its flag is given.

path-cli 0.19.0; toolpath-cli 0.19.0 (lockstep bump of the shim).
…-session-id

Step 5 is one `p export claude --input <doc> --cwd <remote-dir>
--session-id <minted-ID>` call. The script dies when the output carries
no `cwd` equal to the remote project directory or no `sessionId` equal
to the minted ID, and ships it as is. The summary prints both counts.
@ecalifornica
ecalifornica force-pushed the ecalifornica/export-claude-cwd-session-id branch from 928da47 to f678e77 Compare August 25, 2026 20:02
@ecalifornica
ecalifornica marked this pull request as ready for review August 25, 2026 20:07
@ecalifornica
ecalifornica requested a review from akesling August 25, 2026 20:07
@ecalifornica
ecalifornica marked this pull request as draft August 27, 2026 16:31
@ecalifornica
ecalifornica deleted the ecalifornica/export-claude-cwd-session-id branch August 27, 2026 20:41
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.

2 participants