Project Structure
OpenClaw is a pnpm monorepo containing 71 src subdirectories, 34 extensions, 52 skills, and 3 native applications.
Top-Level Directory Layout
openclaw/
├── src/ # Core source code (71 subdirectories)
├── apps/ # Native applications
│ ├── android/ # Android (Kotlin/Gradle)
│ ├── ios/ # iOS (Swift)
│ ├── macos/ # macOS menu bar (SwiftUI)
│ └── shared/ # iOS/macOS shared code (OpenClawKit)
├── ui/ # Web UI (Vite + Lit)
├── packages/ # Workspace sub-packages
│ ├── clawdbot/ # Clawdbot instance
│ └── moltbot/ # Moltbot instance
├── extensions/ # 34 channel/feature extensions
├── skills/ # 52 built-in skills
├── docs/ # Mintlify documentation (multi-language)
├── test/ # Test utilities and fixtures
├── scripts/ # Build and deployment scripts
├── vendor/ # Third-party dependencies
├── vitest.config.ts # Test configuration
├── pnpm-workspace.yaml # Monorepo configuration
└── package.json # Root package (CLI entry)Workspace Configuration
Source: pnpm-workspace.yaml
yaml
packages:
- . # Root package (CLI)
- ui # Web UI
- packages/* # Workspace packages (clawdbot, moltbot)
- extensions/* # 34 channel pluginsThe root package.json export configuration:
json
{
"main": "dist/index.js",
"exports": {
".": "./dist/index.js",
"./plugin-sdk": "./dist/plugin-sdk/index.js",
"./cli-entry": "./openclaw.mjs"
}
}The three exports correspond to: the main program entry, the plugin SDK, and the CLI entry point (respawner).
src/ Core Modules
Control Plane
| Directory | File Count | Description |
|---|---|---|
gateway/ | ~131 | WebSocket server, sessions, auth, hooks, config hot-reload |
config/ | ~127 | Config loading, session storage, profile management, validation |
sessions/ | -- | Session management and isolation |
routing/ | -- | Message routing logic |
Channel Implementations
| Directory | File Count | Description |
|---|---|---|
channels/ | ~33 | Channel abstraction: registry, dock, mention-gating |
telegram/ | ~87 | grammy SDK integration |
discord/ | ~44 | discord.js integration |
slack/ | ~36 | @slack/bolt integration |
signal/ | ~24 | signal-cli integration |
imessage/ | ~16 | macOS iMessage integration |
line/ | ~36 | LINE SDK integration |
whatsapp/ | -- | Baileys (WhatsApp Web) |
web/ | ~48 | WebChat browser interface |
Agent and Tools
| Directory | File Count | Description |
|---|---|---|
agents/ | ~312 | Agent runtime, Pi agent RPC, tool calls, streaming |
plugins/ | ~37 | Plugin registration, loading, lifecycle |
hooks/ | ~30 | Hook system extensions |
browser/ | ~70 | Playwright browser automation |
memory/ | ~45 | Session memory, vector database |
CLI and Commands
| Directory | File Count | Description |
|---|---|---|
cli/ | ~107 | CLI core: deps injection, program build, onboarding |
commands/ | ~183 | All CLI subcommand implementations |
tui/ | ~30 | Terminal UI mode |
wizard/ | -- | Setup wizard |
terminal/ | -- | Terminal utility functions |
Infrastructure
| Directory | File Count | Description |
|---|---|---|
infra/ | ~157 | Port management, binaries, environment, runtime guards |
media/ | ~22 | Image/audio/video processing |
media-understanding/ | ~23 | Image/video AI understanding |
security/ | ~15 | Security policies, access control, sandbox |
logging/ | ~17 | Structured logging framework |
auto-reply/ | ~73 | Auto-reply configuration and templates |
cron/ | ~35 | Cron job scheduling |
daemon/ | ~32 | System daemon management |
extensions/ Directory
Extensions fall into two categories: channel extensions and feature extensions.
Channel extensions:
msteams/-- Microsoft Teamsmatrix/-- Matrix protocolzalo//zalouser/-- Zalo messagingvoice-call/-- Voice callsgooglechat/-- Google Chatmattermost/-- Mattermost
Feature extensions:
memory-lancedb/-- LanceDB vector databasememory-core/-- Memory system coredevice-pair/-- Device pairingdiagnostics-otel/-- OpenTelemetry diagnosticsllm-task/-- LLM task executioncopilot-proxy/-- GitHub Copilot proxy
skills/ Directory
52 built-in skills, managed through the ClawHub registry. Examples:
1password/-- Password managergithub/-- GitHub integrationgmail/-- Emailgoogle-calendar/-- Calendarapple-notes//bear-notes/-- Note-taking appsapple-reminders/-- Remindersslack//discord/-- Platform control skillsblogwatcher//news/-- Content monitoring
Native Apps (apps/)
Build and Test
bash
pnpm build # Full build (canvas, bundle, protocols)
pnpm check # Type check + lint + format
pnpm test # Vitest unit tests
pnpm test:e2e # End-to-end tests
pnpm test:live # Live API tests (requires real credentials)
pnpm test:coverage # Coverage report (70% threshold)Test configuration files:
| Config | Purpose |
|---|---|
vitest.config.ts | Main configuration |
vitest.e2e.config.ts | End-to-end tests |
vitest.live.config.ts | Live API tests |
vitest.unit.config.ts | Pure unit tests |
vitest.extensions.config.ts | Extension tests |
vitest.gateway.config.ts | Gateway tests |
Test files are co-located with source files (*.test.ts), following the Vitest convention.
Summary
- pnpm monorepo architecture with 4 workspace areas (root, ui, packages, extensions)
- src/ contains 71 functional modules spanning the full stack from infrastructure to CLI
- extensions/ and skills/ provide pluggable channel and feature extensions
- apps/ includes macOS, iOS, and Android native applications
- Build system uses tsdown/Rolldown, testing uses Vitest
Next: Gateway Overview