ClaudeCode

works.iterative.claude.zio.ClaudeCode
object ClaudeCode

Entry point for querying the Claude Code CLI with ZIO.

query streams messages as the CLI produces them; querySync and queryResult are convenience collectors. session opens a scoped multi-turn conversation. All operations fail with a typed CLIError.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
ClaudeCode.type

Members list

Value members

Concrete methods

def ask(prompt: String): IO[CLIError, String]

Ask Claude a question with sane defaults, returning the assistant's text.

Ask Claude a question with sane defaults, returning the assistant's text.

Attributes

def query(options: QueryOptions, archive: Custody = ...): ZStream[Any, CLIError, Message]

Execute a query and stream messages from the Claude CLI as they arrive.

Execute a query and stream messages from the Claude CLI as they arrive.

Unless archive is Custody.Off, the transcript the run leaves behind is kept once the stream is finished with, for the installation the CLI ran under (see works.iterative.claude.core.log.Installation.resolve), under the default custody root or the one archive names — best-effort, so a failed keep is logged and never breaks the query. The session kept is the one the run reported in its result, falling back to the resumed id when the run died before reporting one (see QueryCustody). Finishing the stream waits for that keep, bounded by works.iterative.claude.zio.internal.cli.SessionArchiveHook.CloseMirrorTimeout — the same bound closing a session waits under.

Attributes

def queryResult(options: QueryOptions): IO[CLIError, String]

Execute a query and extract the assistant's text result.

Execute a query and extract the assistant's text result.

Attributes

def querySync(options: QueryOptions): IO[CLIError, List[Message]]

Execute a query and collect all messages into a list.

Execute a query and collect all messages into a list.

Attributes

def session(options: SessionOptions, archive: Custody = ..., eventsBufferSize: Int = ...): ZIO[Scope, CLIError, Session]

Open a scoped session backed by a long-lived CLI process.

Open a scoped session backed by a long-lived CLI process.

Unless archive is Custody.Off, the session keeps its vendor transcript tree after each real result and on close, for the installation the CLI runs under, under the default custody root or the one archive names — best-effort, so a failed keep is logged and never breaks the session. Closing the session waits for the final keep, bounded by works.iterative.claude.zio.internal.cli.SessionArchiveHook.CloseMirrorTimeout (after which it logs a warning and moves on). eventsBufferSize sizes the lossy events Hub (see Session.events); the default is conservative.

Attributes