Skip to content

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 plugins

The 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

DirectoryFile CountDescription
gateway/~131WebSocket server, sessions, auth, hooks, config hot-reload
config/~127Config loading, session storage, profile management, validation
sessions/--Session management and isolation
routing/--Message routing logic

Channel Implementations

DirectoryFile CountDescription
channels/~33Channel abstraction: registry, dock, mention-gating
telegram/~87grammy SDK integration
discord/~44discord.js integration
slack/~36@slack/bolt integration
signal/~24signal-cli integration
imessage/~16macOS iMessage integration
line/~36LINE SDK integration
whatsapp/--Baileys (WhatsApp Web)
web/~48WebChat browser interface

Agent and Tools

DirectoryFile CountDescription
agents/~312Agent runtime, Pi agent RPC, tool calls, streaming
plugins/~37Plugin registration, loading, lifecycle
hooks/~30Hook system extensions
browser/~70Playwright browser automation
memory/~45Session memory, vector database

CLI and Commands

DirectoryFile CountDescription
cli/~107CLI core: deps injection, program build, onboarding
commands/~183All CLI subcommand implementations
tui/~30Terminal UI mode
wizard/--Setup wizard
terminal/--Terminal utility functions

Infrastructure

DirectoryFile CountDescription
infra/~157Port management, binaries, environment, runtime guards
media/~22Image/audio/video processing
media-understanding/~23Image/video AI understanding
security/~15Security policies, access control, sandbox
logging/~17Structured logging framework
auto-reply/~73Auto-reply configuration and templates
cron/~35Cron job scheduling
daemon/~32System daemon management

extensions/ Directory

Extensions fall into two categories: channel extensions and feature extensions.

Channel extensions:

  • msteams/ -- Microsoft Teams
  • matrix/ -- Matrix protocol
  • zalo/ / zalouser/ -- Zalo messaging
  • voice-call/ -- Voice calls
  • googlechat/ -- Google Chat
  • mattermost/ -- Mattermost

Feature extensions:

  • memory-lancedb/ -- LanceDB vector database
  • memory-core/ -- Memory system core
  • device-pair/ -- Device pairing
  • diagnostics-otel/ -- OpenTelemetry diagnostics
  • llm-task/ -- LLM task execution
  • copilot-proxy/ -- GitHub Copilot proxy

skills/ Directory

52 built-in skills, managed through the ClawHub registry. Examples:

  • 1password/ -- Password manager
  • github/ -- GitHub integration
  • gmail/ -- Email
  • google-calendar/ -- Calendar
  • apple-notes/ / bear-notes/ -- Note-taking apps
  • apple-reminders/ -- Reminders
  • slack/ / discord/ -- Platform control skills
  • blogwatcher/ / 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:

ConfigPurpose
vitest.config.tsMain configuration
vitest.e2e.config.tsEnd-to-end tests
vitest.live.config.tsLive API tests
vitest.unit.config.tsPure unit tests
vitest.extensions.config.tsExtension tests
vitest.gateway.config.tsGateway 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

OpenClaw Source Code Tutorial