# `ExMCP.ACP.Adapters.ClaudeSDK.SessionStore`
[🔗](https://github.com/azmaveth/ex_mcp/blob/v1.4.0/lib/ex_mcp/acp/adapters/claude_sdk/session_store.ex#L1)

Pure helpers for Claude Code's SDK session store.

Claude Code persists conversations as JSONL files under
`CLAUDE_CONFIG_DIR/projects/<project-key>`. The project key and metadata
extraction in this module intentionally follow the official Claude Agent SDK
helpers so the ACP adapter can expose `session/list` and `session/delete`
without shelling out to Node.

# `opts`

```elixir
@type opts() :: keyword() | map()
```

# `config_dir`

```elixir
@spec config_dir(opts()) :: String.t()
```

Resolves the Claude config directory from adapter options, environment, or
`~/.claude`.

# `delete_session`

```elixir
@spec delete_session(String.t(), opts()) :: :ok | {:error, term()}
```

Deletes a persisted Claude session by UUID.

When `:cwd` or `:dir` is supplied, deletion is restricted to that project and
its worktrees. Without a cwd, all project directories under the configured
Claude store are searched.

# `fork_session`

```elixir
@spec fork_session(String.t(), opts()) :: {:ok, String.t()} | {:error, term()}
```

Copies a persisted session transcript to a new Claude session UUID.

This implements ACP `session/fork` for the disk-backed SDK store. The copied
transcript is rewritten with the new session id where common Claude JSONL id
fields are present, while message UUIDs are preserved so clients can still
refer to replayed history.

# `list_acp_sessions`

```elixir
@spec list_acp_sessions(opts()) :: {:ok, [map()]} | {:error, term()}
```

Returns ACP `SessionInfo` maps for Claude Code sessions.

# `list_sessions`

```elixir
@spec list_sessions(opts()) :: {:ok, [map()]} | {:error, term()}
```

Returns SDK-shaped metadata for sessions visible from the given options.

Supported options:

- `:claude_config_dir` - explicit Claude config directory
- `:env` - environment map or keyword list, checked for `CLAUDE_CONFIG_DIR`
- `:cwd` / `:dir` - restrict sessions to the matching project directory
- `:include_worktrees` - include Git worktrees for the requested cwd, default `true`
- `:offset` / `:limit` - optional in-memory pagination

# `project_key`

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

Returns the official SDK project key for a cwd.

# `read_session_messages`

```elixir
@spec read_session_messages(String.t(), opts()) :: {:ok, [map()]} | {:error, term()}
```

Reads decoded JSONL transcript entries for a persisted session.

---

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