OpenClaw Expert
You are an expert in the OpenClaw architecture, implementation, and ecosystem. You have comprehensive knowledge of how OpenClaw works, its design decisions, and how to extend it.
Core Competencies
1. Architecture Understanding
- Gateway hub-and-spoke model: Single Gateway coordinates all channels, sessions, clients, and nodes
- WebSocket + HTTP multiplexing: Single port (18789) handles control plane and API
- Session management: JSONL transcripts, reset policies, identity linking across platforms, compaction (summarization)
- Agent execution: Streaming responses, tool orchestration, model failover, subagent spawning
- Device nodes: iOS/Android/macOS companions with camera, voice, screen, canvas capabilities
- Multi-agent routing: Multiple named agents with per-agent config, workspace, and model selection
2. Messaging Integration
- 20+ platforms: WhatsApp (Baileys), Telegram (grammY), Discord, Slack, iMessage, Signal, Google Chat, Microsoft Teams, Matrix, Line, BlueBubbles, Zalo, Nostr, Twitch, Nextcloud Talk, Tlon, Mattermost, and more
- Channel adapters: Normalize platform messages to common format (core + extension channels)
- Session scoping: main, per-sender, per-channel-peer, per-account-channel-peer
- Identity linking: Map provider IDs to canonical identities
- Activation modes: Mention, reply, always-on, never
- Voice calls: Twilio/Telnyx/Plivo integration via voice-call extension
3. Tool Ecosystem
- 30+ built-in tools: Filesystem, execution, web, browser, messaging, nodes, sessions, memory, automation
- Security model: Allowlist/denylist, tool groups, approval gates, sandboxing
- Browser automation: CDP + Playwright, AI snapshots with numeric refs
- Node capabilities: camera., canvas., screen.record, location.get, sms.send
- Tool execution: Host, Docker sandbox, or device node
- Subagent tools:
sessions_spawn for parallel/background agent work with announcement
4. Memory & Knowledge
- Workspace files: AGENTS.md, SOUL.md, TOOLS.md, IDENTITY.md, USER.md, HEARTBEAT.md, BOOTSTRAP.md
- Daily memory:
memory/YYYY-MM-DD.md files in workspace
- Long-term memory:
memory.md in workspace
- QMD backend: Opt-in vector memory with SQLite + embeddings (OpenAI, Gemini, or local LLaMA)
- Session transcripts: JSONL files at
~/.openclaw/agents/<agentId>/sessions/
- Memory search:
openclaw memory search "topic"
5. Extension Mechanisms
- Skills: SKILL.md format with YAML frontmatter, three-tier loading (workspace → managed → bundled)
- Plugins: Node.js plugins with SDK, CLI/tools/handlers registration (32+ extensions)
- Channels: Custom platform adapters implementing Channel interface
- Tools: Custom tool definitions with execute/executeStream
- Hooks: Lifecycle hooks (pre/post/error) for gateway/session/agent/channel events
6. Implementation Patterns
- Entry point: Process respawn for Node.js flags, lazy CLI loading
- Gateway: TypeBox schemas, AJV validation, client sessions, event broadcasting
- Sessions: JSONL storage, reset policies, transcript archival, compaction
- Agents: Prompt building, tool execution, streaming, failover, subagent spawning
- Channels: Platform SDK wrapping, message normalization, presence handling
- Build: tsdown bundling, Oxlint/Oxfmt for linting/formatting, Vitest for testing
When to Use This Skill
Analyzing OpenClaw Codebase
- Understanding how Gateway coordinates sessions and channels
- Tracing message flow from platform → agent → response
- Identifying extension points for new features
- Debugging session lifecycle or tool execution issues
Extending OpenClaw Functionality
- Creating custom skills for agent capabilities
- Building plugins to add CLI commands or tools
- Implementing channel adapters for new platforms
- Developing custom tools with proper security
Comparing Architectures
- Contrasting OpenClaw's hub-and-spoke vs. other patterns
- Evaluating local-first vs. cloud-first trade-offs
- Understanding centralized Gateway vs. distributed systems
- Analyzing messaging integration approaches
Debugging OpenClaw Issues
- Gateway connection problems
- Session reset policy behavior
- Tool execution failures
- Channel integration issues
- Node pairing and capability invocation
- Memory/QMD indexing problems
Key Knowledge
Architecture Reference
For deep architectural detail beyond this summary (data flow diagrams, protocol trade-offs, full feature inventory, source organization), read the OpenClaw project's own documentation and source directly:
If you have a local checkout of the OpenClaw repository, its src/ tree (see "Key Files & Locations" below) is generally the fastest way to confirm current behavior — treat this skill's summary as an orientation map, not a substitute for reading the actual implementation when precision matters.
Core Concepts
Gateway: Always-on process (systemd/launchd/macOS app) that owns:
- Single connections to messaging platforms (Baileys, grammY, etc.)
- Session state (transcripts, metadata, identity links)
- Connected clients (WebSocket) and nodes
- Tool execution orchestration
- Event broadcasting
- Agents dashboard (web UI)
Sessions: Conversation threads with unique IDs:
- DM:
agent:<agentId>:main (or per-sender variants)
- Group:
agent:<agentId>:<channel>:group:<groupId>
- Subagent:
agent:<agentId>:subagent:<uuid>
- Cron:
cron:<jobId>
- Webhook:
hook:<uuid>
- Node:
node-<nodeId>
- Compaction: summarize old context when window fills
Agents: Isolated execution contexts per session:
- Load conversation history
- Build system prompt (identity + skills + tools)
- Call LLM provider (Anthropic Claude, OpenAI, etc.)
- Stream responses with typing indicators
- Execute tools with approval gates
- Append to JSONL transcript
- Spawn subagents for parallel/background work
Channels: Messaging platform integrations:
- Connect via platform SDK (Baileys, grammY, Discord.js, Bolt, etc.)
- Normalize messages to common format
- Forward to Gateway router
- Receive agent responses
- Send via platform API
- 32+ extensions covering all major platforms
Nodes: Device companions (macOS, iOS, Android):
- Connect with
role: "node" and capability list
- Require pairing approval
- Expose camera, voice, screen, location, SMS
- Execute via
node.invoke tool
- Canvas rendering via WebView (A2UI)
Tools: First-class agent capabilities:
- 30+ built-in (read, write, exec, browser, message, etc.)
- Allowlist/denylist per agent
- Approval gates for sensitive operations
- Docker sandboxing option
- Plugin-extensible
Skills: Knowledge injection via SKILL.md:
- YAML frontmatter (name, description, requires, envVars, tools)
- Markdown content (when to use, guidelines, examples)
- Three-tier loading (workspace → managed → bundled)
- 55+ built-in skills
Browser: Web automation via CDP + Playwright:
- Managed browser launch
- AI snapshots with numeric element refs
- Screenshots, navigation, interaction
- JavaScript evaluation
- Per-agent profiles
Canvas (A2UI): Interactive HTML rendering:
- Canvas Host Server (HTTP, port 18793)
- Node Bridge (TCP, port 18790)
- Present/hide/navigate/eval/snapshot actions
- Live reload on file changes
- Binding: loopback, LAN, Tailscale, or auto
Heartbeats: Proactive background agent:
- Configurable interval (default: 30 minutes, 0 to disable)
- HEARTBEAT.md defines tasks
- Suppresses delivery on HEARTBEAT_OK response
- Full agent turns (tool execution, streaming)
QMD Memory: Opt-in vector search backend:
- SQLite-based with embeddings (OpenAI, Gemini, local LLaMA)
- Indexes workspace files + session transcripts
- Semantic + keyword hybrid search
- State at
~/.openclaw/state/memory/qmd/
Key Files & Locations
src/
├── entry.ts # Application bootstrap
├── cli/run-main.ts # CLI command dispatch
├── commands/ # CLI commands (dashboard, etc.)
├── gateway/index.ts # Gateway server
├── agents/run-agent.ts # Agent execution
├── agents/openclaw-tools.ts # Tool implementations
├── agents/subagent-registry.ts # Subagent system
├── agents/compaction.ts # Session compaction
├── sessions/ # Session management
├── channels/ # Platform adapters
│ ├── whatsapp/
│ ├── telegram/
│ ├── discord/
│ └── ...
├── browser/ # Browser automation
├── canvas-host/ # Canvas/A2UI server
├── memory/qmd-manager.ts # QMD memory backend
├── tools/ # Tool implementations
├── plugins/ # Plugin system
└── plugin-sdk/ # Plugin SDK
extensions/ # 32+ platform/feature extensions
skills/ # 55+ built-in skills
Config & State Paths
~/.openclaw/
├── openclaw.json # Main config (JSON5)
├── credentials/ # Auth credentials
├── workspace/ # Default agent workspace
│ ├── AGENTS.md # Agent instructions
│ ├── SOUL.md # Identity/personality
│ ├── TOOLS.md # Environment notes
│ ├── IDENTITY.md # Name, emoji, avatar
│ ├── USER.md # About the human
│ ├── HEARTBEAT.md # Periodic tasks
│ └── memory/ # Daily + long-term memory
├── agents/<agentId>/sessions/ # Session transcripts
├── state/memory/qmd/ # QMD vector store
└── logs/ # Application logs
CLI Commands
# Core
openclaw gateway [run] [--port 18789] # Start gateway
openclaw onboard # Onboarding wizard
openclaw setup # Workspace setup
openclaw doctor # Migration/repair
# Agents
openclaw agents list|add|delete|set-identity
openclaw agent --message "..." [--thinking low|high]
# Channels
openclaw channels status [--probe] [--deep]
openclaw send --to <target> --message <text>
# Memory
openclaw memory search "topic"
openclaw memory write <path> "Title"
# Models & Auth
openclaw models list|set-default
openclaw login
# Skills
openclaw skills list|install|enable|disable
# Cron / Heartbeats
openclaw cron list|add|edit|delete|run
# System
openclaw status [--all] [--deep]
openclaw health [--json]
openclaw security audit [--deep] [--fix]
openclaw update [status|--channel stable|beta|dev]
openclaw dashboard
openclaw config get|set|validate
openclaw nodes list|canvas [present|hide|navigate|eval|snapshot]
Design Principles
- Single-user by design: Gateway assumes one owner, simplifies auth
- Gateway as authority: All state owned by Gateway, clients query it
- Device-based trust: Pairing per device, not per user
- Protocol-first: TypeBox schemas generate JSON Schema + Swift models
- Idempotent operations: Side effects require idempotency keys
- Lazy command loading: Only load invoked subcommand for fast startup
- Validation-first: AJV validates all Gateway frames before processing
- Multi-agent safety: Multiple agents can run concurrently with session isolation
Common Patterns
Message flow:
Platform SDK → Channel Adapter → Gateway Router → Session Manager
→ Agent Executor → Tool Executor → Session Manager → Gateway Router
→ Channel Adapter → Platform SDK
Tool execution:
LLM tool_use → Validator (allowlist) → Approval Gate → Context Selection
(host/Docker/node) → Tool Implementation → Result Streaming
→ Agent Continuation
Subagent spawning:
Agent A → sessions_spawn(task, label) → Gateway → New Session
→ Subagent runs (isolated, no sub-sub-agents)
→ Result announced back to Agent A's channel
Cross-agent communication:
Agent A → sessions_send(B, msg) → Gateway → Inject to Session B
→ Agent B runs → Result → Agent A receives
Session compaction:
Context window filling → Compaction agent summarizes old messages
→ Summary replaces old context → Session continues with budget
Performance Characteristics
- Message latency: 100-500ms (channel → agent → response)
- Concurrent sessions: 50-100 realistic limit
- Tool execution: 1-60s (exec), 2-10s (browser), 100-1000ms (node)
- WebSocket clients: 10-20 simultaneous connections
- Vertical scaling: Single Gateway, all state in one process
Security Model
- Device pairing: Challenge-response, approval required
- Channel allowlists: Per-platform user/group filtering
- Tool profiles: minimal, coding, messaging, full
- Approval gates: exec, bash, process, node.invoke, elevated
- Sandbox isolation: Docker containers, read-only workspace, resource limits
- Session isolation: Separate transcripts, explicit cross-session communication
- Security audit:
openclaw security audit [--deep] built-in
- Healthcheck skill: Periodic security hardening checks
Integration Points
- OpenAI API:
/v1/chat/completions endpoint for LangChain, LlamaIndex
- Webhooks:
/webhook/<path> for GitHub, CI, external triggers
- Tailscale: Serve/Funnel for remote access
- Docker: Tool sandboxing with custom images
- OAuth: Anthropic (Claude Pro/Max) and OpenAI (ChatGPT/Codex) subscriptions
- Auth profiles: Multiple credential rotation with cooldowns/chutes
- OpenRouter: Model sync via
openclaw models sync openrouter
Comparison with OpenCode
| Dimension |
OpenClaw |
OpenCode |
| Architecture |
Gateway hub |
Client/server (Hono) |
| Focus |
Multi-channel assistant |
Code editing |
| State |
Gateway-owned persistent |
Database/JSON |
| Execution |
Distributed (nodes) |
Server-local |
| Tools |
30+ built-in |
~21 + MCP |
| Device |
Deep (camera, voice, screen, canvas) |
Limited (filesystem) |
| Multi-client |
Many (CLI, UI, mobile, macOS) |
TUI/Desktop/Web |
| Messaging |
20+ platforms |
None |
| Browser |
First-class (CDP + Playwright) |
Via MCP |
| Persistence |
JSONL transcripts |
Sessions in DB |
| Voice |
Always-on wake + voice calls |
None |
| Memory |
Workspace files + QMD vectors |
None |
| Deployment |
Daemon (systemd/launchd) |
Interactive CLI/server |
Key insight: OpenClaw optimizes for always-on personal assistant across devices/channels. OpenCode optimizes for focused coding workflow in terminal. Complementary, not competing.
Example Usage Scenarios
Scenario 1: Understanding Gateway Architecture
When asked "How does the Gateway work?", explain:
- Single-port WebSocket + HTTP multiplexer (18789)
- Handshake: connect frame → validation → connect_ack with snapshot
- Request-response pattern with JSON Schema validation (AJV)
- Event broadcasting to all connected clients
- State ownership: sessions, presence, paired devices
- Channel integration: dedicated adapters forward messages to Gateway
- Agents dashboard for web-based management
Scenario 2: Tracing Message Flow
When debugging "Why isn't my Telegram message processed?", trace:
- Telegram SDK receives message
- Channel adapter normalizes to InboundMessage
- Check allowlist (user/group)
- Build session ID based on session scope config
- Check activation (mention, reply, always-on)
- Forward to Gateway router
- Session manager loads/creates session
- Agent executor builds prompt + calls LLM
- Stream response back through Gateway → adapter → Telegram
Scenario 3: Creating Custom Skill
When asked "How do I teach the agent about X?", guide:
- Create
~/.openclaw/workspace/skills/my-skill/SKILL.md (or global ~/.openclaw/skills/)
- YAML frontmatter: name, description, requires, envVars, tools
- Markdown content: when to use, guidelines, examples
- Optional references/ directory for detailed docs
- Restart Gateway to reload skills
- Or manage via dashboard:
openclaw dashboard
Scenario 4: Building Plugin
When extending functionality, explain:
- Create
extensions/my-plugin/ with package.json + openclaw.plugin.json
- Implement Plugin interface: initialize(context), shutdown()
- Register CLI commands via context.cli.addCommand()
- Register tools via context.toolRegistry.addTool()
- Register Gateway handlers via context.gateway.on()
- Build and link:
npm run build && npm link
- Enable in openclaw.json:
"plugins": {"my-plugin": {"enabled": true}}
Scenario 5: Setting Up Subagents
When asked about parallel agent work:
- Configure subagent settings in openclaw.json
- Agent uses
sessions_spawn tool with task description
- Subagent runs in isolated session
- Results announced back to originating channel
- Transcript preserved for review
- Safety: no sub-sub-agents, no session tools by default
Scenario 6: Configuring QMD Memory
When asked about memory/search:
- Set
memory.backend: "qmd" in openclaw.json
- Choose embedding provider (OpenAI, Gemini, local LLaMA)
- QMD indexes workspace files + session transcripts
- Agent uses memory_search tool for semantic lookup
- State stored at
~/.openclaw/state/memory/qmd/
Best Practices
When Analyzing OpenClaw
- Start with the architecture overview in the project's own docs
- Trace specific flows through the implementation directly
- Reference feature details in the docs as needed
- Consider extension points before proposing changes
When Extending OpenClaw
- Choose correct extension mechanism (skill, plugin, channel, tool)
- Follow security best practices (validation, approval gates)
- Test thoroughly (unit, integration, e2e with Vitest)
- Document clearly (README, examples)
When Debugging
- Check Gateway logs (
openclaw daemon logs or ~/.openclaw/logs/)
- Verify config (
openclaw config validate, allowlists, tool profiles)
- Run diagnostics (
openclaw doctor, openclaw status --all)
- Trace message flow from source to agent
- Test tool execution in isolation
- Verify node pairing and capabilities
- Check QMD indexing status if memory issues
References
Summary
This skill provides expert-level knowledge of OpenClaw's:
- Architecture (Gateway, sessions, agents, channels, nodes, canvas)
- Implementation (TypeScript, Node.js, WebSocket, HTTP, tsdown, Vitest)
- Features (messaging, tools, browser, voice, memory, automation, heartbeats, subagents)
- Extension (skills, plugins, channels, tools, hooks — 32+ extensions, 55+ skills)
- Integration (OpenAI API, webhooks, Tailscale, Docker, OAuth, OpenRouter)
- Memory (workspace files, QMD vectors, session transcripts, compaction)
- Comparison (vs. OpenCode, Claude.ai, ChatGPT)
Use this skill when working with the OpenClaw codebase, extending functionality, debugging issues, or comparing architectural approaches.
1---2name: openclaw-expert3description: Expert guide for OpenClaw's gateway hub-and-spoke architecture, 20+ messaging platform integrations, session management, agent execution, and multi-agent routing.4---56# OpenClaw Expert78You are an expert in the OpenClaw architecture, implementation, and ecosystem. You have comprehensive knowledge of how OpenClaw works, its design decisions, and how to extend it.910## Core Competencies1112### 1. Architecture Understanding13- **Gateway hub-and-spoke model**: Single Gateway coordinates all channels, sessions, clients, and nodes14- **WebSocket + HTTP multiplexing**: Single port (18789) handles control plane and API15- **Session management**: JSONL transcripts, reset policies, identity linking across platforms, compaction (summarization)16- **Agent execution**: Streaming responses, tool orchestration, model failover, subagent spawning17- **Device nodes**: iOS/Android/macOS companions with camera, voice, screen, canvas capabilities18- **Multi-agent routing**: Multiple named agents with per-agent config, workspace, and model selection1920### 2. Messaging Integration21- **20+ platforms**: WhatsApp (Baileys), Telegram (grammY), Discord, Slack, iMessage, Signal, Google Chat, Microsoft Teams, Matrix, Line, BlueBubbles, Zalo, Nostr, Twitch, Nextcloud Talk, Tlon, Mattermost, and more22- **Channel adapters**: Normalize platform messages to common format (core + extension channels)23- **Session scoping**: main, per-sender, per-channel-peer, per-account-channel-peer24- **Identity linking**: Map provider IDs to canonical identities25- **Activation modes**: Mention, reply, always-on, never26- **Voice calls**: Twilio/Telnyx/Plivo integration via voice-call extension2728### 3. Tool Ecosystem29- **30+ built-in tools**: Filesystem, execution, web, browser, messaging, nodes, sessions, memory, automation30- **Security model**: Allowlist/denylist, tool groups, approval gates, sandboxing31- **Browser automation**: CDP + Playwright, AI snapshots with numeric refs32- **Node capabilities**: camera.*, canvas.*, screen.record, location.get, sms.send33- **Tool execution**: Host, Docker sandbox, or device node34- **Subagent tools**: `sessions_spawn` for parallel/background agent work with announcement3536### 4. Memory & Knowledge37- **Workspace files**: AGENTS.md, SOUL.md, TOOLS.md, IDENTITY.md, USER.md, HEARTBEAT.md, BOOTSTRAP.md38- **Daily memory**: `memory/YYYY-MM-DD.md` files in workspace39- **Long-term memory**: `memory.md` in workspace40- **QMD backend**: Opt-in vector memory with SQLite + embeddings (OpenAI, Gemini, or local LLaMA)41- **Session transcripts**: JSONL files at `~/.openclaw/agents/<agentId>/sessions/`42- **Memory search**: `openclaw memory search "topic"`4344### 5. Extension Mechanisms45- **Skills**: SKILL.md format with YAML frontmatter, three-tier loading (workspace → managed → bundled)46- **Plugins**: Node.js plugins with SDK, CLI/tools/handlers registration (32+ extensions)47- **Channels**: Custom platform adapters implementing Channel interface48- **Tools**: Custom tool definitions with execute/executeStream49- **Hooks**: Lifecycle hooks (pre/post/error) for gateway/session/agent/channel events5051### 6. Implementation Patterns52- **Entry point**: Process respawn for Node.js flags, lazy CLI loading53- **Gateway**: TypeBox schemas, AJV validation, client sessions, event broadcasting54- **Sessions**: JSONL storage, reset policies, transcript archival, compaction55- **Agents**: Prompt building, tool execution, streaming, failover, subagent spawning56- **Channels**: Platform SDK wrapping, message normalization, presence handling57- **Build**: tsdown bundling, Oxlint/Oxfmt for linting/formatting, Vitest for testing5859## When to Use This Skill6061### Analyzing OpenClaw Codebase62- Understanding how Gateway coordinates sessions and channels63- Tracing message flow from platform → agent → response64- Identifying extension points for new features65- Debugging session lifecycle or tool execution issues6667### Extending OpenClaw Functionality68- Creating custom skills for agent capabilities69- Building plugins to add CLI commands or tools70- Implementing channel adapters for new platforms71- Developing custom tools with proper security7273### Comparing Architectures74- Contrasting OpenClaw's hub-and-spoke vs. other patterns75- Evaluating local-first vs. cloud-first trade-offs76- Understanding centralized Gateway vs. distributed systems77- Analyzing messaging integration approaches7879### Debugging OpenClaw Issues80- Gateway connection problems81- Session reset policy behavior82- Tool execution failures83- Channel integration issues84- Node pairing and capability invocation85- Memory/QMD indexing problems8687## Key Knowledge8889### Architecture Reference9091For deep architectural detail beyond this summary (data flow diagrams, protocol trade-offs, full feature inventory, source organization), read the OpenClaw project's own documentation and source directly:9293- **Docs**: https://docs.openclaw.ai94- **Source**: https://github.com/openclaw/openclaw95- **Website**: https://openclaw.ai96- **Discord**: https://discord.gg/clawd9798If you have a local checkout of the OpenClaw repository, its `src/` tree (see "Key Files & Locations" below) is generally the fastest way to confirm current behavior — treat this skill's summary as an orientation map, not a substitute for reading the actual implementation when precision matters.99100### Core Concepts101102**Gateway**: Always-on process (systemd/launchd/macOS app) that owns:103- Single connections to messaging platforms (Baileys, grammY, etc.)104- Session state (transcripts, metadata, identity links)105- Connected clients (WebSocket) and nodes106- Tool execution orchestration107- Event broadcasting108- Agents dashboard (web UI)109110**Sessions**: Conversation threads with unique IDs:111- DM: `agent:<agentId>:main` (or per-sender variants)112- Group: `agent:<agentId>:<channel>:group:<groupId>`113- Subagent: `agent:<agentId>:subagent:<uuid>`114- Cron: `cron:<jobId>`115- Webhook: `hook:<uuid>`116- Node: `node-<nodeId>`117- Compaction: summarize old context when window fills118119**Agents**: Isolated execution contexts per session:120- Load conversation history121- Build system prompt (identity + skills + tools)122- Call LLM provider (Anthropic Claude, OpenAI, etc.)123- Stream responses with typing indicators124- Execute tools with approval gates125- Append to JSONL transcript126- Spawn subagents for parallel/background work127128**Channels**: Messaging platform integrations:129- Connect via platform SDK (Baileys, grammY, Discord.js, Bolt, etc.)130- Normalize messages to common format131- Forward to Gateway router132- Receive agent responses133- Send via platform API134- 32+ extensions covering all major platforms135136**Nodes**: Device companions (macOS, iOS, Android):137- Connect with `role: "node"` and capability list138- Require pairing approval139- Expose camera, voice, screen, location, SMS140- Execute via `node.invoke` tool141- Canvas rendering via WebView (A2UI)142143**Tools**: First-class agent capabilities:144- 30+ built-in (read, write, exec, browser, message, etc.)145- Allowlist/denylist per agent146- Approval gates for sensitive operations147- Docker sandboxing option148- Plugin-extensible149150**Skills**: Knowledge injection via SKILL.md:151- YAML frontmatter (name, description, requires, envVars, tools)152- Markdown content (when to use, guidelines, examples)153- Three-tier loading (workspace → managed → bundled)154- 55+ built-in skills155156**Browser**: Web automation via CDP + Playwright:157- Managed browser launch158- AI snapshots with numeric element refs159- Screenshots, navigation, interaction160- JavaScript evaluation161- Per-agent profiles162163**Canvas (A2UI)**: Interactive HTML rendering:164- Canvas Host Server (HTTP, port 18793)165- Node Bridge (TCP, port 18790)166- Present/hide/navigate/eval/snapshot actions167- Live reload on file changes168- Binding: loopback, LAN, Tailscale, or auto169170**Heartbeats**: Proactive background agent:171- Configurable interval (default: 30 minutes, 0 to disable)172- HEARTBEAT.md defines tasks173- Suppresses delivery on HEARTBEAT_OK response174- Full agent turns (tool execution, streaming)175176**QMD Memory**: Opt-in vector search backend:177- SQLite-based with embeddings (OpenAI, Gemini, local LLaMA)178- Indexes workspace files + session transcripts179- Semantic + keyword hybrid search180- State at `~/.openclaw/state/memory/qmd/`181182### Key Files & Locations183184```185src/186├── entry.ts # Application bootstrap187├── cli/run-main.ts # CLI command dispatch188├── commands/ # CLI commands (dashboard, etc.)189├── gateway/index.ts # Gateway server190├── agents/run-agent.ts # Agent execution191├── agents/openclaw-tools.ts # Tool implementations192├── agents/subagent-registry.ts # Subagent system193├── agents/compaction.ts # Session compaction194├── sessions/ # Session management195├── channels/ # Platform adapters196│ ├── whatsapp/197│ ├── telegram/198│ ├── discord/199│ └── ...200├── browser/ # Browser automation201├── canvas-host/ # Canvas/A2UI server202├── memory/qmd-manager.ts # QMD memory backend203├── tools/ # Tool implementations204├── plugins/ # Plugin system205└── plugin-sdk/ # Plugin SDK206extensions/ # 32+ platform/feature extensions207skills/ # 55+ built-in skills208```209210### Config & State Paths211212```213~/.openclaw/214├── openclaw.json # Main config (JSON5)215├── credentials/ # Auth credentials216├── workspace/ # Default agent workspace217│ ├── AGENTS.md # Agent instructions218│ ├── SOUL.md # Identity/personality219│ ├── TOOLS.md # Environment notes220│ ├── IDENTITY.md # Name, emoji, avatar221│ ├── USER.md # About the human222│ ├── HEARTBEAT.md # Periodic tasks223│ └── memory/ # Daily + long-term memory224├── agents/<agentId>/sessions/ # Session transcripts225├── state/memory/qmd/ # QMD vector store226└── logs/ # Application logs227```228229### CLI Commands230231```bash232# Core233openclaw gateway [run] [--port 18789] # Start gateway234openclaw onboard # Onboarding wizard235openclaw setup # Workspace setup236openclaw doctor # Migration/repair237238# Agents239openclaw agents list|add|delete|set-identity240openclaw agent --message "..." [--thinking low|high]241242# Channels243openclaw channels status [--probe] [--deep]244openclaw send --to <target> --message <text>245246# Memory247openclaw memory search "topic"248openclaw memory write <path> "Title"249250# Models & Auth251openclaw models list|set-default252openclaw login253254# Skills255openclaw skills list|install|enable|disable256257# Cron / Heartbeats258openclaw cron list|add|edit|delete|run259260# System261openclaw status [--all] [--deep]262openclaw health [--json]263openclaw security audit [--deep] [--fix]264openclaw update [status|--channel stable|beta|dev]265openclaw dashboard266openclaw config get|set|validate267openclaw nodes list|canvas [present|hide|navigate|eval|snapshot]268```269270### Design Principles2712721. **Single-user by design**: Gateway assumes one owner, simplifies auth2732. **Gateway as authority**: All state owned by Gateway, clients query it2743. **Device-based trust**: Pairing per device, not per user2754. **Protocol-first**: TypeBox schemas generate JSON Schema + Swift models2765. **Idempotent operations**: Side effects require idempotency keys2776. **Lazy command loading**: Only load invoked subcommand for fast startup2787. **Validation-first**: AJV validates all Gateway frames before processing2798. **Multi-agent safety**: Multiple agents can run concurrently with session isolation280281### Common Patterns282283**Message flow**:284```285Platform SDK → Channel Adapter → Gateway Router → Session Manager286 → Agent Executor → Tool Executor → Session Manager → Gateway Router287 → Channel Adapter → Platform SDK288```289290**Tool execution**:291```292LLM tool_use → Validator (allowlist) → Approval Gate → Context Selection293 (host/Docker/node) → Tool Implementation → Result Streaming294 → Agent Continuation295```296297**Subagent spawning**:298```299Agent A → sessions_spawn(task, label) → Gateway → New Session300 → Subagent runs (isolated, no sub-sub-agents)301 → Result announced back to Agent A's channel302```303304**Cross-agent communication**:305```306Agent A → sessions_send(B, msg) → Gateway → Inject to Session B307 → Agent B runs → Result → Agent A receives308```309310**Session compaction**:311```312Context window filling → Compaction agent summarizes old messages313 → Summary replaces old context → Session continues with budget314```315316### Performance Characteristics317- **Message latency**: 100-500ms (channel → agent → response)318- **Concurrent sessions**: 50-100 realistic limit319- **Tool execution**: 1-60s (exec), 2-10s (browser), 100-1000ms (node)320- **WebSocket clients**: 10-20 simultaneous connections321- **Vertical scaling**: Single Gateway, all state in one process322323### Security Model324- **Device pairing**: Challenge-response, approval required325- **Channel allowlists**: Per-platform user/group filtering326- **Tool profiles**: minimal, coding, messaging, full327- **Approval gates**: exec, bash, process, node.invoke, elevated328- **Sandbox isolation**: Docker containers, read-only workspace, resource limits329- **Session isolation**: Separate transcripts, explicit cross-session communication330- **Security audit**: `openclaw security audit [--deep]` built-in331- **Healthcheck skill**: Periodic security hardening checks332333### Integration Points334- **OpenAI API**: `/v1/chat/completions` endpoint for LangChain, LlamaIndex335- **Webhooks**: `/webhook/<path>` for GitHub, CI, external triggers336- **Tailscale**: Serve/Funnel for remote access337- **Docker**: Tool sandboxing with custom images338- **OAuth**: Anthropic (Claude Pro/Max) and OpenAI (ChatGPT/Codex) subscriptions339- **Auth profiles**: Multiple credential rotation with cooldowns/chutes340- **OpenRouter**: Model sync via `openclaw models sync openrouter`341342### Comparison with OpenCode343344| Dimension | OpenClaw | OpenCode |345|-----------|----------|----------|346| **Architecture** | Gateway hub | Client/server (Hono) |347| **Focus** | Multi-channel assistant | Code editing |348| **State** | Gateway-owned persistent | Database/JSON |349| **Execution** | Distributed (nodes) | Server-local |350| **Tools** | 30+ built-in | ~21 + MCP |351| **Device** | Deep (camera, voice, screen, canvas) | Limited (filesystem) |352| **Multi-client** | Many (CLI, UI, mobile, macOS) | TUI/Desktop/Web |353| **Messaging** | 20+ platforms | None |354| **Browser** | First-class (CDP + Playwright) | Via MCP |355| **Persistence** | JSONL transcripts | Sessions in DB |356| **Voice** | Always-on wake + voice calls | None |357| **Memory** | Workspace files + QMD vectors | None |358| **Deployment** | Daemon (systemd/launchd) | Interactive CLI/server |359360**Key insight**: OpenClaw optimizes for **always-on personal assistant** across devices/channels. OpenCode optimizes for **focused coding workflow** in terminal. Complementary, not competing.361362## Example Usage Scenarios363364### Scenario 1: Understanding Gateway Architecture365When asked "How does the Gateway work?", explain:366- Single-port WebSocket + HTTP multiplexer (18789)367- Handshake: connect frame → validation → connect_ack with snapshot368- Request-response pattern with JSON Schema validation (AJV)369- Event broadcasting to all connected clients370- State ownership: sessions, presence, paired devices371- Channel integration: dedicated adapters forward messages to Gateway372- Agents dashboard for web-based management373374### Scenario 2: Tracing Message Flow375When debugging "Why isn't my Telegram message processed?", trace:3761. Telegram SDK receives message3772. Channel adapter normalizes to InboundMessage3783. Check allowlist (user/group)3794. Build session ID based on session scope config3805. Check activation (mention, reply, always-on)3816. Forward to Gateway router3827. Session manager loads/creates session3838. Agent executor builds prompt + calls LLM3849. Stream response back through Gateway → adapter → Telegram385386### Scenario 3: Creating Custom Skill387When asked "How do I teach the agent about X?", guide:3881. Create `~/.openclaw/workspace/skills/my-skill/SKILL.md` (or global `~/.openclaw/skills/`)3892. YAML frontmatter: name, description, requires, envVars, tools3903. Markdown content: when to use, guidelines, examples3914. Optional references/ directory for detailed docs3925. Restart Gateway to reload skills3936. Or manage via dashboard: `openclaw dashboard`394395### Scenario 4: Building Plugin396When extending functionality, explain:3971. Create `extensions/my-plugin/` with package.json + openclaw.plugin.json3982. Implement Plugin interface: initialize(context), shutdown()3993. Register CLI commands via context.cli.addCommand()4004. Register tools via context.toolRegistry.addTool()4015. Register Gateway handlers via context.gateway.on()4026. Build and link: `npm run build && npm link`4037. Enable in openclaw.json: `"plugins": {"my-plugin": {"enabled": true}}`404405### Scenario 5: Setting Up Subagents406When asked about parallel agent work:4071. Configure subagent settings in openclaw.json4082. Agent uses `sessions_spawn` tool with task description4093. Subagent runs in isolated session4104. Results announced back to originating channel4115. Transcript preserved for review4126. Safety: no sub-sub-agents, no session tools by default413414### Scenario 6: Configuring QMD Memory415When asked about memory/search:4161. Set `memory.backend: "qmd"` in openclaw.json4172. Choose embedding provider (OpenAI, Gemini, local LLaMA)4183. QMD indexes workspace files + session transcripts4194. Agent uses memory_search tool for semantic lookup4205. State stored at `~/.openclaw/state/memory/qmd/`421422## Best Practices423424### When Analyzing OpenClaw4251. Start with the architecture overview in the project's own docs4262. Trace specific flows through the implementation directly4273. Reference feature details in the docs as needed4284. Consider extension points before proposing changes429430### When Extending OpenClaw4311. Choose correct extension mechanism (skill, plugin, channel, tool)4322. Follow security best practices (validation, approval gates)4333. Test thoroughly (unit, integration, e2e with Vitest)4344. Document clearly (README, examples)435436### When Debugging4371. Check Gateway logs (`openclaw daemon logs` or `~/.openclaw/logs/`)4382. Verify config (`openclaw config validate`, allowlists, tool profiles)4393. Run diagnostics (`openclaw doctor`, `openclaw status --all`)4404. Trace message flow from source to agent4415. Test tool execution in isolation4426. Verify node pairing and capabilities4437. Check QMD indexing status if memory issues444445## References446447- **GitHub**: https://github.com/openclaw/openclaw448- **Documentation**: https://docs.openclaw.ai449- **Website**: https://openclaw.ai450- **Discord**: https://discord.gg/clawd451452## Summary453454This skill provides expert-level knowledge of OpenClaw's:455- Architecture (Gateway, sessions, agents, channels, nodes, canvas)456- Implementation (TypeScript, Node.js, WebSocket, HTTP, tsdown, Vitest)457- Features (messaging, tools, browser, voice, memory, automation, heartbeats, subagents)458- Extension (skills, plugins, channels, tools, hooks — 32+ extensions, 55+ skills)459- Integration (OpenAI API, webhooks, Tailscale, Docker, OAuth, OpenRouter)460- Memory (workspace files, QMD vectors, session transcripts, compaction)461- Comparison (vs. OpenCode, Claude.ai, ChatGPT)462463Use this skill when working with the OpenClaw codebase, extending functionality, debugging issues, or comparing architectural approaches.