# dwmkerr/claude-code-agent architecture

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

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

## Overview

This product is a container-ready A2A server that accepts streamed messages, runs Claude Code in per-context workspaces, and returns task updates and results. Configuration and skill discovery feed agent registration; the executor manages Claude CLI sessions, streaming output, optional JSONL logs, and optional OpenTelemetry traces. README also documents workspace isolation and per-session setup for plugins and MCP servers. Links reflect excerpted calls or README statements; deployment-specific integrations are not expanded into runtime components.

Main entry points: [`src/claude-code-executor.ts`](https://github.com/dwmkerr/claude-code-agent/blob/main/src/claude-code-executor.ts) (Session Executor), [`src/main.ts`](https://github.com/dwmkerr/claude-code-agent/blob/main/src/main.ts) (Server Startup), [`src/routes.ts`](https://github.com/dwmkerr/claude-code-agent/blob/main/src/routes.ts) (A2A Routing), [`src/claude-code-agent.ts`](https://github.com/dwmkerr/claude-code-agent/blob/main/src/claude-code-agent.ts) (Agent Card)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["A2A Server"]
  node_entry["Server Startup<br/>[main.ts]"]
  node_routes["A2A Routing<br/>[routes.ts]"]
  node_agent["Agent Card"]
  node_protocol["A2A Types<br/>[protocol.ts]"]
  node_skills["Skill Discovery<br/>[skill-loader.ts]"]
end

subgraph group_execution["Claude Execution"]
  node_executor["Session Executor"]
  node_workspace[("Isolated Workspace")]
  node_setup["Session Setup"]
  node_cli_path["CLI Discovery<br/>[claude-path.ts]"]
  node_format["Output Formatting<br/>[format-chunk.ts]"]
end

subgraph group_configuration["Configuration"]
  node_config["Runtime Config<br/>[config.ts]"]
end

subgraph group_observability["Observability"]
  node_tracing["Trace Setup<br/>[tracing.ts]"]
  node_transformer["Span Transform"]
end

node_user(("A2A Client"))
node_claude["Claude Code CLI"]
node_otel["OTLP Collector"]
node_logs["JSONL Logs"]

node_user -->|"sends request"| node_entry
node_entry -->|"loads settings"| node_config
node_entry -->|"loads skills"| node_skills
node_entry -->|"sets up routes"| node_routes
node_routes -->|"creates agent"| node_agent
node_routes -->|"serves A2A"| node_user
node_agent -->|"creates executor"| node_executor
node_agent -->|"registers skills"| node_skills
node_executor -->|"finds executable"| node_cli_path
node_executor -->|"runs sessions"| node_claude
node_executor -->|"uses workspace"| node_workspace
node_executor -->|"runs init script"| node_setup
node_executor -->|"formats chunks"| node_format
node_executor -->|"transforms messages"| node_transformer
node_executor -->|"checks tracing"| node_tracing
node_entry -->|"initializes tracing"| node_tracing
node_tracing -->|"exports traces"| node_otel
node_executor -->|"writes chunks"| node_logs
node_executor -->|"streams results"| node_user

click node_entry "https://github.com/dwmkerr/claude-code-agent/blob/main/src/main.ts"
click node_routes "https://github.com/dwmkerr/claude-code-agent/blob/main/src/routes.ts"
click node_agent "https://github.com/dwmkerr/claude-code-agent/blob/main/src/claude-code-agent.ts"
click node_protocol "https://github.com/dwmkerr/claude-code-agent/blob/main/src/protocol.ts"
click node_skills "https://github.com/dwmkerr/claude-code-agent/blob/main/src/skill-loader.ts"
click node_executor "https://github.com/dwmkerr/claude-code-agent/blob/main/src/claude-code-executor.ts"
click node_cli_path "https://github.com/dwmkerr/claude-code-agent/blob/main/src/lib/claude-path.ts"
click node_format "https://github.com/dwmkerr/claude-code-agent/blob/main/src/lib/format-chunk.ts"
click node_config "https://github.com/dwmkerr/claude-code-agent/blob/main/src/config.ts"
click node_tracing "https://github.com/dwmkerr/claude-code-agent/blob/main/src/tracing.ts"
click node_transformer "https://github.com/dwmkerr/claude-code-agent/blob/main/src/lib/span-transformer.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_entry,node_routes,node_agent,node_protocol,node_skills,node_user toneBlue
class node_executor,node_workspace,node_setup,node_cli_path,node_format toneAmber
class node_config toneMint
class node_tracing,node_transformer toneRose
class node_claude,node_otel,node_logs toneIndigo
```

## Components

### A2A Server

- [Server Startup](https://github.com/dwmkerr/claude-code-agent/blob/main/src/main.ts): `src/main.ts`
- [A2A Routing](https://github.com/dwmkerr/claude-code-agent/blob/main/src/routes.ts): `src/routes.ts`
- [Agent Card](https://github.com/dwmkerr/claude-code-agent/blob/main/src/claude-code-agent.ts): `src/claude-code-agent.ts`
- [A2A Types](https://github.com/dwmkerr/claude-code-agent/blob/main/src/protocol.ts): `src/protocol.ts`
- [Skill Discovery](https://github.com/dwmkerr/claude-code-agent/blob/main/src/skill-loader.ts): `src/skill-loader.ts`

### Claude Execution

- [Session Executor](https://github.com/dwmkerr/claude-code-agent/blob/main/src/claude-code-executor.ts): `src/claude-code-executor.ts`
- **Isolated Workspace**
- **Session Setup**
- [CLI Discovery](https://github.com/dwmkerr/claude-code-agent/blob/main/src/lib/claude-path.ts): `src/lib/claude-path.ts`
- [Output Formatting](https://github.com/dwmkerr/claude-code-agent/blob/main/src/lib/format-chunk.ts): `src/lib/format-chunk.ts`

### Configuration

- [Runtime Config](https://github.com/dwmkerr/claude-code-agent/blob/main/src/config.ts): `src/config.ts`

### Observability

- [Trace Setup](https://github.com/dwmkerr/claude-code-agent/blob/main/src/tracing.ts): `src/tracing.ts`
- [Span Transform](https://github.com/dwmkerr/claude-code-agent/blob/main/src/lib/span-transformer.ts): `src/lib/span-transformer.ts`

### Other components

- **A2A Client**
- **Claude Code CLI**
- **OTLP Collector**
- **JSONL Logs**

## Connections

- A2A Client → Server Startup: sends request (evidence: `README.md`)
- Server Startup → Runtime Config: loads settings (evidence: `src/main.ts`)
- Server Startup → Skill Discovery: loads skills (evidence: `src/main.ts`)
- Server Startup → A2A Routing: sets up routes (evidence: `src/main.ts`)
- A2A Routing → Agent Card: creates agent (evidence: `src/routes.ts`)
- A2A Routing → A2A Client: serves A2A (evidence: `README.md`)
- Agent Card → Session Executor: creates executor (evidence: `src/claude-code-agent.ts`)
- Agent Card → Skill Discovery: registers skills (evidence: `src/claude-code-agent.ts`)
- Session Executor → CLI Discovery: finds executable (evidence: `src/claude-code-executor.ts`)
- Session Executor → Claude Code CLI: runs sessions (evidence: `src/claude-code-executor.ts`)
- Session Executor → Isolated Workspace: uses workspace (evidence: `README.md`)
- Session Executor → Session Setup: runs init script (evidence: `README.md`)
- Session Executor → Output Formatting: formats chunks (evidence: `src/claude-code-executor.ts`)
- Session Executor → Span Transform: transforms messages (evidence: `src/claude-code-executor.ts`)
- Session Executor → Trace Setup: checks tracing (evidence: `src/claude-code-executor.ts`)
- Server Startup → Trace Setup: initializes tracing (evidence: `src/main.ts`)
- Trace Setup → OTLP Collector: exports traces (evidence: `src/tracing.ts`)
- Session Executor → JSONL Logs: writes chunks (evidence: `src/claude-code-executor.ts`)
- Session Executor → A2A Client: streams results (evidence: `README.md`)
