A complete technical reference for the OpenClaw agent system prompt architecture — every piece of text injected into the system prompt and user messages, where it comes from, and when it fires.
OpenClaw is a Node.js-based LLM agent framework that manages AI agent personalities, workspace context, memory, and multi-channel messaging (e.g. Slack). Agents are configured via a workspace directory of Markdown files and a central openclaw.json config file.
| Path | Description |
|---|---|
PROMPT-ANATOMY.md |
Complete map of the system prompt pipeline |
reference/system-prompt/ |
25 system prompt sections (01--20, 21a--21d, 22) assembled every turn (manifest) |
reference/user-messages/ |
Prompts sent as user messages (read-only docs) |
reference/config/ |
Default config values affecting prompt behavior |
reference/skills/ |
Skills prompt XML template |
workspace/defaults/ |
Editable workspace templates (AGENTS.md, SOUL.md, IDENTITY.md, etc.) |
workspace/dev-variants/ |
Dev agent (C-3PO) workspace templates |
prompts/manifest.json |
Machine-readable index of all prompts with metadata |
sync-prompts.sh |
Sync edited templates back to an OpenClaw installation |
See prompts/README.md for detailed descriptions of every file.
Edit workspace templates in workspace/defaults/, then sync them back to your OpenClaw installation:
# Preview what would change
./sync-prompts.sh --dry-run
# Sync workspace files to OpenClaw
./sync-prompts.sh
# Target a specific installation
./sync-prompts.sh --openclaw-path /path/to/openclaw
# Restart to pick up changes
openclaw gateway restartPROMPT-ANATOMY.md documents the full prompt construction pipeline assembled by buildAgentSystemPrompt(). It covers:
- System Prompt Builder — 25 entries (sections 01--20, 21a--21d, 22) assembled every turn, in order (identity, tooling, safety, workspace context, runtime info, etc.)
- Workspace Files — the Markdown files (
AGENTS.md,SOUL.md,IDENTITY.md,USER.md,MEMORY.md, etc.) loaded from the workspace directory and injected into every prompt - Heartbeat System — periodic background checks sent as user messages on a configurable timer
- Session Reset Prompt — the message injected on
/newor/reset - Post-Compaction Refresh — context re-injection after conversation compaction
- Memory Flush Prompts — triggered when the transcript exceeds soft/hard token thresholds
- Memory Recall Prompt — injected when memory tools are available
- Skills Prompt — XML block advertising installed ClawHub skills
- Inbound Context — per-message trusted metadata (channel, surface, account, etc.)
- Config Reference — the
openclaw.jsonkeys that affect prompt behavior
[System Prompt]
├── Identity (from IDENTITY.md)
├── ## Tooling (available tools list)
├── ## Tool Call Style
├── ## Safety
├── ## Skills (available skills XML)
├── ## Model Aliases (from config)
├── ## Workspace (working directory)
├── ## Documentation (docs path)
├── ## Current Date & Time
├── ## Workspace Files (injected)
│ └── # Project Context
│ ├── AGENTS.md
│ ├── SOUL.md
│ ├── TOOLS.md
│ ├── IDENTITY.md
│ ├── USER.md
│ ├── HEARTBEAT.md
│ ├── BOOTSTRAP.md (if present)
│ └── MEMORY.md
├── ## Silent Replies (NO_REPLY rules)
├── ## Heartbeats (HEARTBEAT_OK rules)
├── ## Runtime (model, host, channel info)
├── ## Reply Tags
├── ## Messaging (routing rules)
├── ## Inbound Context (per-message JSON metadata)
└── ## Reactions (if configured)
[User Message]
├── The actual user text
├── OR: HEARTBEAT_PROMPT (on heartbeat tick)
├── OR: BARE_SESSION_RESET_PROMPT (on /new or /reset)
├── OR: Post-compaction refresh (after compaction)
└── OR: Memory flush prompt (when transcript too large)
| Path | Effect |
|---|---|
agents.defaults.heartbeat.every |
Heartbeat interval (e.g. "30m") |
agents.defaults.heartbeat.prompt |
Custom heartbeat prompt override |
agents.defaults.model |
Default LLM model |
agents.defaults.extraSystemPrompt |
Additional text injected into system prompt |
agents.defaults.memoryFlush.* |
Memory flush thresholds and prompts |
channels.defaults.heartbeat |
Heartbeat visibility (show/suppress per channel) |
agents.{agentId}.* |
Per-agent overrides of all the above |
OpenClaw runs as a Node.js package. The key functions and modules are:
| Function / Constant | Module | Purpose |
|---|---|---|
buildAgentSystemPrompt() |
Main agent runtime bundle | Assembles the full system prompt every turn |
HEARTBEAT_PROMPT |
Main agent runtime bundle | Heartbeat user-message constant |
loadWorkspaceBootstrapFiles() |
Agent scope module | Loads workspace Markdown files into context |
| (heartbeat visibility logic) | Heartbeat visibility module | Heartbeat channel visibility / suppression |
/usr/lib/node_modules/openclaw/docs |
— | Built-in documentation referenced in system prompt |
/usr/lib/node_modules/openclaw/skills/ |
— | Built-in skills directory |
OpenClaw bundles are minified with hash suffixes that change each build. To find the relevant code in any installation:
grep -r "buildAgentSystemPrompt" /path/to/openclaw/
grep -r "loadWorkspaceBootstrapFiles" /path/to/openclaw/
grep -r "HEARTBEAT_PROMPT" /path/to/openclaw/MIT