# chuhuan88/claude-code architecture

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

- Interactive diagram: https://gitdiagram.com/chuhuan88/claude-code
- Repository: https://github.com/chuhuan88/claude-code

## Overview

Claude Code is a terminal-based AI coding assistant. The principal workflow is a user submitting a prompt in the terminal, the assistant processing it through its query engine, and registered tools carrying out coding or other tasks subject to permissions; results return in the terminal. The repository also includes multi-agent work, MCP and plugin integrations, remote sessions, memory, and optional BUDDY and KAIROS features. The README documents these capabilities, but the supplied source excerpts do not establish all runtime call paths, so uncertain links are omitted.

Main entry points: [`Tool.ts`](https://github.com/chuhuan88/claude-code/blob/main/Tool.ts) (Tool framework), [`QueryEngine.ts`](https://github.com/chuhuan88/claude-code/blob/main/QueryEngine.ts) (Query engine), [`ink/components/App.tsx`](https://github.com/chuhuan88/claude-code/blob/main/ink/components/App.tsx) (Ink terminal UI), [`services/mcp/MCPConnectionManager.tsx`](https://github.com/chuhuan88/claude-code/blob/main/services/mcp/MCPConnectionManager.tsx) (MCP connections)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Terminal interaction"]
  node_terminal["Ink terminal UI<br/>[App.tsx]"]
  node_commands["CLI commands<br/>[commands.ts]"]
end

subgraph group_execution["Assistant execution"]
  node_query["Query engine<br/>[QueryEngine.ts]"]
  node_tools["Tool framework<br/>[Tool.ts]"]
  node_permissions["Permission controls"]
  node_agents["Agent tools"]
  node_session["Session state<br/>[state.ts]"]
  node_transcripts[("Session storage<br/>[sessionStorage.ts]")]
  node_settings[("Settings<br/>[settings.ts]")]
end

subgraph group_integrations["Integrations and remote"]
  node_mcp["MCP connections"]
  node_plugins["Plugin management"]
  node_remote["Remote sessions"]
  node_bridge["Bridge sessions<br/>[bridgeMain.ts]"]
  node_lsp["Language servers"]
end

subgraph group_features["Additional capabilities"]
  node_memory["Memory commands<br/>[memory.tsx]"]
  node_buddy["BUDDY companion<br/>[companion.ts]"]
  node_kairos["KAIROS history<br/>[sessionHistory.ts]"]
  node_ultraplan["Remote planning<br/>[ultraplan.tsx]"]
end

node_user(("User"))

node_user -->|"enters prompts"| node_terminal
node_terminal -->|"invokes commands"| node_commands
node_query -->|"uses framework"| node_tools
node_tools -.->|"permission checks"| node_permissions
node_tools -.->|"coordinates agents"| node_agents
node_session -->|"session data"| node_transcripts
node_mcp -.->|"provides tools"| node_tools
node_plugins -->|"stores options"| node_settings
node_remote -.->|"remote execution"| node_bridge
node_user -->|"manages memory"| node_memory
node_user -->|"interacts with"| node_buddy
node_kairos -->|"proactive updates"| node_user
node_user -->|"requests planning"| node_ultraplan
node_user -->|"configures servers"| node_mcp
node_user -->|"manages plugins"| node_plugins
node_query -.->|"remote planning"| node_remote

click node_terminal "https://github.com/chuhuan88/claude-code/blob/main/ink/components/App.tsx"
click node_commands "https://github.com/chuhuan88/claude-code/blob/main/commands.ts"
click node_query "https://github.com/chuhuan88/claude-code/blob/main/QueryEngine.ts"
click node_tools "https://github.com/chuhuan88/claude-code/blob/main/Tool.ts"
click node_permissions "https://github.com/chuhuan88/claude-code/blob/main/components/permissions/PermissionDialog.tsx"
click node_agents "https://github.com/chuhuan88/claude-code/blob/main/tools/AgentTool/agentColorManager.ts"
click node_session "https://github.com/chuhuan88/claude-code/blob/main/bootstrap/state.ts"
click node_transcripts "https://github.com/chuhuan88/claude-code/blob/main/utils/sessionStorage.ts"
click node_settings "https://github.com/chuhuan88/claude-code/blob/main/utils/settings/settings.ts"
click node_mcp "https://github.com/chuhuan88/claude-code/blob/main/services/mcp/MCPConnectionManager.tsx"
click node_plugins "https://github.com/chuhuan88/claude-code/blob/main/services/plugins/PluginInstallationManager.ts"
click node_remote "https://github.com/chuhuan88/claude-code/blob/main/remote/RemoteSessionManager.ts"
click node_bridge "https://github.com/chuhuan88/claude-code/blob/main/bridge/bridgeMain.ts"
click node_lsp "https://github.com/chuhuan88/claude-code/blob/main/services/lsp/LSPServerManager.ts"
click node_memory "https://github.com/chuhuan88/claude-code/blob/main/commands/memory/memory.tsx"
click node_buddy "https://github.com/chuhuan88/claude-code/blob/main/buddy/companion.ts"
click node_kairos "https://github.com/chuhuan88/claude-code/blob/main/assistant/sessionHistory.ts"
click node_ultraplan "https://github.com/chuhuan88/claude-code/blob/main/commands/ultraplan.tsx"

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_terminal,node_commands,node_user toneBlue
class node_query,node_tools,node_permissions,node_agents,node_session,node_transcripts,node_settings toneAmber
class node_mcp,node_plugins,node_remote,node_bridge,node_lsp toneMint
class node_memory,node_buddy,node_kairos,node_ultraplan toneRose
```

## Components

### Terminal interaction

- [Ink terminal UI](https://github.com/chuhuan88/claude-code/blob/main/ink/components/App.tsx): `ink/components/App.tsx`
- [CLI commands](https://github.com/chuhuan88/claude-code/blob/main/commands.ts): `commands.ts`

### Assistant execution

- [Query engine](https://github.com/chuhuan88/claude-code/blob/main/QueryEngine.ts): `QueryEngine.ts`
- [Tool framework](https://github.com/chuhuan88/claude-code/blob/main/Tool.ts): `Tool.ts`
- [Permission controls](https://github.com/chuhuan88/claude-code/blob/main/components/permissions/PermissionDialog.tsx): `components/permissions/PermissionDialog.tsx`
- [Agent tools](https://github.com/chuhuan88/claude-code/blob/main/tools/AgentTool/agentColorManager.ts): `tools/AgentTool/agentColorManager.ts`
- [Session state](https://github.com/chuhuan88/claude-code/blob/main/bootstrap/state.ts): `bootstrap/state.ts`
- [Session storage](https://github.com/chuhuan88/claude-code/blob/main/utils/sessionStorage.ts): `utils/sessionStorage.ts`
- [Settings](https://github.com/chuhuan88/claude-code/blob/main/utils/settings/settings.ts): `utils/settings/settings.ts`

### Integrations and remote

- [MCP connections](https://github.com/chuhuan88/claude-code/blob/main/services/mcp/MCPConnectionManager.tsx): `services/mcp/MCPConnectionManager.tsx`
- [Plugin management](https://github.com/chuhuan88/claude-code/blob/main/services/plugins/PluginInstallationManager.ts): `services/plugins/PluginInstallationManager.ts`
- [Remote sessions](https://github.com/chuhuan88/claude-code/blob/main/remote/RemoteSessionManager.ts): `remote/RemoteSessionManager.ts`
- [Bridge sessions](https://github.com/chuhuan88/claude-code/blob/main/bridge/bridgeMain.ts): `bridge/bridgeMain.ts`
- [Language servers](https://github.com/chuhuan88/claude-code/blob/main/services/lsp/LSPServerManager.ts): `services/lsp/LSPServerManager.ts`

### Additional capabilities

- [Memory commands](https://github.com/chuhuan88/claude-code/blob/main/commands/memory/memory.tsx): `commands/memory/memory.tsx`
- [BUDDY companion](https://github.com/chuhuan88/claude-code/blob/main/buddy/companion.ts): `buddy/companion.ts`
- [KAIROS history](https://github.com/chuhuan88/claude-code/blob/main/assistant/sessionHistory.ts): `assistant/sessionHistory.ts`
- [Remote planning](https://github.com/chuhuan88/claude-code/blob/main/commands/ultraplan.tsx): `commands/ultraplan.tsx`

### Other components

- **User**

## Connections

- User → Ink terminal UI: enters prompts (evidence: `README.md`)
- Ink terminal UI → CLI commands: invokes commands (evidence: `commands.ts`)
- Query engine → Tool framework: uses framework (evidence: `QueryEngine.ts`)
- Tool framework → Permission controls: permission checks
- Tool framework → Agent tools: coordinates agents
- Session state → Session storage: session data (evidence: `utils/sessionStorage.ts`)
- MCP connections → Tool framework: provides tools (evidence: `services/mcp/MCPConnectionManager.tsx`)
- Plugin management → Settings: stores options
- Remote sessions → Bridge sessions: remote execution
- User → Memory commands: manages memory (evidence: `README.md`)
- User → BUDDY companion: interacts with (evidence: `README.md`)
- KAIROS history → User: proactive updates (evidence: `README.md`)
- User → Remote planning: requests planning (evidence: `README.md`)
- User → MCP connections: configures servers (evidence: `README.md`)
- User → Plugin management: manages plugins (evidence: `README.md`)
- Query engine → Remote sessions: remote planning
