clawng-term-memory
Make your OpenClaw agent portable and persistent. Every change to your agent's soul, memory, and operating rules is committed to git and pushed to a private GitHub repo — so you can restore your exact agent setup on any machine, just by cloning the repo.
Watch your assistant evolve over time through its git history: see when it learned something new, what decisions changed, and who it was a week ago. It's version control for a mind.
Setup
- 1. Initialize a git repo in your workspace (if not already done):
CODEBLOCK0
- 2. Create a private GitHub repo, then add it as a remote using SSH (recommended) or HTTPS:
SSH (recommended — no token exposure):
CODEBLOCK1
HTTPS with credential store (no token in URL):
CODEBLOCK2
- 3. Push initial commit:
CODEBLOCK3
- 4. Set workspace path if non-standard (optional):
export CLAWNG_WORKSPACE=/your/custom/workspace/path
The script defaults to
$HOME/.openclaw/workspace if not set.
Multi-agent / multi-machine support
Each machine has its own branch (agent/<hostname>) with its own MEMORY.md. A daily AI synthesis job reads all agents' memories and writes one authoritative SHARED_MEMORY.md to main — fully automatic, no human required.
CODEBLOCK5
- -
commit.sh — pushes to agent/<hostname> automatically (branch created on first commit) - INLINECODE7 — collects all agents' MEMORY.md files for the synthesis agent
- AI synthesis agent — deduplicates and merges into
SHARED_MEMORY.md on main nightly - All agents read
SHARED_MEMORY.md from main to stay in sync
Scales to 10+ machines with no conflicts.
Tracked files
- -
SOUL.md, MEMORY.md, USER.md, TOOLS.md, IDENTITY.md, AGENTS.md, INLINECODE18 - INLINECODE19 (daily notes)
- INLINECODE20 (installed skills)
Commit + push changes
Run after modifying any core file:
CODEBLOCK6
Examples:
- - INLINECODE21
- INLINECODE22
- INLINECODE23
- INLINECODE24
Daily AI synthesis (run once per day)
INLINECODE25 collects all agent MEMORY.md files. An AI agent then synthesizes them into SHARED_MEMORY.md on main — deduplicating, resolving conflicts intelligently, and keeping all unique information.
Set up as an OpenClaw cron job (runs at 02:00 local time by default).
View history
CODEBLOCK7
Diff a file
CODEBLOCK8
Revert a file to previous version
CODEBLOCK9
Auto-commit rule
Always run the commit script after modifying a core knowledge file. Write → commit → push. Every time, no exceptions.
clawng-term-memory
让你的 OpenClaw 智能体可移植且持久化。对智能体灵魂、记忆和操作规则的每一次更改都会提交到 git 并推送到私有 GitHub 仓库——这样你只需克隆仓库,就能在任何机器上恢复你的精确智能体配置。
通过 git 历史观察你的助手随时间演变:查看它何时学到了新东西,哪些决策发生了变化,以及一周前它是什么样子。这是对思维进行的版本控制。
设置
- 1. 在工作区初始化 git 仓库(如果尚未完成):
bash
cd ~/.openclaw/workspace
git init
git config user.name YourAgent
git config user.email agent@example.com
- 2. 创建一个私有 GitHub 仓库,然后使用 SSH(推荐)或 HTTPS 将其添加为远程仓库:
SSH(推荐——不会暴露令牌):
bash
git remote add origin git@github.com:<用户>/<仓库>.git
带凭据存储的 HTTPS(URL 中不包含令牌):
bash
git remote add origin https://github.com/<用户>/<仓库>.git
git config credential.helper store
Git 会在首次推送时提示输入凭据并安全存储
- 3. 推送初始提交:
bash
git branch -M main && git push -u origin main
- 4. 如果工作区路径非标准,可设置(可选):
bash
export CLAWNG_WORKSPACE=/你的/自定义/工作区/路径
如果未设置,脚本默认使用 $HOME/.openclaw/workspace。
多智能体/多机器支持
每台机器都有自己的分支(agent/<主机名>)及其自己的 MEMORY.md。每日 AI 合成任务会读取所有智能体的记忆,并将一份权威的 SHARED_MEMORY.md 写入 main 分支——完全自动,无需人工干预。
agent/vps-1 → MEMORY.md ──┐
agent/vps-2 → MEMORY.md ──┤ Claude 合成 → SHARED_MEMORY.md → main
agent/vps-3 → MEMORY.md ──┘
- - commit.sh — 自动推送到 agent/<主机名>(首次提交时创建分支)
- merge.sh — 收集所有智能体的 MEMORY.md 文件供合成智能体使用
- AI 合成智能体 — 每晚去重并合并到 main 分支上的 SHAREDMEMORY.md
- 所有智能体从 main 分支读取 SHAREDMEMORY.md 以保持同步
可扩展到 10 台以上机器且无冲突。
跟踪的文件
- - SOUL.md、MEMORY.md、USER.md、TOOLS.md、IDENTITY.md、AGENTS.md、HEARTBEAT.md
- memory/*.md(每日笔记)
- skills/(已安装的技能)
提交并推送更改
修改任何核心文件后运行:
bash
bash /path/to/workspace/skills/clawng-term-memory/scripts/commit.sh 更改的简短描述
示例:
- - MEMORY.md: 添加了新客户上下文
- SOUL.md: 更新了操作规则
- memory/2026-02-21.md: 每日笔记
- HEARTBEAT.md: 调整了检查频率
每日 AI 合成(每天运行一次)
merge.sh 收集所有智能体的 MEMORY.md 文件。然后 AI 智能体将它们合成为 main 分支上的 SHARED_MEMORY.md——去重、智能解决冲突,并保留所有独特信息。
设置为 OpenClaw 定时任务(默认在本地时间 02:00 运行)。
查看历史
bash
cd /path/to/workspace && git log --oneline --graph memory/ MEMORY.md SOUL.md
比较文件差异
bash
cd /path/to/workspace && git diff HEAD~1 MEMORY.md
将文件恢复到先前版本
bash
cd /path/to/workspace && git checkout HEAD~1 -- MEMORY.md
bash skills/clawng-term-memory/scripts/commit.sh 将 MEMORY.md 恢复到先前版本
自动提交规则
修改核心知识文件后务必运行提交脚本。 编写 → 提交 → 推送。每次如此,无一例外。