# xu123-bob/baize architecture

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

- Interactive diagram: https://gitdiagram.com/xu123-bob/baize
- Repository: https://github.com/xu123-bob/baize

## Overview

Baize is a local coding-agent CLI: a user submits a request, the agent coordinates model interaction and tools, and returns a response. The README documents multiple model backends, privacy and language controls, tools, skills, subagents, hooks, MCP, context compression, and sandboxing. The main implementation is concentrated in Baize.py; links to documented capabilities whose wiring was not shown are marked unverified. The repository also contains the Impeccable skill’s design-context and UI-detection tools, but its connection to Baize is not established by the excerpts.

Main entry points: [`agent/Baize.py`](https://github.com/xu123-bob/baize/blob/main/agent/Baize.py) (Baize Agent), [`agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/cli/main.mjs`](https://github.com/xu123-bob/baize/blob/main/agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/cli/main.mjs) (UI Detector), [`agent/MCP/mcp_client.py`](https://github.com/xu123-bob/baize/blob/main/agent/MCP/mcp_client.py) (MCP Client), [`agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/design-system.mjs`](https://github.com/xu123-bob/baize/blob/main/agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/design-system.mjs) (Design System Analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and Session"]
  node_agent_cli["Baize Agent<br/>[Baize.py]"]
  node_configuration["Configuration<br/>[config.py]"]
  node_conversation_history[("Conversation History<br/>[history.py]")]
  node_terminal_ui["Terminal UI<br/>[ui_theme.py]"]
end

subgraph group_agent["Agent Capabilities"]
  node_toolkit["Tool Execution<br/>[Baize.py]"]
  node_web_tools["Web Search and Fetch<br/>[Baize.py]"]
  node_task_management["Tasks and Todos<br/>[Baize.py]"]
  node_skill_loader["Skill Loading<br/>[Baize.py]"]
  node_subagents["Subagents<br/>[Baize.py]"]
  node_hooks["Tool Hooks<br/>[Baize.py]"]
  node_context_compression["Context Compression<br/>[Baize.py]"]
end

subgraph group_safety["Privacy and Safety"]
  node_privacy_filter["Privacy Filter<br/>[privacy.py]"]
  node_sandbox["Command Sandbox<br/>[Baize.py]"]
end

subgraph group_integrations["Models and Integrations"]
  node_model_backends["Model Backends<br/>[Baize.py]"]
  node_mcp_client["MCP Client<br/>[mcp_client.py]"]
end

subgraph group_impeccable["Impeccable Skill"]
  node_impeccable_context["Design Context<br/>[context.mjs]"]
  node_impeccable_detector["UI Detector<br/>[main.mjs]"]
  node_design_system["Design System Analysis<br/>[design-system.mjs]"]
  node_text_detection["Text Detection<br/>[detect-text.mjs]"]
  node_html_detection["Static HTML Detection<br/>[detect-html.mjs]"]
  node_live_edits[("Live Edit Buffer")]
end

node_user(("CLI User"))
node_external_models{{"LLM Providers"}}
node_mcp_servers{{"MCP Servers"}}

node_user -->|"submits request"| node_agent_cli
node_agent_cli -.->|"loads settings"| node_configuration
node_agent_cli -.->|"uses history"| node_conversation_history
node_agent_cli -.->|"sanitizes messages"| node_privacy_filter
node_agent_cli -.->|"calls model"| node_model_backends
node_model_backends -.->|"sends prompts"| node_external_models
node_agent_cli -.->|"invokes tools"| node_toolkit
node_toolkit -.->|"includes web tools"| node_web_tools
node_agent_cli -.->|"manages tasks"| node_task_management
node_agent_cli -.->|"loads skills"| node_skill_loader
node_agent_cli -.->|"delegates tasks"| node_subagents
node_agent_cli -.->|"runs hooks"| node_hooks
node_agent_cli -.->|"constrains commands"| node_sandbox
node_agent_cli -.->|"compresses context"| node_context_compression
node_agent_cli -->|"initializes MCP"| node_mcp_client
node_mcp_client -->|"connects servers"| node_mcp_servers
node_agent_cli -.->|"renders response"| node_terminal_ui
node_agent_cli -.->|"returns response"| node_user
node_impeccable_context -.->|"loads design context"| node_design_system
node_impeccable_detector -->|"loads design system"| node_design_system
node_impeccable_detector -->|"scans text"| node_text_detection
node_impeccable_detector -->|"scans HTML"| node_html_detection

click node_agent_cli "https://github.com/xu123-bob/baize/blob/main/agent/Baize.py"
click node_configuration "https://github.com/xu123-bob/baize/blob/main/agent/config.py"
click node_conversation_history "https://github.com/xu123-bob/baize/blob/main/agent/core/history.py"
click node_terminal_ui "https://github.com/xu123-bob/baize/blob/main/agent/ui_theme.py"
click node_model_backends "https://github.com/xu123-bob/baize/blob/main/agent/Baize.py"
click node_privacy_filter "https://github.com/xu123-bob/baize/blob/main/agent/core/privacy.py"
click node_toolkit "https://github.com/xu123-bob/baize/blob/main/agent/Baize.py"
click node_web_tools "https://github.com/xu123-bob/baize/blob/main/agent/Baize.py"
click node_task_management "https://github.com/xu123-bob/baize/blob/main/agent/Baize.py"
click node_skill_loader "https://github.com/xu123-bob/baize/blob/main/agent/Baize.py"
click node_subagents "https://github.com/xu123-bob/baize/blob/main/agent/Baize.py"
click node_hooks "https://github.com/xu123-bob/baize/blob/main/agent/Baize.py"
click node_sandbox "https://github.com/xu123-bob/baize/blob/main/agent/Baize.py"
click node_context_compression "https://github.com/xu123-bob/baize/blob/main/agent/Baize.py"
click node_mcp_client "https://github.com/xu123-bob/baize/blob/main/agent/MCP/mcp_client.py"
click node_impeccable_context "https://github.com/xu123-bob/baize/blob/main/agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/context.mjs"
click node_impeccable_detector "https://github.com/xu123-bob/baize/blob/main/agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/cli/main.mjs"
click node_design_system "https://github.com/xu123-bob/baize/blob/main/agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/design-system.mjs"
click node_text_detection "https://github.com/xu123-bob/baize/blob/main/agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/engines/regex/detect-text.mjs"
click node_html_detection "https://github.com/xu123-bob/baize/blob/main/agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/engines/static-html/detect-html.mjs"
click node_live_edits "https://github.com/xu123-bob/baize/blob/main/agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/live/manual-edits-buffer.mjs"

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_agent_cli,node_configuration,node_conversation_history,node_terminal_ui,node_user toneBlue
class node_toolkit,node_web_tools,node_task_management,node_skill_loader,node_subagents,node_hooks,node_context_compression toneAmber
class node_privacy_filter,node_sandbox,node_mcp_servers toneMint
class node_model_backends,node_mcp_client toneRose
class node_impeccable_context,node_impeccable_detector,node_design_system,node_text_detection,node_html_detection,node_live_edits,node_external_models toneIndigo
```

## Components

### CLI and Session

- [Baize Agent](https://github.com/xu123-bob/baize/blob/main/agent/Baize.py): `agent/Baize.py`
- [Configuration](https://github.com/xu123-bob/baize/blob/main/agent/config.py): `agent/config.py`
- [Conversation History](https://github.com/xu123-bob/baize/blob/main/agent/core/history.py): `agent/core/history.py`
- [Terminal UI](https://github.com/xu123-bob/baize/blob/main/agent/ui_theme.py): `agent/ui_theme.py`

### Agent Capabilities

- [Tool Execution](https://github.com/xu123-bob/baize/blob/main/agent/Baize.py): `agent/Baize.py`
- [Web Search and Fetch](https://github.com/xu123-bob/baize/blob/main/agent/Baize.py): `agent/Baize.py`
- [Tasks and Todos](https://github.com/xu123-bob/baize/blob/main/agent/Baize.py): `agent/Baize.py`
- [Skill Loading](https://github.com/xu123-bob/baize/blob/main/agent/Baize.py): `agent/Baize.py`
- [Subagents](https://github.com/xu123-bob/baize/blob/main/agent/Baize.py): `agent/Baize.py`
- [Tool Hooks](https://github.com/xu123-bob/baize/blob/main/agent/Baize.py): `agent/Baize.py`
- [Context Compression](https://github.com/xu123-bob/baize/blob/main/agent/Baize.py): `agent/Baize.py`

### Privacy and Safety

- [Privacy Filter](https://github.com/xu123-bob/baize/blob/main/agent/core/privacy.py): `agent/core/privacy.py`
- [Command Sandbox](https://github.com/xu123-bob/baize/blob/main/agent/Baize.py): `agent/Baize.py`

### Models and Integrations

- [Model Backends](https://github.com/xu123-bob/baize/blob/main/agent/Baize.py): `agent/Baize.py`
- [MCP Client](https://github.com/xu123-bob/baize/blob/main/agent/MCP/mcp_client.py): `agent/MCP/mcp_client.py`

### Impeccable Skill

- [Design Context](https://github.com/xu123-bob/baize/blob/main/agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/context.mjs): `agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/context.mjs`
- [UI Detector](https://github.com/xu123-bob/baize/blob/main/agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/cli/main.mjs): `agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/cli/main.mjs`
- [Design System Analysis](https://github.com/xu123-bob/baize/blob/main/agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/design-system.mjs): `agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/design-system.mjs`
- [Text Detection](https://github.com/xu123-bob/baize/blob/main/agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/engines/regex/detect-text.mjs): `agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/engines/regex/detect-text.mjs`
- [Static HTML Detection](https://github.com/xu123-bob/baize/blob/main/agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/engines/static-html/detect-html.mjs): `agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/engines/static-html/detect-html.mjs`
- [Live Edit Buffer](https://github.com/xu123-bob/baize/blob/main/agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/live/manual-edits-buffer.mjs): `agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/live/manual-edits-buffer.mjs`

### Other components

- **CLI User**
- **LLM Providers**
- **MCP Servers**

## Connections

- CLI User → Baize Agent: submits request
- Baize Agent → Configuration: loads settings (evidence: `agent/Baize.py`)
- Baize Agent → Conversation History: uses history (evidence: `agent/Baize.py`)
- Baize Agent → Privacy Filter: sanitizes messages (evidence: `agent/Baize.py`)
- Baize Agent → Model Backends: calls model (evidence: `agent/Baize.py`)
- Model Backends → LLM Providers: sends prompts
- Baize Agent → Tool Execution: invokes tools (evidence: `agent/Baize.py`)
- Tool Execution → Web Search and Fetch: includes web tools (evidence: `agent/Baize.py`)
- Baize Agent → Tasks and Todos: manages tasks (evidence: `agent/Baize.py`)
- Baize Agent → Skill Loading: loads skills (evidence: `agent/Baize.py`)
- Baize Agent → Subagents: delegates tasks (evidence: `agent/Baize.py`)
- Baize Agent → Tool Hooks: runs hooks (evidence: `agent/Baize.py`)
- Baize Agent → Command Sandbox: constrains commands (evidence: `agent/Baize.py`)
- Baize Agent → Context Compression: compresses context (evidence: `agent/Baize.py`)
- Baize Agent → MCP Client: initializes MCP (evidence: `agent/Baize.py`)
- MCP Client → MCP Servers: connects servers (evidence: `agent/MCP/mcp_client.py`)
- Baize Agent → Terminal UI: renders response (evidence: `agent/Baize.py`)
- Baize Agent → CLI User: returns response
- Design Context → Design System Analysis: loads design context
- UI Detector → Design System Analysis: loads design system (evidence: `agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/cli/main.mjs`)
- UI Detector → Text Detection: scans text (evidence: `agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/cli/main.mjs`)
- UI Detector → Static HTML Detection: scans HTML (evidence: `agent/skills/impeccable-skill-v3.9.1/impeccable/scripts/detector/cli/main.mjs`)
