Skip to content
3 min read · 669 words

@nhtio/adk/batteries/llm/claude_code_cli

Claude Code CLI battery — the first in the "CLI harness" LLM-battery family, wrapping the claude CLI binary as a DispatchExecutorFn destination.

Remarks

A fundamentally different kind of "model call" than the other bundled LLM batteries: the CLI is itself a complete agent loop (its own tool use, its own context management, its own retry/backoff), not a stateless completion endpoint. Since a subprocess must be spawned anyway, ALL Claude-Code-specific complexity — spawning the real claude binary, hosting an MCP bridge server, translating its stream-json — lives in a dedicated wrapper process shipped as a sibling dist asset; the adapter only ever spawns and drives that wrapper over a small, harness-agnostic protocol (./wire), reusable by future CLI harnesses (Codex CLI, the Pi coding agent).

Key design decisions: history is ADK-owned and each dispatch is a stateless claude --bare -p invocation (no --resume/--session-id reliance); Claude Code's own built-in tools are fully disabled via --tools ""; real ADK tools are bridged into the CLI's tool loop via an injected MCP server, but actual execution always happens on the ADK side via tool.executor(ctx)(args); permissions are bypassed wholesale (--dangerously-skip-permissions) since the bridge itself — not a CLI allow-flag — is what enforces which bridged tools are callable; and there is no client-side contextWindow guard, since --max-budget-usd/--max-turns are the CLI-native substitutes.

References

buildClaudeCodeCliPrompt

Re-exports buildClaudeCodeCliPrompt


ChatCompletionsBucketLabel

Re-exports ChatCompletionsBucketLabel


ChatCompletionsBucketOrder

Re-exports ChatCompletionsBucketOrder


ChatCompletionsRetryConfig

Re-exports ChatCompletionsRetryConfig


ChatCompletionsTool

Re-exports ChatCompletionsTool


ChatHelpersCommon

Re-exports ChatHelpersCommon


ClaudeCodeCliAdapter

Re-exports ClaudeCodeCliAdapter


ClaudeCodeCliAdapterOptions

Re-exports ClaudeCodeCliAdapterOptions


ClaudeCodeCliExtraArg

Re-exports ClaudeCodeCliExtraArg


ClaudeCodeCliHelpers

Re-exports ClaudeCodeCliHelpers


claudeCodeCliOptionsSchema

Re-exports claudeCodeCliOptionsSchema


defaultBuildClaudeCodeCliPrompt

Re-exports defaultBuildClaudeCodeCliPrompt


defaultDescriptionToChatCompletionsJsonSchema

Re-exports defaultDescriptionToChatCompletionsJsonSchema


defaultFilterThoughts

Re-exports defaultFilterThoughts


defaultRenderArtifactHandleBody

Re-exports defaultRenderArtifactHandleBody


defaultRenderChatCompletionsSystemPrompt

Re-exports defaultRenderChatCompletionsSystemPrompt


defaultRenderClaudeCodeCliTimelineMessage

Re-exports defaultRenderClaudeCodeCliTimelineMessage


defaultRenderClaudeCodeCliToolCallResult

Re-exports defaultRenderClaudeCodeCliToolCallResult


defaultRenderFirstPartyRetrievables

Re-exports defaultRenderFirstPartyRetrievables


defaultRenderMemories

Re-exports defaultRenderMemories


defaultRenderRetrievableHandleBody

Re-exports defaultRenderRetrievableHandleBody


defaultRenderRetrievables

Re-exports defaultRenderRetrievables


defaultRenderRetrievableSafetyDirective

Re-exports defaultRenderRetrievableSafetyDirective


defaultRenderStandingInstructions

Re-exports defaultRenderStandingInstructions


defaultRenderThirdPartyPrivateRetrievables

Re-exports defaultRenderThirdPartyPrivateRetrievables


defaultRenderThirdPartyPublicRetrievables

Re-exports defaultRenderThirdPartyPublicRetrievables


defaultRenderThought

Re-exports defaultRenderThought


defaultRenderTrustedContent

Re-exports defaultRenderTrustedContent


defaultRenderUntrustedContent

Re-exports defaultRenderUntrustedContent


defaultToolsToChatCompletionsTools

Re-exports defaultToolsToChatCompletionsTools


DescriptionLike

Re-exports DescriptionLike


descriptionToChatCompletionsJsonSchema

Re-exports descriptionToChatCompletionsJsonSchema


E_CLAUDE_CODE_CLI_BINARY_NOT_FOUND

Re-exports E_CLAUDE_CODE_CLI_BINARY_NOT_FOUND


E_CLAUDE_CODE_CLI_MCP_BRIDGE_STARTUP_FAILED

Re-exports E_CLAUDE_CODE_CLI_MCP_BRIDGE_STARTUP_FAILED


