<!-- source: https://deepwiki.com/openclaw/openclaw/3.5.1-command-system -->

# Command System

- .github/workflows/docs-sync-publish.yml
- SECURITY.md
- apps/macos/Sources/OpenClaw/OnboardingView+Pages.swift
- docs/automation/cron-jobs.md
- docs/cli/cron.md
- docs/plugins/hooks.md
- extensions/signal/src/config-schema.test.ts
- extensions/telegram/src/account-selection.ts
- extensions/telegram/src/accounts.test.ts
- extensions/telegram/src/doctor.test.ts
- extensions/telegram/src/doctor.ts
- src/agents/openclaw-tools.sessions.test.ts
- src/agents/tools/agent-step.test.ts
- src/agents/tools/agent-step.ts
- src/agents/tools/sessions-send-tool.ts
- src/agents/tools/sessions.test.ts
- src/auto-reply/reply/context-text.ts
- src/auto-reply/reply/dispatch-acp-command-bypass.test.ts
- src/auto-reply/reply/dispatch-acp-command-bypass.ts
- src/auto-reply/reply/dispatch-acp-delivery.test.ts
- src/auto-reply/reply/dispatch-acp-delivery.ts
- src/auto-reply/reply/dispatch-acp.ts
- src/auto-reply/reply/dispatch-from-config.test.ts
- src/auto-reply/reply/dispatch-from-config.ts
- src/auto-reply/reply/effective-reply-route.test.ts
- src/auto-reply/reply/effective-reply-route.ts
- src/cli/config-cli.test.ts
- src/cli/config-cli.ts
- src/cli/cron-cli.test.ts
- src/cli/cron-cli/register.cron-simple.test.ts
- src/cli/cron-cli/register.cron-simple.ts
- src/cli/cron-cli/shared.cause-display.test.ts
- src/cli/cron-cli/shared.test.ts
- src/cli/cron-cli/shared.ts
- src/cli/daemon-cli/install.test.ts
- src/cli/failure-output.test.ts
- src/cli/plugins-install-persist.test.ts
- src/cli/skills-cli.commands.test.ts
- src/config/group-policy.test.ts
- src/config/group-policy.ts
- src/config/schema.ts
- src/config/validation.channel-metadata.test.ts
- src/cron/cron-protocol-conformance.test.ts
- src/cron/parse.test.ts
- src/cron/parse.ts
- src/cron/service.failure-alert.test.ts
- src/infra/stable-node-path.test.ts
- src/plugin-sdk/acp-runtime-backend.ts
- src/plugin-sdk/acp-runtime.test.ts
- src/plugins/hook-types.ts
- src/secrets/configure-plan.ts
- src/secrets/json-pointer.test.ts
- src/secrets/json-pointer.ts
- src/secrets/path-utils.test.ts
- src/secrets/path-utils.ts
- src/skills/loading/skill-contract.ts

The Command System in OpenClaw provides a unified interface for structured control of agents, sessions, and system configurations. It bridges natural language chat interfaces with structured code execution through textual slash commands (e.g., `/status`, `/model`) and native platform integrations (e.g., Discord Slash Commands, Telegram Bot Commands).

## Overview

OpenClaw's command system is designed to be multi-platform and extensible. It allows users to bypass the LLM execution pipeline for direct system manipulation while providing rich UI elements like choice menus, buttons, and autocomplete on supported platforms.

- Unified Registry : Centralized definitions for all system and plugin commands, allowing both built-in and extended functionality. src/auto-reply/reply/dispatch-from-config.ts 71 src/auto-reply/reply/dispatch-from-config.ts 101-104
- Argument Parsing : Support for positional arguments, typed choices, and "capture remaining" text for natural language instructions. src/auto-reply/reply/dispatch-from-config.ts 102
- Native Integration : Automatic mapping of commands to platform-specific interfaces like Telegram bot commands or Discord slash commands. src/auto-reply/reply/dispatch-from-config.ts 96-99
- Authorization and Policy : Integrated checks for tool policies and agent permissions before command execution. src/auto-reply/reply/dispatch-from-config.ts 19-24

