# `ClaudeAgentSDK.Session.History`
[🔗](https://github.com/nshkrdotcom/claude_agent_sdk/blob/v0.17.2/lib/claude_agent_sdk/session/history.ex#L1)

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.

# `get_session_messages`

```elixir
@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)

# `list_sessions`

```elixir
@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)

# `sanitize_path`

```elixir
@spec sanitize_path(String.t()) :: String.t()
```

Sanitizes a project path to the directory format used by Claude CLI.

# `simple_hash`

```elixir
@spec simple_hash(String.t()) :: String.t()
```

Produces the same base-36 hash used by the upstream session-storage logic.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