E_CLAUDE_CODE_CLI_PROCESS_EXITED_NONZERO

Re-exports E_CLAUDE_CODE_CLI_PROCESS_EXITED_NONZERO


E_CLAUDE_CODE_CLI_STARTUP_TIMEOUT

Re-exports E_CLAUDE_CODE_CLI_STARTUP_TIMEOUT


E_CLAUDE_CODE_CLI_STREAM_ERROR

Re-exports E_CLAUDE_CODE_CLI_STREAM_ERROR


E_CLAUDE_CODE_CLI_STREAM_STALLED

Re-exports E_CLAUDE_CODE_CLI_STREAM_STALLED


E_CLAUDE_CODE_CLI_TURN_FAILED

Re-exports E_CLAUDE_CODE_CLI_TURN_FAILED


E_CLAUDE_CODE_CLI_UNSUPPORTED_MEDIA_MODALITY

Re-exports E_CLAUDE_CODE_CLI_UNSUPPORTED_MEDIA_MODALITY


E_CLAUDE_CODE_CLI_WRAPPER_CRASHED

Re-exports E_CLAUDE_CODE_CLI_WRAPPER_CRASHED


E_CLAUDE_CODE_CLI_WRAPPER_SPAWN_ERROR

Re-exports E_CLAUDE_CODE_CLI_WRAPPER_SPAWN_ERROR


E_INVALID_CLAUDE_CODE_CLI_OPTIONS

Re-exports E_INVALID_CLAUDE_CODE_CLI_OPTIONS


ExecaLike

Re-exports ExecaLike


ExecaResolver

Re-exports ExecaResolver


filterThoughts

Re-exports filterThoughts


JsonSchema

Re-exports JsonSchema


MemoryAttrs

Re-exports MemoryAttrs


renderArtifactHandleBody

Re-exports renderArtifactHandleBody


renderChatCompletionsSystemPrompt

Re-exports renderChatCompletionsSystemPrompt


renderClaudeCodeCliTimelineMessage

Re-exports renderClaudeCodeCliTimelineMessage


renderClaudeCodeCliToolCallResult

Re-exports renderClaudeCodeCliToolCallResult


renderFirstPartyRetrievables

Re-exports renderFirstPartyRetrievables


renderMemories

Re-exports renderMemories


renderRetrievableHandleBody

Re-exports renderRetrievableHandleBody


renderRetrievables

Re-exports renderRetrievables


renderRetrievableSafetyDirective

Re-exports renderRetrievableSafetyDirective


renderStandingInstructions

Re-exports renderStandingInstructions


renderThirdPartyPrivateRetrievables

Re-exports renderThirdPartyPrivateRetrievables


renderThirdPartyPublicRetrievables

Re-exports renderThirdPartyPublicRetrievables


renderThought

Re-exports renderThought


renderTrustedContent

Re-exports renderTrustedContent


renderUntrustedContent

Re-exports renderUntrustedContent


resolveDefaultWrapperPath

Re-exports resolveDefaultWrapperPath


RetrievableAttrs

Re-exports RetrievableAttrs


StandingInstructionAttrs

Re-exports StandingInstructionAttrs


ThoughtAttrs

Re-exports ThoughtAttrs


toolsToChatCompletionsTools

Re-exports toolsToChatCompletionsTools


TrustedContentAttrs

Re-exports TrustedContentAttrs


UnsupportedMediaPolicy

Re-exports UnsupportedMediaPolicy


UntrustedContentAttrs

Re-exports UntrustedContentAttrs


validateOptions

Re-exports validateOptions


WrapperAuth

Re-exports WrapperAuth


WrapperBridgedTool

Re-exports WrapperBridgedTool


WrapperCommand

Re-exports WrapperCommand


WrapperErrorEvent

Re-exports WrapperErrorEvent


WrapperEvent

Re-exports WrapperEvent


WrapperInitEvent

Re-exports WrapperInitEvent


WrapperLogEvent

Re-exports WrapperLogEvent


WrapperMessageDeltaEvent

Re-exports WrapperMessageDeltaEvent


WrapperReadyEvent

Re-exports WrapperReadyEvent


WrapperResultEvent

Re-exports WrapperResultEvent


WrapperRetryEvent

Re-exports WrapperRetryEvent


WrapperRunCommand

Re-exports WrapperRunCommand


WrapperShutdownCommand

Re-exports WrapperShutdownCommand


WrapperShutdownCompleteEvent

Re-exports WrapperShutdownCompleteEvent


WrapperThoughtDeltaEvent

Re-exports WrapperThoughtDeltaEvent


WrapperToolCallRequestEvent

Re-exports WrapperToolCallRequestEvent


WrapperToolCallResponseCommand

Re-exports WrapperToolCallResponseCommand


WrapperToolResultContentBlock

Re-exports WrapperToolResultContentBlock