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:
| Mode | CLI Flag | Behavior |
|---|---|---|
DefaultMode | default | Standard interactive permission prompts. Not suitable for headless execution — prompts cannot be answered. |
Plan | plan | The agent can plan and reason but will prompt before executing any tool. Useful for review workflows where you want to inspect the plan before execution. |
AcceptEdits | acceptEdits | Auto-approve file editing tools (create, write, edit) but prompt for other actions like shell commands. A middle ground between safety and automation. |
BypassPermissions | bypassPermissions | Auto-approve all tool uses without prompting. This is the default for Agent-Ctrl because headless execution cannot respond to permission prompts. |
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
| Task Complexity | Suggested Turns |
|---|---|
| Simple question or summary | 3-5 |
| Single-file edit | 5-10 |
| Multi-file refactoring | 15-30 |
| Complex feature implementation | 30-50 |
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:| Data Point | Available | Notes |
|---|---|---|
| Text output | Yes | Concatenated from all text content blocks |
| Tool calls | Yes | With call IDs, inputs, and results |
| Session ID | Yes | Extracted from session_id field in stream |
| Token usage | No | Claude Code CLI does not expose token counts |
| Cost | No | Claude Code CLI does not expose cost data |
| Parse diagnostics | Yes | Malformed JSON line counts and samples |