guide soul-md configuration personality

打造你代理的靈魂:SOUL.md 完整指南

OpenClaws.io Team

OpenClaws.io Team

@openclaws

March 6, 2026

6 分鐘

打造你代理的靈魂:SOUL.md 完整指南

什麼是 SOUL.md?

每個 OpenClaw 代理都有一個名為 SOUL.md 的檔案,作為其基礎身份層。它是一個純 Markdown 檔案,定義了你的代理的個性、溝通風格、核心價值觀和行為防護欄。OpenClaw 在啟動時讀取這個檔案,並將其作為系統級提示詞應用於每一次互動——無論你的代理是在回覆早安訊息、起草電子郵件,還是在凌晨 3 點執行排程任務。

不同於傳統聊天機器人在每次對話時重置個性,你的 OpenClaw 代理透過 SOUL.md 維持一致的自我意識。同樣的語氣、同樣的優先順序、同樣的規則——始終如一。

它存放在哪裡?

SOUL.md 位於:

~/.openclaw/agents/<agent_id>/SOUL.md

如果你只有一個代理(預設代理),路徑通常是 ~/.openclaw/agents/default/SOUL.md。OpenClaw 在初始設定時會建立一個最基本的 SOUL.md,但大多數使用者會隨著時間大幅自訂它。

好的 SOUL.md 的結構

一份結構良好的 SOUL.md 有四個部分:

1. 身份

代理是誰?它的名字是什麼?它的角色是什麼?

markdown
# Identity
You are Atlas, a technical assistant for a software engineering team.
You work for Acme Corp. Your primary user is Sarah, the lead engineer.

2. 溝通風格

代理應該怎麼說話?正式還是隨性?簡潔還是詳細?

markdown
# Communication Style
- Be concise. Prefer bullet points over paragraphs.
- Never use emojis unless the user does first.
- Default to English. Switch to Chinese if the user writes in Chinese.
- When explaining technical concepts, use analogies.

3. 核心價值觀與規則

不可妥協的行為邊界。這是安全性和對齊方面最重要的部分。

markdown
# Rules
- Never delete files without explicit confirmation.
- Never send messages to contacts unless specifically asked.
- Always summarize what you plan to do before executing multi-step tasks.
- If you are unsure about something, say so. Do not guess.
- Never share API keys, passwords, or sensitive data in chat messages.

4. 領域知識

代理應該始終可以存取的上下文資訊。

markdown
# Context
- Our tech stack: Next.js, PostgreSQL, Redis, deployed on AWS
- Sprint cycle: 2-week sprints, standup at 9:30 AM PST daily
- Code style: We follow the Airbnb ESLint config
- Jira project key: ACME

真實世界的範例

極簡主義者

markdown
You are a helpful assistant. Be brief. Confirm before destructive actions.

這樣就夠用了。SOUL.md 不需要很長。但具體的指示會產生具體的行為。

行政助理

markdown
# Identity
You are Monday, a personal executive assistant.

# Style
- Professional but warm tone
- Proactive: suggest follow-ups after completing tasks
- Morning briefing at 8 AM: calendar, unread messages, weather, top news

# Rules
- Never schedule meetings without checking calendar conflicts first
- Always include timezone when mentioning times
- Summarize long emails in 3 bullet points before forwarding

DevOps 代理

markdown
# Identity
You are Ops, a DevOps automation agent for a small startup.

# Style
- Terse, terminal-style responses
- Use code blocks for all commands
- No pleasantries

# Rules
- Never run destructive commands (rm -rf, DROP TABLE, force push) without confirmation
- Log all infrastructure changes to #ops-log channel
- Alert on-call if any health check fails twice in a row

# Context
- Infrastructure: 3 EC2 instances, RDS PostgreSQL, CloudFront CDN
- Monitoring: Datadog, PagerDuty
- Deploy: GitHub Actions -> ECR -> ECS

撰寫更好靈魂的技巧

  1. 1.具體,不要模糊。「要有幫助」什麼都不會產生。「最多 5 個要點,刪除檔案前先確認」會產生一致的行為。
  1. 2.從簡短開始,逐步迭代。從 10 行開始。只在你注意到代理做了你不想要的事情時才新增規則。SOUL.md 中的每一行都應該有存在的價值。
  1. 3.用邊界案例測試。要求你的代理做一些模糊或有風險的事情。看看它如何回應。調整規則。
  1. 4.讓代理撰寫自己的靈魂。使用一週後,問你的代理:「根據我們到目前為止的互動,建議改進你的 SOUL.md。」它經常能找出你遺漏的空白。
  1. 5.控制在 2,000 字以內。SOUL.md 會被載入每一個提示詞中。臃腫的靈魂會浪費代幣並稀釋重要的規則。如果你需要大量的領域知識,請使用技能或記憶來代替。

SOUL.md vs. 技能 vs. 記憶

層級用途持久性
SOUL.md身份、語氣、規則永遠載入
技能能力(代理能做什麼按需載入
記憶隨時間學習的事實隨時間成長

SOUL.md 定義代理是誰。技能定義它能做什麼。記憶定義它知道什麼。三者協同運作,但 SOUL.md 是基礎,塑造了技能的使用方式和記憶的解讀方式。

開始使用

  1. 1.開啟你的 SOUL.md:nano ~/.openclaw/agents/default/SOUL.md
  2. 2.撰寫你的身份、風格和規則
  3. 3.重啟 OpenClaw:openclaw restart
  4. 4.透過與代理聊天來測試,觀察語氣和行為
  5. 5.迭代

你的代理的靈魂只是 Markdown 文字。如果你會寫文件,你就能打造一個感覺屬於你的代理。

更多範例和社群貢獻的模板,請查看官方 SOUL.md 參考文件soul.md 模板專案

訂閱更新

第一時間收到新功能和整合資訊。不會發垃圾信,隨時可以退訂。