openclaw-agent-builder
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOpenClaw Agent Builder
OpenClaw Agent 构建教程
Create specialized openclaw agents with complete workspace structure, identity files, and skills.
创建具备完整工作区结构、身份文件与技能的专用OpenClaw Agent。
When to Use
适用场景
When building a new openclaw agent for a specific purpose:
- Domain-specific agents (Android dev, SEO, content writing, etc.)
- Multi-agent routing scenarios
- Isolated agent personalities
- Workspace-based AI assistants
当你需要为特定用途构建新的OpenClaw Agent时:
- 领域专用Agent(Android开发、SEO、内容创作等)
- 多Agent路由场景
- 具备独立人格的Agent
- 基于工作区的AI助手
Core Concepts
核心概念
OpenClaw Agent Structure
OpenClaw Agent 结构
Each agent = isolated brain with:
- Workspace: Files (AGENTS.md, SOUL.md, USER.md, IDENTITY.md, TOOLS.md, etc.)
- State dir: (auth, config)
~/.openclaw/agents/<agentId>/agent - Sessions: (chat history)
~/.openclaw/agents/<agentId>/sessions
每个Agent都是一个独立的智能单元,包含:
- 工作区:各类文件(AGENTS.md、SOUL.md、USER.md、IDENTITY.md、TOOLS.md等)
- 状态目录:(存储认证信息、配置)
~/.openclaw/agents/<agentId>/agent - 会话目录:(存储聊天历史)
~/.openclaw/agents/<agentId>/sessions
Workspace Files
工作区文件
Required:
- - Operating instructions, memory management, behavior rules
AGENTS.md - - Persona, tone, communication style
SOUL.md - - User context and how to address them
USER.md - - Agent name, emoji, role, mission
IDENTITY.md - - Tool notes and conventions
TOOLS.md
Optional:
- - Heartbeat checklist (keep short)
HEARTBEAT.md - - Startup checklist when gateway restarts
BOOT.md - - Daily memory logs (YYYY-MM-DD.md)
memory/ - - Curated long-term memory
MEMORY.md - - Workspace-specific skills
skills/
必填文件:
- - 操作指令、内存管理规则、行为规范
AGENTS.md - - 人格设定、语气风格、沟通方式
SOUL.md - - 用户上下文信息及沟通注意事项
USER.md - - Agent名称、表情符号、角色、使命
IDENTITY.md - - 工具说明及使用规范
TOOLS.md
可选文件:
- - 心跳检查清单(保持简洁)
HEARTBEAT.md - - 网关重启时的启动检查清单
BOOT.md - - 每日内存日志(YYYY-MM-DD.md格式)
memory/ - - 整理后的长期知识库
MEMORY.md - - 工作区专属技能
skills/
Agent Builder Workflow
Agent 构建流程
1. Ask Questions First
1. 先明确需求问题
Before building, clarify:
- Agent purpose: What problem does this agent solve?
- Domain expertise: What specialized knowledge needed?
- Communication style: Professional? Casual? Technical?
- Tools/integrations: APIs, databases, external systems?
- Skills needed: Custom capabilities or workflows?
在开始构建前,先明确以下问题:
- Agent用途:该Agent要解决什么问题?
- 领域专业知识:需要哪些专属知识?
- 沟通风格:专业正式?轻松随意?技术向?
- 工具/集成:需要对接哪些API、数据库或外部系统?
- 所需技能:需要哪些自定义能力或工作流?
2. Create Workspace Structure
2. 创建工作区结构
bash
undefinedbash
undefinedCreate agent workspace
Create agent workspace
mkdir -p ~/.openclaw/workspace-<agent-name>
cd ~/.openclaw/workspace-<agent-name>
mkdir -p ~/.openclaw/workspace-<agent-name>
cd ~/.openclaw/workspace-<agent-name>
Initialize git (recommended)
Initialize git (recommended)
git init
undefinedgit init
undefined3. Build Core Files
3. 构建核心文件
IDENTITY.md - Who the agent is:
markdown
undefinedIDENTITY.md - 定义Agent的身份:
markdown
undefinedIDENTITY.md
IDENTITY.md
Name
Name
[Agent Name]
[Agent Name]
Emoji
Emoji
[1-2 relevant emojis]
[1-2 relevant emojis]
Role
Role
[Short role description - e.g., "Android spec writer", "SEO optimizer"]
[Short role description - e.g., "Android spec writer", "SEO optimizer"]
Mission
Mission
[Concise mission statement - what the agent does and why]
**SOUL.md** - Personality and tone:
```markdown[Concise mission statement - what the agent does and why]
**SOUL.md** - 定义人格与语气:
```markdownSOUL.md - [Agent Name]
SOUL.md - [Agent Name]
Who You Are
Who You Are
[Description of expertise, background, strengths]
[Description of expertise, background, strengths]
Your Expertise
Your Expertise
[Domain 1]
[Domain 1]
- [Specific skill or knowledge area]
- [Another capability]
- [Specific skill or knowledge area]
- [Another capability]
[Domain 2]
[Domain 2]
- [Capability]
- [Capability]
Your Approach
Your Approach
[Trait 1 - e.g., Analytical, Pragmatic]
[Trait 1 - e.g., Analytical, Pragmatic]
- [How this manifests]
- [How this manifests]
[Trait 2]
[Trait 2]
- [Behavior pattern]
- [Behavior pattern]
Your Tone
Your Tone
[Communication style - concise/verbose, formal/casual, technical level]
[Communication style - concise/verbose, formal/casual, technical level]
Your Values
Your Values
- [Value 1] - [Why it matters]
- [Value 2] - [Explanation]
**AGENTS.md** - Operating instructions:
```markdown- [Value 1] - [Why it matters]
- [Value 2] - [Explanation]
**AGENTS.md** - 操作指令:
```markdownAGENTS.md - [Agent Name]
AGENTS.md - [Agent Name]
[Brief agent description and primary role]
[Brief agent description and primary role]
Primary Responsibilities
Primary Responsibilities
- [Task 1] - [Description]
- [Task 2] - [Description]
- [Task 1] - [Description]
- [Task 2] - [Description]
Workflow
Workflow
On User Request: "[Trigger Pattern]"
On User Request: "[Trigger Pattern]"
-
[Step 1] [Action description] [Details, commands, or sub-steps]
-
[Step 2] [Next action]
-
[Step 1] [Action description] [Details, commands, or sub-steps]
-
[Step 2] [Next action]
On User Request: "[Another Pattern]"
On User Request: "[Another Pattern]"
[Workflow steps]
[Workflow steps]
[Domain-Specific Section - e.g., "iOS Codebase Structure"]
[Domain-Specific Section - e.g., "iOS Codebase Structure"]
[Relevant context, file paths, patterns]
[Relevant context, file paths, patterns]
[Another Section - e.g., "Translation Guidelines"]
[Another Section - e.g., "Translation Guidelines"]
[Reference tables, mappings, rules]
[Reference tables, mappings, rules]
Memory
Memory
- Log [what to track] in
memory/YYYY-MM-DD.md - [Memory strategy specific to agent purpose]
- Log [what to track] in
memory/YYYY-MM-DD.md - [Memory strategy specific to agent purpose]
Tools
Tools
See for [domain-specific tools or integrations]
TOOLS.mdSee for [domain-specific tools or integrations]
TOOLS.mdSkills
Skills
- [skill-name] - [Purpose]
- [another-skill] - [Purpose]
**USER.md** - User context:
```markdown- [skill-name] - [Purpose]
- [another-skill] - [Purpose]
**USER.md** - 用户上下文信息:
```markdownUSER.md
USER.md
Who You Are
Who You Are
[User description, preferences, context]
[User description, preferences, context]
Your Goals
Your Goals
[What user wants to achieve with this agent]
[What user wants to achieve with this agent]
Communication Preferences
Communication Preferences
[How user prefers to interact]
**TOOLS.md** - Tool conventions:
```markdown[How user prefers to interact]
**TOOLS.md** - 工具使用规范:
```markdownTOOLS.md
TOOLS.md
[Domain] Tools
[Domain] Tools
- [Tool/API name]: [Purpose and usage notes]
- [Another tool]: [Notes]
- [Tool/API name]: [Purpose and usage notes]
- [Another tool]: [Notes]
Authentication
Authentication
[If agent needs API keys, credentials, etc.]
[If agent needs API keys, credentials, etc.]
Conventions
Conventions
[Domain-specific conventions or patterns]
undefined[Domain-specific conventions or patterns]
undefined4. Add Skills (Optional)
4. 添加技能(可选)
Create workspace-specific skills:
bash
mkdir -p skills/<skill-name>Each skill needs :
SKILL.mdmarkdown
---
name: skill-name
description: What the skill does
---创建工作区专属技能:
bash
mkdir -p skills/<skill-name>每个技能都需要文件:
SKILL.mdmarkdown
---
name: skill-name
description: What the skill does
---Skill Name
Skill Name
[Skill documentation following agentskills.io format]
[Skill documentation following agentskills.io format]
When to Use
When to Use
[Trigger conditions]
[Trigger conditions]
Steps
Steps
[Detailed workflow]
[Detailed workflow]
Examples
Examples
[Usage examples]
undefined[Usage examples]
undefined5. Setup Memory System
5. 设置内存系统
bash
mkdir -p memory
touch memory/$(date +%Y-%m-%d).mdOptional for curated knowledge:
MEMORY.mdmarkdown
undefinedbash
mkdir -p memory
touch memory/$(date +%Y-%m-%d).md可选创建用于存储整理后的知识库:
MEMORY.mdmarkdown
undefinedMEMORY.md
MEMORY.md
[Category]
[Category]
- [Key fact or pattern]
- [Lesson learned]
- [Key fact or pattern]
- [Lesson learned]
[Another Category]
[Another Category]
[Organized knowledge]
undefined[Organized knowledge]
undefined6. Register Agent
6. 注册Agent
bash
undefinedbash
undefinedAdd agent to openclaw
Add agent to openclaw
openclaw agents add <agent-name>
openclaw agents add <agent-name>
Set workspace path
Set workspace path
Edit ~/.openclaw/openclaw.json:
Edit ~/.openclaw/openclaw.json:
{
"agents": {
"list": [
{
"id": "<agent-name>",
"workspace": "~/.openclaw/workspace-<agent-name>"
}
]
}
}
undefined{
"agents": {
"list": [
{
"id": "<agent-name>",
"workspace": "~/.openclaw/workspace-<agent-name>"
}
]
}
}
undefined7. Add Bindings (Multi-Agent Routing)
7. 添加路由绑定(多Agent路由)
Route specific channels/users to this agent:
json5
{
"bindings": [
{
"agentId": "<agent-name>",
"match": {
"channel": "whatsapp",
"peer": { "kind": "direct", "id": "+1234567890" }
}
}
]
}将特定渠道/用户的请求路由到该Agent:
json5
{
"bindings": [
{
"agentId": "<agent-name>",
"match": {
"channel": "whatsapp",
"peer": { "kind": "direct", "id": "+1234567890" }
}
}
]
}Design Principles
设计原则
Agent Identity
Agent 身份设定
- Clear purpose: Single, focused responsibility
- Distinct personality: Unique tone/approach vs other agents
- Expertise depth: Deep knowledge in specific domain
- 明确用途:单一、聚焦的职责
- 独特人格:与其他Agent有区分度的语气/行事方式
- 专业深度:在特定领域具备深厚知识
Communication Style
沟通风格
- Concise: Default to brevity unless domain requires detail
- Professional: Match industry standards
- Actionable: Focus on what to do, not just description
- 简洁明了:默认采用简洁表述,除非领域需要详细说明
- 符合专业规范:匹配行业标准
- 注重可执行性:聚焦具体操作,而非单纯描述
Memory Strategy
内存策略
- Daily logs: Track important events/decisions
- Curated knowledge: Extract patterns into MEMORY.md
- Context preservation: Save state before or
/new/reset
- 每日日志:记录重要事件/决策
- 整理知识库:将规律提炼至
MEMORY.md - 保留上下文:在执行或
/new前保存状态/reset
Skill Organization
技能组织
- Workspace skills: Agent-specific capabilities
- Shared skills: Common utilities in
~/.openclaw/skills/ - Override pattern: Workspace skills override shared/bundled
- 工作区专属技能:仅适用于当前Agent的能力
- 共享技能:通用工具存放在
~/.openclaw/skills/ - 覆盖规则:工作区技能优先级高于共享/内置技能
Example Agents
示例Agent
Android Spec Generator
Android 规格生成器
Purpose: Analyze iOS features, generate Android requirement specs
Style: Concise, technical, requirement-focused
Skills: ios-analyzer, android-spec-generator, github-issue-creatorPurpose: Analyze iOS features, generate Android requirement specs
Style: Concise, technical, requirement-focused
Skills: ios-analyzer, android-spec-generator, github-issue-creatorSEO Expert
SEO 专家
Purpose: Content optimization, keyword research, SEO strategy
Style: Data-driven, analytical, actionable
Skills: keyword-research, content-analyzer, competitor-analysisPurpose: Content optimization, keyword research, SEO strategy
Style: Data-driven, analytical, actionable
Skills: keyword-research, content-analyzer, competitor-analysisContent Writer
内容创作者
Purpose: Blog posts, documentation, technical writing
Style: Clear, engaging, audience-aware
Skills: content-planner, seo-writer, editorPurpose: Blog posts, documentation, technical writing
Style: Clear, engaging, audience-aware
Skills: content-planner, seo-writer, editorAnti-Patterns
反模式
❌ Don't:
- Mix multiple unrelated domains in one agent
- Create verbose, chatty agents unless purpose requires it
- Duplicate content across AGENTS.md, SOUL.md, TOOLS.md
- Store secrets in workspace (use )
~/.openclaw/credentials/
✅ Do:
- Keep single, clear focus per agent
- Match communication style to domain norms
- Organize by responsibility (identity/soul/operations)
- Use git for workspace backup (private repo)
❌ 请勿:
- 在一个Agent中混合多个无关领域
- 创建冗长、闲聊式的Agent,除非其用途需要
- 在AGENTS.md、SOUL.md、TOOLS.md中重复内容
- 在工作区存储密钥(请使用)
~/.openclaw/credentials/
✅ 建议:
- 每个Agent保持单一、明确的聚焦点
- 沟通风格匹配领域常规
- 按职责划分内容(身份/人格/操作)
- 使用Git备份工作区(私有仓库)
Testing Agent
测试Agent
bash
undefinedbash
undefinedStart gateway with agent
Start gateway with agent
openclaw gateway --agent <agent-name>
openclaw gateway --agent <agent-name>
Or use binding to route to agent
Or use binding to route to agent
openclaw gateway
openclaw gateway
Send test message via WhatsApp/Telegram/Discord
Send test message via WhatsApp/Telegram/Discord
Verify agent responds with expected personality/capability
Verify agent responds with expected personality/capability
undefinedundefinedMaintenance
维护
Update Agent
更新Agent
bash
cd ~/.openclaw/workspace-<agent-name>
git add .
git commit -m "Update [what changed]"
git pushbash
cd ~/.openclaw/workspace-<agent-name>
git add .
git commit -m "Update [what changed]"
git pushAdd New Skill
添加新技能
bash
cd ~/.openclaw/workspace-<agent-name>/skills
mkdir new-skillbash
cd ~/.openclaw/workspace-<agent-name>/skills
mkdir new-skillCreate SKILL.md
Create SKILL.md
undefinedundefinedBackup Agent
备份Agent
bash
undefinedbash
undefinedWorkspace already in git
Workspace already in git
Separately backup sessions if needed:
Separately backup sessions if needed:
tar -czf sessions-backup.tar.gz ~/.openclaw/agents/<agent-name>/sessions/
undefinedtar -czf sessions-backup.tar.gz ~/.openclaw/agents/<agent-name>/sessions/
undefinedResources
参考资源
Questions Before Building?
构建前需确认的问题
Ask user to clarify:
- Agent purpose and scope
- Communication style preferences
- Required integrations/APIs
- Routing strategy (dedicated channel vs shared)
- Skill requirements
请让用户明确以下信息:
- Agent的用途与范围
- 沟通风格偏好
- 所需的集成/API
- 路由策略(专属渠道 vs 共享渠道)
- 技能需求