Add OpenClaw Agent
Create a new isolated OpenClaw agent and configure it (identity + role + task) in its workspace.
When this skill applies
- - User asks to create a new agent (by name).
- User wants to give that agent an identity (display name, emoji, theme, avatar) or a task/purpose (persona, rules, scope).
Workflow (recommended)
0. Ask what the new agent is for (required)
- - Ask the user what they want the new agent to do.
- Ask for any constraints that affect identity and rules (language, tone, safety boundaries, sources allowed, output format, etc.).
Then pick an agent-name based on the purpose. Prefer short, stable ids like:
- -
beauty, coding, support, ops, research, INLINECODE6
Notes:
- - OpenClaw normalizes names to an agent id (lowercase; invalid characters collapse to
-). The id cannot be main (reserved). - Use the normalized id in the workspace directory:
~/.openclaw/workspace-<agent-id>.
1. Create the agent with exec (non-interactive, JSON)
Use the exec tool to run the OpenClaw CLI. Non-interactive creation requires --workspace and --non-interactive.
Before creating, check whether it already exists:
CODEBLOCK0
Before running creation, explicitly ask for confirmation, for example:
Only execute the command after the user confirms.
Create the agent:
CODEBLOCK1
Optional flags you can add when needed:
- -
--model <id> – default model for this agent. - INLINECODE14 – agent state dir (default:
~/.openclaw/agents/<id>/agent). - INLINECODE16 – route a channel to this agent (repeatable).
2. Configure identity by editing IDENTITY.md (then sync)
Edit the new workspace file:
The top section is a template with identity key-value lines (examples):
- - INLINECODE18
- INLINECODE19
- INLINECODE20
- INLINECODE21
Supported keys: name, emoji, theme, creature, vibe, avatar.
Hard rule (IDENTITY.md):
- - Only edit the identity field lines (the
- **Name:** ... style lines / key-value fields). - Do not rewrite, delete, or reorder any other template text above the separator.
- Any additional identity/role description must be appended after the
--- separator. - If the file does not contain
---, add a blank line and then a --- line at the end, and append your description after it. - Tool priority for file changes: prefer
edit for targeted append/update; use write only when edit cannot be applied reliably (for example file missing or malformed beyond safe patching).
Short example (append style):
CODEBLOCK2
After editing, sync to config via exec:
CODEBLOCK3
3. Configure role + task + operating rules in AGENTS.md
Edit the new workspace file:
Put task definition and operating rules here (how to work), based on what the user told you in step 0. Examples of good content:
- - What this agent is responsible for (scope)
- What it must not do (red lines)
- The question-asking checklist before acting
- Output format expectations (bullets, structure, brevity)
- Tooling rules (when to use exec; avoid destructive commands unless asked)
Hard rule (AGENTS.md):
- - Do not rewrite, delete, or reorder the default template content.
- Add all custom “role/task/rules” content only by appending after the
--- separator. - If the file has no
---, add a blank line + --- near the end, then append your custom section after it. - Tool priority for file changes: prefer
edit for targeted append/update; use write only when edit cannot be applied reliably (for example file missing or malformed beyond safe patching).
Short example (append style):
CODEBLOCK4
If you also want a stable persona/tone/boundary file, place that in SOUL.md too, but keep the core “how to operate” rules in AGENTS.md.
End-to-end flow (summary)
- 1. Ask what the new agent is for (purpose + constraints).
- Choose
<agent-name> (short, stable; will normalize to <agent-id>). - INLINECODE46
- Edit INLINECODE47
- INLINECODE48
- Edit
~/.openclaw/workspace-<agent-id>/AGENTS.md with the role/task/rules.
References
添加 OpenClaw 代理
创建一个新的独立 OpenClaw 代理,并在其工作区中配置(身份 + 角色 + 任务)。
适用场景
- - 用户要求创建一个新代理(按名称)。
- 用户希望为该代理赋予身份(显示名称、表情符号、主题、头像)或任务/目的(角色、规则、范围)。
工作流程(推荐)
0. 询问新代理的用途(必需)
- - 询问用户希望新代理做什么。
- 询问任何影响身份和规则的约束条件(语言、语气、安全边界、允许使用的来源、输出格式等)。
然后根据用途选择一个代理名称。优先选择简短、稳定的标识符,例如:
- - beauty、coding、support、ops、research、personal
注意:
- - OpenClaw 会将名称规范化为代理 ID(小写;无效字符会合并为-)。ID 不能是main(保留名称)。
- 在工作区目录中使用规范化后的 ID:~/.openclaw/workspace-<代理-id>
1. 使用 exec 创建代理(非交互式,JSON)
使用 exec 工具运行 OpenClaw CLI。非交互式创建需要--workspace和--non-interactive参数。
创建前,先检查代理是否已存在:
bash
openclaw agents list --json
在执行创建命令前,明确请求用户确认,例如:
- - 我已准备好运行:openclaw agents add <代理名称> --workspace ~/.openclaw/workspace-<代理-id> --non-interactive --json。现在运行吗?
仅在用户确认后才执行命令。
创建代理:
bash
openclaw agents add <代理名称> --workspace ~/.openclaw/workspace-<代理-id> --non-interactive --json
可根据需要添加的可选标志:
- - --model – 该代理的默认模型。
- --agent-dir – 代理状态目录(默认:~/.openclaw/agents//agent)。
- --bind – 将通道路由到此代理(可重复使用)。
2. 通过编辑 IDENTITY.md 配置身份(然后同步)
编辑新的工作区文件:
- - ~/.openclaw/workspace-<代理-id>/IDENTITY.md
顶部区域是一个包含身份键值行的模板(示例):
- - name: My Agent
- emoji: 🦞
- theme: short theme
- avatar: path/or/url
支持的键:name、emoji、theme、creature、vibe、avatar。
硬性规则(IDENTITY.md):
- - 仅编辑身份字段行(- Name: ... 样式行 / 键值字段)。
- 不要重写、删除或重新排序分隔符上方的任何其他模板文本。
- 任何额外的身份/角色描述必须附加在---分隔符之后。
- 如果文件中不包含---,则在末尾添加一个空行,然后添加一行---,并在其后附加你的描述。
- 文件更改的工具优先级:优先使用edit进行有针对性的追加/更新;仅在edit无法可靠应用时(例如文件缺失或格式错误无法安全修补)才使用write。
简短示例(追加样式):
md
...(保留/更新现有身份字段)
我负责:根据肤质/预算/场景给出 2-3 个可选方案,并说明优缺点与使用顺序。
编辑后,通过 exec 同步到配置:
bash
openclaw agents set-identity --workspace ~/.openclaw/workspace-<代理-id> --from-identity --json
3. 在 AGENTS.md 中配置角色 + 任务 + 操作规则
编辑新的工作区文件:
- - ~/.openclaw/workspace-<代理-id>/AGENTS.md
根据用户在步骤 0 中提供的信息,在此处放置任务定义和操作规则(如何工作)。好的内容示例:
- - 该代理负责什么(范围)
- 它不能做什么(红线)
- 行动前的问题检查清单
- 输出格式期望(要点、结构、简洁性)
- 工具使用规则(何时使用 exec;除非被要求,否则避免破坏性命令)
硬性规则(AGENTS.md):
- - 不要重写、删除或重新排序默认模板内容。
- 所有自定义的“角色/任务/规则”内容仅通过附加在---分隔符之后添加。
- 如果文件中没有---,在末尾附近添加一个空行 + ---,然后在其后附加你的自定义部分。
- 文件更改的工具优先级:优先使用edit进行有针对性的追加/更新;仅在edit无法可靠应用时(例如文件缺失或格式错误无法安全修补)才使用write。
简短示例(追加样式):
md
...(保持默认模板不变)
美妆助手工作规范
- - 先问:肤质/预算/诉求/过敏史
- 再给:2-3 个方案 + 优缺点 + 价格区间
- 禁止:假装亲测;推荐三无/杂牌
如果你还想要一个稳定的角色/语气/边界文件,也可以将其放在SOUL.md中,但核心的“如何操作”规则应保留在AGENTS.md中。
端到端流程(总结)
- 1. 询问新代理的用途(目的 + 约束条件)。
- 选择<代理名称>(简短、稳定;将规范化为<代理-id>)。
- openclaw agents add <代理名称> --workspace ~/.openclaw/workspace-<代理-id> --non-interactive --json
- 编辑~/.openclaw/workspace-<代理-id>/IDENTITY.md
- openclaw agents set-identity --workspace ~/.openclaw/workspace-<代理-id> --from-identity --json
- 使用角色/任务/规则编辑~/.openclaw/workspace-<代理-id>/AGENTS.md
参考
- - 多代理路由和路径:多代理路由、代理工作区。
- CLI:openclaw agents add、openclaw agents set-identity、openclaw agents bind,详见代理 CLI。