# koushikbaagh/claude-code-leak architecture

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

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

## Overview

Claude Code is a terminal-based AI software-engineering assistant. The principal workflow is a user prompt entering the terminal UI, being prepared and sent through the query engine, then producing tool activity and a response; tool permissions gate user approval. Slash commands provide a separate route for session, configuration, and workflow management. The README also documents IDE bridging, persistent sessions, MCP, agents, skills, and task management. Some of these implementations are not present in the supplied tree or sampled excerpts, so their links are limited to documented capabilities and supported paths.

Main entry points: [`src/QueryEngine.ts`](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/QueryEngine.ts) (Query engine), [`src/commands.ts`](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/commands.ts) (Command registry), [`src/components/App.tsx`](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/components/App.tsx) (Terminal app), [`src/components/permissions/FilePermissionDialog/usePermissionHandler.ts`](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/components/permissions/FilePermissionDialog/usePermissionHandler.ts) (Permission dialog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Terminal interaction"]
  node_app["Terminal app<br/>[App.tsx]"]
  node_prompt["Prompt input<br/>[PromptInput.tsx]"]
  node_permission["Permission dialog"]
end

subgraph group_agent["Agent runtime"]
  node_query["Query engine<br/>[QueryEngine.ts]"]
  node_tooltypes["Tool contracts<br/>[Tool.ts]"]
  node_transcript[("Session transcripts<br/>[sessionStorage.ts]")]
  node_portable["Portable session reads"]
end

subgraph group_workflow["Commands and workflows"]
  node_commands["Command registry<br/>[commands.ts]"]
  node_sessionhistory["Session history<br/>[sessionHistory.ts]"]
  node_taskcommands["Task management<br/>[tasks.tsx]"]
  node_memorycommands["Persistent memory<br/>[memory.tsx]"]
end

subgraph group_integration["External integrations"]
  node_pluginoptions["Plugin options"]
  node_securestorage[("Secure credentials")]
  node_keychain["macOS Keychain"]
  node_bridge["IDE bridge<br/>[bridgeMain.ts]"]
end

node_user(("Terminal user"))
node_ide(("IDE extension"))
node_anthropic(("Anthropic API"))
node_workspace[("Project workspace")]
node_mcp(("MCP servers"))
node_toolapproval(("User approval"))

node_user -->|"uses"| node_app
node_app -->|"renders"| node_prompt
node_app -->|"dispatches"| node_commands
node_prompt -->|"submits prompt"| node_query
node_query -->|"sends query"| node_anthropic
node_query -->|"uses contracts"| node_tooltypes
node_query -->|"requests approval"| node_permission
node_permission -->|"prompts"| node_toolapproval
node_permission -->|"allows or rejects"| node_query
node_query -->|"tool effects"| node_workspace
node_query -->|"flushes session"| node_transcript
node_transcript -->|"uses reader"| node_portable
node_sessionhistory -->|"loads sessions"| node_transcript
node_commands -->|"dispatches"| node_taskcommands
node_commands -->|"dispatches"| node_memorycommands
node_commands -->|"configures plugins"| node_pluginoptions
node_pluginoptions -->|"stores secrets"| node_securestorage
node_securestorage -.->|"uses on macOS"| node_keychain
node_bridge -->|"exchanges messages"| node_ide
node_bridge -->|"runs sessions"| node_query
node_query -.->|"invokes tools"| node_mcp

click node_app "https://github.com/koushikbaagh/claude-code-leak/blob/main/src/components/App.tsx"
click node_prompt "https://github.com/koushikbaagh/claude-code-leak/blob/main/src/components/PromptInput/PromptInput.tsx"
click node_commands "https://github.com/koushikbaagh/claude-code-leak/blob/main/src/commands.ts"
click node_query "https://github.com/koushikbaagh/claude-code-leak/blob/main/src/QueryEngine.ts"
click node_tooltypes "https://github.com/koushikbaagh/claude-code-leak/blob/main/src/Tool.ts"
click node_permission "https://github.com/koushikbaagh/claude-code-leak/blob/main/src/components/permissions/FilePermissionDialog/usePermissionHandler.ts"
click node_transcript "https://github.com/koushikbaagh/claude-code-leak/blob/main/src/utils/sessionStorage.ts"
click node_portable "https://github.com/koushikbaagh/claude-code-leak/blob/main/src/utils/sessionStoragePortable.ts"
click node_sessionhistory "https://github.com/koushikbaagh/claude-code-leak/blob/main/src/assistant/sessionHistory.ts"
click node_taskcommands "https://github.com/koushikbaagh/claude-code-leak/blob/main/src/commands/tasks/tasks.tsx"
click node_memorycommands "https://github.com/koushikbaagh/claude-code-leak/blob/main/src/commands/memory/memory.tsx"
click node_pluginoptions "https://github.com/koushikbaagh/claude-code-leak/blob/main/src/utils/plugins/pluginOptionsStorage.ts"
click node_securestorage "https://github.com/koushikbaagh/claude-code-leak/blob/main/src/utils/secureStorage/plainTextStorage.ts"
click node_keychain "https://github.com/koushikbaagh/claude-code-leak/blob/main/src/utils/secureStorage/macOsKeychainStorage.ts"
click node_bridge "https://github.com/koushikbaagh/claude-code-leak/blob/main/src/bridge/bridgeMain.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_app,node_prompt,node_permission,node_user,node_toolapproval toneBlue
class node_query,node_tooltypes,node_transcript,node_portable,node_workspace toneAmber
class node_commands,node_sessionhistory,node_taskcommands,node_memorycommands,node_anthropic,node_mcp toneMint
class node_pluginoptions,node_securestorage,node_keychain,node_bridge toneRose
class node_ide toneIndigo
```

## Components

### Terminal interaction

- [Terminal app](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/components/App.tsx): `src/components/App.tsx`
- [Prompt input](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/components/PromptInput/PromptInput.tsx): `src/components/PromptInput/PromptInput.tsx`
- [Permission dialog](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/components/permissions/FilePermissionDialog/usePermissionHandler.ts): `src/components/permissions/FilePermissionDialog/usePermissionHandler.ts`

### Agent runtime

- [Query engine](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/QueryEngine.ts): `src/QueryEngine.ts`
- [Tool contracts](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/Tool.ts): `src/Tool.ts`
- [Session transcripts](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/utils/sessionStorage.ts): `src/utils/sessionStorage.ts`
- [Portable session reads](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/utils/sessionStoragePortable.ts): `src/utils/sessionStoragePortable.ts`

### Commands and workflows

- [Command registry](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/commands.ts): `src/commands.ts`
- [Session history](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/assistant/sessionHistory.ts): `src/assistant/sessionHistory.ts`
- [Task management](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/commands/tasks/tasks.tsx): `src/commands/tasks/tasks.tsx`
- [Persistent memory](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/commands/memory/memory.tsx): `src/commands/memory/memory.tsx`

### External integrations

- [Plugin options](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/utils/plugins/pluginOptionsStorage.ts): `src/utils/plugins/pluginOptionsStorage.ts`
- [Secure credentials](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/utils/secureStorage/plainTextStorage.ts): `src/utils/secureStorage/plainTextStorage.ts`
- [macOS Keychain](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/utils/secureStorage/macOsKeychainStorage.ts): `src/utils/secureStorage/macOsKeychainStorage.ts`
- [IDE bridge](https://github.com/koushikbaagh/claude-code-leak/blob/main/src/bridge/bridgeMain.ts): `src/bridge/bridgeMain.ts`

### Other components

- **Terminal user**
- **IDE extension**
- **Anthropic API**
- **Project workspace**
- **MCP servers**
- **User approval**

## Connections

- Terminal user → Terminal app: uses
- Terminal app → Prompt input: renders
- Terminal app → Command registry: dispatches
- Prompt input → Query engine: submits prompt
- Query engine → Anthropic API: sends query
- Query engine → Tool contracts: uses contracts
- Query engine → Permission dialog: requests approval
- Permission dialog → User approval: prompts
- Permission dialog → Query engine: allows or rejects
- Query engine → Project workspace: tool effects
- Query engine → Session transcripts: flushes session
- Session transcripts → Portable session reads: uses reader
- Session history → Session transcripts: loads sessions
- Command registry → Task management: dispatches
- Command registry → Persistent memory: dispatches
- Command registry → Plugin options: configures plugins
- Plugin options → Secure credentials: stores secrets
- Secure credentials → macOS Keychain: uses on macOS
- IDE bridge → IDE extension: exchanges messages
- IDE bridge → Query engine: runs sessions
- Query engine → MCP servers: invokes tools
