Read Claude CLI transcript history from on-disk JSONL files.
This module mirrors the upstream Agent SDK session-history behavior:
it reads ~/.claude/projects/<sanitized-cwd>/<session-id>.jsonl,
reconstructs the canonical conversation chain, and returns history metadata
or visible user/assistant messages.
Summary
Functions
Deletes a transcript and its sibling subagent transcript directory.
Forks a transcript into a new session file.
Looks up metadata for a single CLI transcript session.
Reads visible conversation messages from a CLI transcript.
Reads visible messages from a subagent transcript.
Lists CLI transcript sessions.
Lists subagent IDs for a session.
Appends a custom title entry to a transcript.
Sanitizes a project path to the directory format used by Claude CLI.
Produces the same base-36 hash used by the upstream session-storage logic.
Appends a tag entry to a transcript. Passing nil clears the tag.
Functions
Deletes a transcript and its sibling subagent transcript directory.
@spec fork_session( String.t(), keyword() ) :: ClaudeAgentSDK.Session.ForkResult.t()
Forks a transcript into a new session file.
@spec get_session_info( String.t(), keyword() ) :: ClaudeAgentSDK.Session.SessionInfo.t() | nil
Looks up metadata for a single CLI transcript session.
@spec get_session_messages( String.t(), keyword() ) :: [ClaudeAgentSDK.Session.SessionMessage.t()]
Reads visible conversation messages from a CLI transcript.
Options:
:directory- project path to search in:limit- max number of messages to return:offset- number of messages to skip from the start:projects_dir- override the Claude projects directory (primarily for tests)
@spec get_subagent_messages(String.t(), String.t(), keyword()) :: [ ClaudeAgentSDK.Session.SessionMessage.t() ]
Reads visible messages from a subagent transcript.
@spec list_sessions(keyword()) :: [ClaudeAgentSDK.Session.SessionInfo.t()]
Lists CLI transcript sessions.
Options:
:directory- project path to scan:limit- max number of sessions to return:include_worktrees- include git worktree transcript directories (default:true):projects_dir- override the Claude projects directory (primarily for tests)
Lists subagent IDs for a session.
Appends a custom title entry to a transcript.
Sanitizes a project path to the directory format used by Claude CLI.
Produces the same base-36 hash used by the upstream session-storage logic.
Appends a tag entry to a transcript. Passing nil clears the tag.