Bridge System

Description

The Bridge System is the bidirectional communication layer that connects IDE extensions (VS Code, JetBrains) with the Claude Code CLI process. Rather than building separate agent implementations for each IDE, Anthropic chose to run the same queryengine-ts engine underneath all interfaces, with the bridge abstracting away transport differences. This means the terminal CLI, VS Code extension, and JetBrains plugin all share identical agent logic, tool execution, and permission-pipeline enforcement.

Transport Versions

The bridge has evolved through two transport generations:

Version Transport Characteristics
v1 stdin/stdout JSON-RPC Simple pipe-based protocol; the IDE spawns the CLI as a child process and communicates via newline-delimited JSON on stdio
v2 WebSocket Persistent bidirectional connection; supports reconnection, multiplexed channels, and higher throughput for streaming responses

The active transport version is selected based on the IDE extension's capabilities and is negotiated during the handshake phase. Both versions carry the same message schema, so the upper layers of the system are transport-agnostic.

Authentication

Bridge sessions are authenticated via JWT tokens issued by the IDE extension. The token encodes the user's Anthropic API credentials, workspace context, and permitted scopes. The CLI validates the JWT signature before accepting any bridge commands, preventing unauthorized processes from hijacking an active agent session.

BRIDGE_MODE Flag

When Claude Code detects it is running as a bridge backend (rather than as an interactive terminal), it sets the BRIDGE_MODE environment flag. This flag triggers several behavioral changes:

Bidirectional Messaging

Communication is fully bidirectional. The IDE can send user messages, cancel requests, and push workspace context updates (e.g., active file changed, selection changed). The CLI sends back streaming assistant responses, tool invocation notifications, permission requests, and telemetry events. This two-way flow enables features like inline diff previews in VS Code that would be impossible with a one-way pipe.

Key claims

Relations

Sources

src-20260409-e7da1a492842