Skip to main content

Module transcript

Module transcript 

Source
Expand description

On-disk transcript locations for Claude Code sessions.

The CLI persists every session’s journal at ~/.claude/projects/<encoded-cwd>/<session-id>.jsonl. The encoding rule is unpublished CLI behavior, measured against real transcript stores: every / and . in the working directory’s path becomes -; all other characters pass through. Observed pairs:

  • /home/u/repos/inboxnegative.com-home-u-repos-inboxnegative-com
  • /home/u/repos/x/.worktrees/y-home-u-repos-x--worktrees-y

The encoding is lossy (not injective): distinct working directories can collide — a/b.c and a/b/c and a-b-c all encode identically. Treat encoded names as a lookup key for paths you already know, never as something to decode.

Exported so consumers stop growing private copies of the rule: a consumer that re-implements it can silently diverge the day the CLI changes, and two implementations of one CLI behavior is one too many.

Functions§

encode_project_dir
Encode a working directory the way the CLI names its per-project transcript folder: / and . become -, everything else unchanged.
transcript_path
Resolve <home>/.claude/projects/<encoded-cwd>/<session-id>.jsonl — the transcript file the CLI writes for session_id runs in working_directory. Takes home explicitly (pass a tempdir in tests; never let a test path resolve into a real transcript store).