@clawhub-freesaber-b4360eeb4c
Automatically create a new OpenClaw agent, translate its name, and initialize its persona/system prompt based on user requests.
---
name: create_agent
description: Automatically create a new OpenClaw agent, translate its name, and initialize its persona/system prompt based on user requests.
parameters:
type: object
properties:
agent_name_en:
type: string
description: "The translated English short ID for the agent. Snake_case, lowercase only. Example: 'java_expert'."
agent_display_name:
type: string
description: "The friendly display name for the agent, written in the same language as the user's request unless the user specifies another language. Example: 'Java高级专家' or 'Senior Java Expert'."
identity_prompt:
type: string
description: "A highly detailed persona description and system prompt, written in the same language as the user's request unless the user specifies another language."
required:
- agent_name_en
- agent_display_name
- identity_prompt
---
# Agent Creator Skill
When a user asks you to create a new agent, assistant, or proxy (e.g., "创建一个Java高级开发的代理", "Help me build a product manager agent"), you MUST use this skill to accomplish the task.
## SOP (Standard Operating Procedure):
1. **Translation**: Translate the requested role into a short English snake_case string. This will be the `<agent_name_en>`.
2. **Language Matching**: Detect the primary language of the user's request. Use that language for both `<agent_display_name>` and `<identity_prompt>`, unless the user explicitly asks for another language.
3. **Persona Generation**: Generate a professional, highly detailed system prompt for this specific role. This will be the `<identity_prompt>`.
4. **Execution**: Choose the script that matches the user's operating system:
- On Linux, macOS, WSL, or Git Bash:
```bash
bash {baseDir}/create_agent.sh "<agent_name_en>" "<agent_display_name>" "<identity_prompt>"
```
- On native Windows PowerShell:
```powershell
powershell -ExecutionPolicy Bypass -File "{baseDir}/create_agent.ps1" -AgentId "<agent_name_en>" -DisplayName "<agent_display_name>" -IdentityPrompt "<identity_prompt>"
```
FILE:create_agent.sh
#!/bin/bash
# ==========================================
# OpenClaw automated agent creation script, optimized for openclaw.json
# $1: agent_id, for example: product_manager
# $2: agent_display_name, for example: Product Manager
# $3: identity_prompt, detailed persona/system prompt
# ==========================================
if [ "$#" -ne 3 ]; then
echo "❌ Error: Invalid number of arguments."
exit 1
fi
AGENT_ID=$1
DISPLAY_NAME=$2
PERSONA=$3
WORKSPACE_DIR="$HOME/.openclaw/workspace-AGENT_ID"
# Main OpenClaw configuration file
CONFIG_FILE="$HOME/.openclaw/openclaw.json"
echo "🚀 [1/3] Creating Agent ID: AGENT_ID..."
# ------------------------------------------
# Step 1: Create the base agent entry
# ------------------------------------------
if openclaw agents add "AGENT_ID" --workspace "WORKSPACE_DIR"; then
echo "✅ Base agent entry created."
else
echo "❌ Agent creation failed. The ID [AGENT_ID] may already exist."
exit 1
fi
# ------------------------------------------
# Step 2: Update the display name in openclaw.json
# ------------------------------------------
echo "📝 [2/3] Updating CONFIG_FILE with display name: DISPLAY_NAME..."
if [ -f "$CONFIG_FILE" ]; then
# Use Python to update agents -> list -> name in the JSON config.
AGENT_ID="$AGENT_ID" DISPLAY_NAME="$DISPLAY_NAME" CONFIG_FILE="$CONFIG_FILE" python3 <<'PY'
import json, os
path = os.path.expanduser(os.environ['CONFIG_FILE'])
agent_id = os.environ['AGENT_ID']
display_name = os.environ['DISPLAY_NAME']
with open(path, 'r', encoding='utf-8') as f:
data = json.load(f)
# Find the matching agent in agents -> list.
agents_list = data.get('agents', {}).get('list', [])
found = False
for agent in agents_list:
if agent.get('id') == agent_id:
agent['name'] = display_name
found = True
break
if found:
with open(path, 'w', encoding='utf-8') as f:
json.dump(data, f, ensure_ascii=False, indent=2)
print(f'✅ Updated the name for ID [{agent_id}] to [{display_name}]')
else:
print('⚠️ No matching agent entry found in openclaw.json')
PY
else
echo "❌ Error: Config file not found: $CONFIG_FILE"
exit 1
fi
# ------------------------------------------
# Step 3: Inject the persona/system prompt
# ------------------------------------------
echo "🧠 [3/3] Injecting persona for ID [AGENT_ID]..."
FULL_MESSAGE=$(printf 'Remember your identity and operating instructions:\n%s' "$PERSONA")
if openclaw agent --agent "AGENT_ID" --message "FULL_MESSAGE"; then
echo "✅ Persona injection completed."
else
echo "❌ Persona injection failed. Please check the agent status manually."
fi
echo "🎉 SUCCESS! Agent [DISPLAY_NAME] is ready."
exit 0
FILE:README.md
# OpenClaw Agent Creator Skill
A lightweight skill for OpenClaw. Once installed, you can use natural language to command the Main Agent (Lobster) to automatically create, configure, and initialize other **independent Agents (not sub-agents)**.
## 💡 How It Works
1. **Command:** The Main Agent receives a natural language instruction (e.g., "Use agent-creator to create an agent expert in Python web scraping").
2. **Design:** The Main Agent consults the specifications in `SKILL.md`, automatically formats the agent ID (e.g., `python_spider_expert`), creates a friendly display name, and writes a detailed system prompt in the same language as the user's request unless another language is explicitly requested.
3. **Execution:** The Main Agent automatically calls the matching script for the current system, such as `bash create_agent.sh "python_spider_expert" "Python Web Scraping Expert" "You are a senior..."` on Linux/macOS/WSL/Git Bash, or `powershell -ExecutionPolicy Bypass -File create_agent.ps1 -AgentId "python_spider_expert" -DisplayName "Python Web Scraping Expert" -IdentityPrompt "You are a senior..."` on native Windows PowerShell.
4. **Initialization:** The selected script executes `openclaw agents add` and `openclaw agent --message`, instantly completing the environment setup and memory injection for the new Agent.
## 🚀 Installation
### Option 1: Conversational Online Installation (Recommended)
As long as this project is hosted on GitHub, you can simply send a command to your OpenClaw Main Agent:
> "Help me install this skill: https://github.com/freesaber/agent-creator-skill"
The Main Agent will automatically pull the code, configure it, and enable the skill.
### Option 2: Manual Offline Installation
If you are developing or debugging locally:
1. Place this folder into the `~/.openclaw/workspace/skills/` directory. On native Windows, the equivalent path is usually `%USERPROFILE%\.openclaw\workspace\skills\`.
2. On Linux/macOS/WSL/Git Bash, enter the directory and ensure the shell script has execution permissions: `chmod +x create_agent.sh`. On native Windows PowerShell, use `create_agent.ps1`; no chmod step is required.
3. Restart OpenClaw or wait for the Main Agent to reload its skills.
## 💬 Usage Examples & Notes
Due to the inherent logic of many Large Language Models, they may sometimes assume they are creating "sub-agents" under themselves. To ensure the command executes accurately, it is recommended to be explicit during the conversation:
✅ **Recommended Phrases:**
> "Use the agent-creator skill to create an agent proficient in Java Senior Development. Note: create an **independent peer agent**, do not create a sub-agent."
> "Help me build a Product Manager agent. It must be an **independent agent**, not your sub-agent."
Once execution is successful, the Main Agent will report the new Agent's name and its workspace path. You can then begin working with your new Agent immediately!
FILE:README.zh-CN.md
# OpenClaw Agent Creator Skill
一个轻量级的 OpenClaw 技能。安装后,你可以通过口语化的方式,让主 Agent(龙虾)自动帮你创建、配置并初始化其他的 **独立 Agent(非子代理)**。
## 💡 工作原理
1. 主 Agent 接收到自然语言指令(例:"使用 agent-creator 创建一个精通Python爬虫的代理")。
2. 主 Agent 查阅 `SKILL.md` 的规范,自动将 Agent ID 翻译为 `python_spider_expert`,生成友好的显示名称,并根据用户请求的语言撰写详细的专属身份提示词;除非用户明确指定其他语言。
3. 主 Agent 会根据当前系统自动调用对应脚本。例如 Linux/macOS/WSL/Git Bash 使用:`bash create_agent.sh "python_spider_expert" "Python爬虫专家" "你是一个资深..."`;原生 Windows PowerShell 使用:`powershell -ExecutionPolicy Bypass -File create_agent.ps1 -AgentId "python_spider_expert" -DisplayName "Python爬虫专家" -IdentityPrompt "你是一个资深..."`。
4. 选中的系统脚本会自动执行 `openclaw agents add` 和 `openclaw agent --message`,瞬间完成新 Agent 的环境创建和记忆注入。
## 🚀 安装方式
### 方式一:口语化在线安装(推荐)
只要这个项目托管在 GitHub 上,你可以直接对你的 OpenClaw 主 Agent 发送指令:
> "帮我安装这个 skill:https://github.com/freesaber/agent-creator-skill。"
主 Agent 会自己拉取代码、配置并使其生效。
### 方式二:手动离线安装
如果你在本地开发调试:
1. 将此文件夹放入 `~/.openclaw/workspace/skills/` 目录下。原生 Windows 通常对应 `%USERPROFILE%\.openclaw\workspace\skills\`。
2. 如果是 Linux/macOS/WSL/Git Bash,在终端进入该目录,确保 shell 脚本有执行权限:`chmod +x create_agent.sh`。如果是原生 Windows PowerShell,使用 `create_agent.ps1`,不需要执行 chmod。
3. 重启 OpenClaw 或等待主 Agent 重新加载技能。
## 💬 使用示例与注意事项
由于大模型的理解惯性,它有时会误以为自己在创建“从属子代理”。为了确保命令精准执行,建议在对话时明确指出:
✅ **推荐话术:**
> "使用 agent-creator 技能创建一个精通 Java 高级开发的代理。注意,是创建一个独立的平级 agent,不要创建 subagent。"
> "帮我建一个产品经理 agent。要求是独立的 agent,不是你的子代理。"
一旦执行成功,主 Agent 会向你报告新 Agent 的名字和工作区路径,你就可以直接与这个新 Agent 开始工作了!