# mark3labs/kit architecture

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

- Interactive diagram: https://gitdiagram.com/mark3labs/kit
- Repository: https://github.com/mark3labs/kit

## Overview

KIT is an extensible AI coding-agent CLI and Go SDK. The principal workflow runs a user prompt through the application and agent, which consults a configured model and may execute built-in or MCP tools; the application then presents results and persists conversation history. Major documented branches include interactive and scripted use, ACP clients, extensions, skills and templates, authentication, and local or remote detachable sessions. Some subsystem links below reflect README descriptions because their implementation was not sampled; unsampled internals are not assumed to have verified call paths.

Main entry points: [`cmd/root.go`](https://github.com/mark3labs/kit/blob/master/cmd/root.go) (CLI commands), [`internal/agent/agent.go`](https://github.com/mark3labs/kit/blob/master/internal/agent/agent.go) (Agent loop), [`pkg/kit/kit.go`](https://github.com/mark3labs/kit/blob/master/pkg/kit/kit.go) (Kit SDK), [`internal/app/app.go`](https://github.com/mark3labs/kit/blob/master/internal/app/app.go) (App orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and experience"]
  node_cli["CLI commands<br/>[root.go]"]
  node_app["App orchestration<br/>[app.go]"]
  node_ui["Terminal interface"]
end

subgraph group_agent["Agent runtime"]
  node_agent["Agent loop<br/>[agent.go]"]
  node_kit["Kit SDK<br/>[kit.go]"]
  node_setup["Agent setup<br/>[setup.go]"]
  node_models["Model providers<br/>[providers.go]"]
end

subgraph group_capabilities["Agent capabilities"]
  node_tools["Core coding tools<br/>[tools.go]"]
  node_mcp["MCP integration<br/>[mcp.go]"]
  node_skills["Skills and agents<br/>[skills.go]"]
  node_templates["Prompt templates<br/>[template.go]"]
  node_extensions["Extension system<br/>[api.go]"]
end

subgraph group_integrations["Client integrations"]
  node_auth["Provider authentication<br/>[oauth.go]"]
  node_acp["ACP server<br/>[session.go]"]
end

subgraph group_sessions["Session services"]
  node_daemon["Remote daemon<br/>[server.go]"]
  node_session[("Conversation history<br/>[tree_manager.go]")]
end

node_user(("User"))
node_provider{{"LLM providers"}}
node_mcpservers{{"MCP servers"}}
node_acpclient(("ACP client"))
node_remoteclient(("Remote client"))

node_user -->|"starts"| node_cli
node_cli -.->|"runs prompts"| node_app
node_app -->|"executes turns"| node_kit
node_app -->|"emits events"| node_ui
node_ui -->|"presents results"| node_user
node_kit -.->|"configures agent"| node_setup
node_setup -->|"creates runtime"| node_agent
node_agent -->|"requests completions"| node_models
node_models -.->|"calls"| node_provider
node_agent -->|"dispatches tools"| node_tools
node_agent -.->|"dispatches tools"| node_mcp
node_mcp -.->|"connects"| node_mcpservers
node_kit -.->|"persists history"| node_session
node_cli -.->|"offers capabilities"| node_skills
node_cli -.->|"loads prompts"| node_templates
node_agent -.->|"supports extensions"| node_extensions
node_cli -->|"manages credentials"| node_auth
node_acpclient -->|"drives sessions"| node_acp
node_acp -->|"runs agent"| node_kit
node_acp -->|"adds servers"| node_mcpservers
node_remoteclient -->|"attaches remotely"| node_daemon
node_daemon -.->|"serves sessions"| node_session

click node_cli "https://github.com/mark3labs/kit/blob/master/cmd/root.go"
click node_app "https://github.com/mark3labs/kit/blob/master/internal/app/app.go"
click node_ui "https://github.com/mark3labs/kit/tree/master/internal/ui"
click node_agent "https://github.com/mark3labs/kit/blob/master/internal/agent/agent.go"
click node_kit "https://github.com/mark3labs/kit/blob/master/pkg/kit/kit.go"
click node_setup "https://github.com/mark3labs/kit/blob/master/internal/kitsetup/setup.go"
click node_models "https://github.com/mark3labs/kit/blob/master/internal/models/providers.go"
click node_tools "https://github.com/mark3labs/kit/blob/master/internal/core/tools.go"
click node_mcp "https://github.com/mark3labs/kit/blob/master/internal/tools/mcp.go"
click node_skills "https://github.com/mark3labs/kit/blob/master/internal/skills/skills.go"
click node_templates "https://github.com/mark3labs/kit/blob/master/internal/prompts/template.go"
click node_extensions "https://github.com/mark3labs/kit/blob/master/internal/extensions/api.go"
click node_auth "https://github.com/mark3labs/kit/blob/master/internal/auth/oauth.go"
click node_acp "https://github.com/mark3labs/kit/blob/master/internal/acpserver/session.go"
click node_daemon "https://github.com/mark3labs/kit/blob/master/internal/daemon/server.go"
click node_session "https://github.com/mark3labs/kit/blob/master/internal/session/tree_manager.go"

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_cli,node_app,node_ui,node_user,node_acpclient,node_remoteclient toneBlue
class node_agent,node_kit,node_setup,node_models toneAmber
class node_tools,node_mcp,node_skills,node_templates,node_extensions,node_mcpservers toneMint
class node_auth,node_acp toneRose
class node_daemon,node_session,node_provider toneIndigo
```

## Components

### CLI and experience

- [CLI commands](https://github.com/mark3labs/kit/blob/master/cmd/root.go): `cmd/root.go`
- [App orchestration](https://github.com/mark3labs/kit/blob/master/internal/app/app.go): `internal/app/app.go`
- [Terminal interface](https://github.com/mark3labs/kit/tree/master/internal/ui): `internal/ui`

### Agent runtime

- [Agent loop](https://github.com/mark3labs/kit/blob/master/internal/agent/agent.go): `internal/agent/agent.go`
- [Kit SDK](https://github.com/mark3labs/kit/blob/master/pkg/kit/kit.go): `pkg/kit/kit.go`
- [Agent setup](https://github.com/mark3labs/kit/blob/master/internal/kitsetup/setup.go): `internal/kitsetup/setup.go`
- [Model providers](https://github.com/mark3labs/kit/blob/master/internal/models/providers.go): `internal/models/providers.go`

### Agent capabilities

- [Core coding tools](https://github.com/mark3labs/kit/blob/master/internal/core/tools.go): `internal/core/tools.go`
- [MCP integration](https://github.com/mark3labs/kit/blob/master/internal/tools/mcp.go): `internal/tools/mcp.go`
- [Skills and agents](https://github.com/mark3labs/kit/blob/master/internal/skills/skills.go): `internal/skills/skills.go`
- [Prompt templates](https://github.com/mark3labs/kit/blob/master/internal/prompts/template.go): `internal/prompts/template.go`
- [Extension system](https://github.com/mark3labs/kit/blob/master/internal/extensions/api.go): `internal/extensions/api.go`

### Client integrations

- [Provider authentication](https://github.com/mark3labs/kit/blob/master/internal/auth/oauth.go): `internal/auth/oauth.go`
- [ACP server](https://github.com/mark3labs/kit/blob/master/internal/acpserver/session.go): `internal/acpserver/session.go`

### Session services

- [Remote daemon](https://github.com/mark3labs/kit/blob/master/internal/daemon/server.go): `internal/daemon/server.go`
- [Conversation history](https://github.com/mark3labs/kit/blob/master/internal/session/tree_manager.go): `internal/session/tree_manager.go`

### Other components

- **User**
- **LLM providers**
- **MCP servers**
- **ACP client**
- **Remote client**

## Connections

- User → CLI commands: starts
- CLI commands → App orchestration: runs prompts
- App orchestration → Kit SDK: executes turns (evidence: `internal/app/app.go`)
- App orchestration → Terminal interface: emits events (evidence: `internal/app/app.go`)
- Terminal interface → User: presents results (evidence: `internal/ui/event_handler.go`)
- Kit SDK → Agent setup: configures agent
- Agent setup → Agent loop: creates runtime (evidence: `internal/kitsetup/setup.go`)
- Agent loop → Model providers: requests completions (evidence: `internal/agent/agent.go`)
- Model providers → LLM providers: calls
- Agent loop → Core coding tools: dispatches tools (evidence: `internal/agent/agent.go`)
- Agent loop → MCP integration: dispatches tools
- MCP integration → MCP servers: connects
- Kit SDK → Conversation history: persists history
- CLI commands → Skills and agents: offers capabilities
- CLI commands → Prompt templates: loads prompts
- Agent loop → Extension system: supports extensions
- CLI commands → Provider authentication: manages credentials
- ACP client → ACP server: drives sessions
- ACP server → Kit SDK: runs agent (evidence: `internal/acpserver/session.go`)
- ACP server → MCP servers: adds servers
- Remote client → Remote daemon: attaches remotely
- Remote daemon → Conversation history: serves sessions
