Overview
The Claude Code bridge wraps Anthropic’sclaude CLI, providing access to Claude’s code-generation and reasoning capabilities through Agent-Ctrl’s unified API. Claude Code is a strong default choice for general coding workflows, tool-heavy tasks, and scenarios where you want fine-grained control over the agent’s system prompt and permission behavior.
The bridge is implemented by ClaudeCodeBridge and configured through ClaudeCodeBridgeBuilder. Access the builder through the AgentCtrl facade:
Basic Usage
The simplest Claude Code interaction requires just a prompt:System Prompts
Claude Code supports two complementary approaches to system prompt configuration, giving you precise control over the agent’s behavior.Replacing the System Prompt
UsewithSystemPrompt() to completely replace the default system prompt with your own. The agent will follow only your instructions, without the built-in Claude Code behavior:
Appending to the System Prompt
UseappendSystemPrompt() to add instructions on top of the default system prompt. This preserves Claude Code’s built-in capabilities (file reading, code editing, command execution) while layering in your project-specific context:
Combining Both Methods
You can use both methods together.withSystemPrompt() sets the base prompt and appendSystemPrompt() adds to it:
Permission Modes
When running Claude Code headlessly (as Agent-Ctrl does), you need to configure how the agent handles tool permission requests. ThePermissionMode enum provides four levels of autonomy:
BypassPermissions because Agent-Ctrl runs the CLI in a non-interactive, headless mode. If you use DefaultMode or Plan without an interactive terminal, the agent will hang waiting for permission responses that never come, eventually timing out.
Turn Limits
Each “turn” represents one cycle where the agent reads context, reasons, and takes an action (such as reading a file, editing code, or running a command). Limiting turns helps control execution time, cost, and scope:Guidelines for Turn Limits
Without a turn limit, Claude Code continues working until it decides the task is complete or the timeout is reached. For predictable behavior, combine
withMaxTurns() with withTimeout().
Additional Directories
By default, the agent operates within the working directory set byinDirectory(). Use withAdditionalDirs() to grant access to additional directories, such as shared libraries, configuration repositories, or reference codebases:
Verbose Mode
Theverbose() method controls whether Claude Code emits detailed output. Verbose mode is enabled by default and is required for proper JSON stream parsing. In most cases, you should leave this at its default value:
Streaming with Claude Code
Claude Code streams output as JSON Lines containing message events, system events, error events, and result events. The bridge parses these in real time and delivers them through the standard streaming callbacks:Event Normalization
During streaming, Claude Code emits several types of events that are normalized into the callback API:- Text content from
MessageEventmessages (typetext) is delivered throughonText()with the text string. - Tool use from
MessageEventmessages (typetool_use) is delivered throughonToolUse()with the tool name, input parameters, and call ID. - Tool results from
MessageEventmessages (typetool_result) are delivered throughonToolUse()withtoolset to'tool_result', the tool use ID in the input array, and the result content as output. - Error events are delivered through
onError()with the error message.
Session Management
Claude Code session IDs are extracted from thesession_id field in the stream JSON output. Use them to maintain conversational context across multiple executions:
Data Availability
Not all data points are available from every agent. Claude Code’s current JSON output format has the following coverage:
If you need token usage and cost tracking, consider using OpenCode with an Anthropic model, which provides both.