Sources: [src/auto-reply/reply/dispatch-from-config.ts19-24](https://github.com/openclaw/openclaw/blob/fbdf5937/src/auto-reply/reply/dispatch-from-config.ts#L19-L24) [src/auto-reply/reply/dispatch-from-config.ts71](https://github.com/openclaw/openclaw/blob/fbdf5937/src/auto-reply/reply/dispatch-from-config.ts#L71-L71) [src/auto-reply/reply/dispatch-from-config.ts96-104](https://github.com/openclaw/openclaw/blob/fbdf5937/src/auto-reply/reply/dispatch-from-config.ts#L96-L104)

## Command Architecture

The system distinguishes between **Core Commands** (built-in system controls), **Plugin Commands** (extended via the plugin SDK), and **Inline Directives** (flags like `/think` or `/verbose` that modify model behavior).

### Command Detection and Parsing

The command system identifies commands by checking if a message starts with a `/`. The detection logic handles stripping of directives and resolving aliases. Commands can be invoked locally via CLI or remotely via the Gateway.

**Diagram: Natural Language to Code Entity Mapping (Command Detection)**

```

```

Sources: [src/auto-reply/reply/dispatch-from-config.ts100-104](https://github.com/openclaw/openclaw/blob/fbdf5937/src/auto-reply/reply/dispatch-from-config.ts#L100-L104) [src/auto-reply/reply/dispatch-from-config.ts153-158](https://github.com/openclaw/openclaw/blob/fbdf5937/src/auto-reply/reply/dispatch-from-config.ts#L153-L158)

### Execution Pipeline

Command execution is managed within the `dispatch-from-config.ts` module. When a message is dispatched, the system determines if it is a "Native Command Turn" (handled via structured platform metadata) or a "Text Command" (parsed from the message body).

**Diagram: Command Execution Data Flow**

```

```

Sources: [src/auto-reply/reply/dispatch-from-config.ts95-104](https://github.com/openclaw/openclaw/blob/fbdf5937/src/auto-reply/reply/dispatch-from-config.ts#L95-L104) [src/auto-reply/reply/dispatch-from-config.ts71](https://github.com/openclaw/openclaw/blob/fbdf5937/src/auto-reply/reply/dispatch-from-config.ts#L71-L71) [src/auto-reply/reply/dispatch-from-config.ts132](https://github.com/openclaw/openclaw/blob/fbdf5937/src/auto-reply/reply/dispatch-from-config.ts#L132-L132)

## Command Types and Directives

### Directives vs. Commands

- Commands : Standalone instructions starting with / . They execute logic and often return a structured response or UI menu. src/auto-reply/reply/dispatch-from-config.ts 101-104
- Directives : Inline hints (e.g., /think , /verbose , /reasoning ) that modify the execution context without being the primary action. src/auto-reply/reply/dispatch-from-config.ts 114
- Directive Persistence : If a message contains directives, they are parsed and applied to the current session turn, overriding defaults. src/auto-reply/reply/dispatch-from-config.ts 87

### Argument Parsing and Normalization

Commands often require complex argument resolution. For instance, the `sessions.send` tool (which can be invoked via commands) includes logic to normalize aliases for message content like `SendMessage`, `content`, or `text`. [src/agents/tools/sessions-send-tool.ts68-82](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/tools/sessions-send-tool.ts#L68-L82)

**Diagram: Argument Normalization (Sessions Send Example)**

```

```

Sources: [src/agents/tools/sessions-send-tool.ts68-88](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/tools/sessions-send-tool.ts#L68-L88) [src/auto-reply/reply/dispatch-from-config.ts102](https://github.com/openclaw/openclaw/blob/fbdf5937/src/auto-reply/reply/dispatch-from-config.ts#L102-L102)

## Session and Maintenance Commands

Specific commands manage the lifecycle and health of the session:

- /status : Invokes logic to display current model, session ID, and task progress.
- /model : Allows live switching of models during a session. src/auto-reply/reply/dispatch-from-config.ts 27-31
- /cron : Manages Gateway cron jobs and wake events. docs/automation/cron-jobs.md 16-24 src/cli/cron-cli/shared.ts 55-75
- /skills : Manages agent skills, including installation and status reporting. src/cli/skills-cli.commands.test.ts 10-47

Sources: [src/auto-reply/reply/dispatch-from-config.ts27-31](https://github.com/openclaw/openclaw/blob/fbdf5937/src/auto-reply/reply/dispatch-from-config.ts#L27-L31) [docs/automation/cron-jobs.md16-24](https://github.com/openclaw/openclaw/blob/fbdf5937/docs/automation/cron-jobs.md?plain=1#L16-L24) [src/cli/skills-cli.commands.test.ts10-47](https://github.com/openclaw/openclaw/blob/fbdf5937/src/cli/skills-cli.commands.test.ts#L10-L47)

## Implementation Reference

### Key Classes and Functions

Sources: [src/auto-reply/reply/dispatch-from-config.ts96-104](https://github.com/openclaw/openclaw/blob/fbdf5937/src/auto-reply/reply/dispatch-from-config.ts#L96-L104) [src/auto-reply/reply/dispatch-from-config.test.ts17](https://github.com/openclaw/openclaw/blob/fbdf5937/src/auto-reply/reply/dispatch-from-config.test.ts#L17-L17)
