# strawberryforme/claude_code_cli architecture

> Architecture diagram of the GitHub repository strawberryforme/claude_code_cli, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/strawberryforme/claude_code_cli
- Repository: https://github.com/strawberryforme/claude_code_cli

## Overview

Claude Code is a terminal-based assistant for working with code: users submit prompts and invoke slash commands, while the query engine coordinates model interaction and session persistence. The repository also includes IDE/remote bridge capabilities, MCP and other service integrations, permission handling, and an MCP server for exploring the source tree. The graph focuses on runtime product components; some major subsystems are documented in the README but lack sampled implementation excerpts, so their unverified connections are omitted.

Main entry points: [`src/QueryEngine.ts`](https://github.com/strawberryforme/claude_code_cli/blob/main/src/QueryEngine.ts) (Query engine), [`mcp-server/src/server.ts`](https://github.com/strawberryforme/claude_code_cli/blob/main/mcp-server/src/server.ts) (Explorer server), [`src/Tool.ts`](https://github.com/strawberryforme/claude_code_cli/blob/main/src/Tool.ts) (Tool contracts), [`src/commands.ts`](https://github.com/strawberryforme/claude_code_cli/blob/main/src/commands.ts) (Command registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["CLI interaction"]
  node_command_registry["Command registry<br/>[commands.ts]"]
  node_terminal_ui["Terminal UI<br/>[App.tsx]"]
  node_command_handlers["Slash commands"]
end

subgraph group_execution["Assistant execution"]
  node_query_engine["Query engine<br/>[QueryEngine.ts]"]
  node_query_pipeline["Query pipeline<br/>[query.ts]"]
  node_tool_contracts["Tool contracts<br/>[Tool.ts]"]
  node_runtime_state["Runtime state<br/>[state.ts]"]
  node_session_storage[("Session storage<br/>[sessionStorage.ts]")]
  node_portable_session_io["Portable session I/O"]
  node_permission_handler["Permission handling"]
end

subgraph group_integrations["Integrations"]
  node_mcp_connections["MCP connections"]
  node_plugin_manager["Plugin manager"]
  node_ide_bridge["IDE bridge"]
  node_remote_sessions["Remote sessions"]
end

subgraph group_explorer["Source explorer"]
  node_explorer_client(("MCP client"))
  node_explorer_server["Explorer server<br/>[server.ts]"]
end

node_terminal_user(("Terminal user"))

node_terminal_user -->|"uses"| node_terminal_ui
node_command_registry -->|"registers"| node_command_handlers
node_query_engine -->|"calls"| node_query_pipeline
node_query_engine -->|"flushes"| node_session_storage
node_query_engine -->|"uses"| node_tool_contracts
node_terminal_ui -->|"reads"| node_runtime_state
node_session_storage -->|"reads transcripts"| node_portable_session_io
node_permission_handler -->|"handles tool permissions"| node_tool_contracts
node_explorer_client -->|"requests source exploration"| node_explorer_server
node_explorer_server -->|"lists commands"| node_command_registry
node_explorer_server -->|"lists tools"| node_tool_contracts

click node_command_registry "https://github.com/strawberryforme/claude_code_cli/blob/main/src/commands.ts"
click node_terminal_ui "https://github.com/strawberryforme/claude_code_cli/blob/main/src/ink/components/App.tsx"
click node_command_handlers "https://github.com/strawberryforme/claude_code_cli/tree/main/src/commands"
click node_query_engine "https://github.com/strawberryforme/claude_code_cli/blob/main/src/QueryEngine.ts"
click node_query_pipeline "https://github.com/strawberryforme/claude_code_cli/blob/main/src/query.ts"
click node_tool_contracts "https://github.com/strawberryforme/claude_code_cli/blob/main/src/Tool.ts"
click node_runtime_state "https://github.com/strawberryforme/claude_code_cli/blob/main/src/bootstrap/state.ts"
click node_session_storage "https://github.com/strawberryforme/claude_code_cli/blob/main/src/utils/sessionStorage.ts"
click node_portable_session_io "https://github.com/strawberryforme/claude_code_cli/blob/main/src/utils/sessionStoragePortable.ts"
click node_permission_handler "https://github.com/strawberryforme/claude_code_cli/blob/main/src/components/permissions/FilePermissionDialog/usePermissionHandler.ts"
click node_mcp_connections "https://github.com/strawberryforme/claude_code_cli/blob/main/src/services/mcp/MCPConnectionManager.tsx"
click node_plugin_manager "https://github.com/strawberryforme/claude_code_cli/blob/main/src/services/plugins/PluginInstallationManager.ts"
click node_ide_bridge "https://github.com/strawberryforme/claude_code_cli/tree/main/src/bridge"
click node_remote_sessions "https://github.com/strawberryforme/claude_code_cli/blob/main/src/remote/RemoteSessionManager.ts"
click node_explorer_server "https://github.com/strawberryforme/claude_code_cli/blob/main/mcp-server/src/server.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_command_registry,node_terminal_ui,node_command_handlers,node_terminal_user toneBlue
class node_query_engine,node_query_pipeline,node_tool_contracts,node_runtime_state,node_session_storage,node_portable_session_io,node_permission_handler toneAmber
class node_mcp_connections,node_plugin_manager,node_ide_bridge,node_remote_sessions toneMint
class node_explorer_client,node_explorer_server toneRose
```

## Components

### CLI interaction

- [Command registry](https://github.com/strawberryforme/claude_code_cli/blob/main/src/commands.ts): `src/commands.ts`
- [Terminal UI](https://github.com/strawberryforme/claude_code_cli/blob/main/src/ink/components/App.tsx): `src/ink/components/App.tsx`
- [Slash commands](https://github.com/strawberryforme/claude_code_cli/tree/main/src/commands): `src/commands`

### Assistant execution

- [Query engine](https://github.com/strawberryforme/claude_code_cli/blob/main/src/QueryEngine.ts): `src/QueryEngine.ts`
- [Query pipeline](https://github.com/strawberryforme/claude_code_cli/blob/main/src/query.ts): `src/query.ts`
- [Tool contracts](https://github.com/strawberryforme/claude_code_cli/blob/main/src/Tool.ts): `src/Tool.ts`
- [Runtime state](https://github.com/strawberryforme/claude_code_cli/blob/main/src/bootstrap/state.ts): `src/bootstrap/state.ts`
- [Session storage](https://github.com/strawberryforme/claude_code_cli/blob/main/src/utils/sessionStorage.ts): `src/utils/sessionStorage.ts`
- [Portable session I/O](https://github.com/strawberryforme/claude_code_cli/blob/main/src/utils/sessionStoragePortable.ts): `src/utils/sessionStoragePortable.ts`
- [Permission handling](https://github.com/strawberryforme/claude_code_cli/blob/main/src/components/permissions/FilePermissionDialog/usePermissionHandler.ts): `src/components/permissions/FilePermissionDialog/usePermissionHandler.ts`

### Integrations

- [MCP connections](https://github.com/strawberryforme/claude_code_cli/blob/main/src/services/mcp/MCPConnectionManager.tsx): `src/services/mcp/MCPConnectionManager.tsx`
- [Plugin manager](https://github.com/strawberryforme/claude_code_cli/blob/main/src/services/plugins/PluginInstallationManager.ts): `src/services/plugins/PluginInstallationManager.ts`
- [IDE bridge](https://github.com/strawberryforme/claude_code_cli/tree/main/src/bridge): `src/bridge`
- [Remote sessions](https://github.com/strawberryforme/claude_code_cli/blob/main/src/remote/RemoteSessionManager.ts): `src/remote/RemoteSessionManager.ts`

### Source explorer

- **MCP client**
- [Explorer server](https://github.com/strawberryforme/claude_code_cli/blob/main/mcp-server/src/server.ts): `mcp-server/src/server.ts`

### Other components

- **Terminal user**

## Connections

- Terminal user → Terminal UI: uses (evidence: `README.md`)
- Command registry → Slash commands: registers (evidence: `src/commands.ts`)
- Query engine → Query pipeline: calls (evidence: `src/QueryEngine.ts`)
- Query engine → Session storage: flushes (evidence: `src/QueryEngine.ts`)
- Query engine → Tool contracts: uses (evidence: `src/QueryEngine.ts`)
- Terminal UI → Runtime state: reads (evidence: `src/ink/components/App.tsx`)
- Session storage → Portable session I/O: reads transcripts (evidence: `src/utils/sessionStorage.ts`)
- Permission handling → Tool contracts: handles tool permissions (evidence: `src/components/permissions/FilePermissionDialog/usePermissionHandler.ts`)
- MCP client → Explorer server: requests source exploration (evidence: `README.md`)
- Explorer server → Command registry: lists commands (evidence: `README.md`)
- Explorer server → Tool contracts: lists tools (evidence: `README.md`)
