⚠️ CRITICAL RULES
群聊中克隆仓库的硬性规定
❌ 禁止:直接使用 git clone 命令
✅ 必须:使用 auto-clone.sh 脚本并传入 --group 参数
当用户在群聊中要求"克隆仓库"时:
- 1. 不要执行
git clone <url> → 这会克隆到 INLINECODE4 - 必须执行
./skills/files-memory-system/scripts/auto-clone.sh --group feishu <group_id> <url> → 这会克隆到群组目录
Group ID 获取方式:从 metadata 中的 conversation_label 字段获取(如 oc_a2b821...)
🔴 会话开始强制检查清单 (群聊)
OpenClaw Bug: 群聊不会自动加载群记忆文件
每次在群聊中收到消息时,必须执行以下检查:
CODEBLOCK0
禁止在群聊中执行任何操作前跳过此检查!
Memory System
📖 新用户? 请先阅读 用户使用指南 了解如何快速上手!
Installation
Method 1: Auto-Install with Self-Registration (Recommended)
CODEBLOCK1
This will:
- 1. ✅ Copy skill to
/workspace/skills/files-memory-system/ (standard location) - ✅ Auto-register in
AGENTS.md so the agent knows this skill exists - ✅ Enable auto-discovery on every agent startup
Method 2: Manual Install
CODEBLOCK2
Method 3: Using clawhub
CODEBLOCK3
Self-Registration Mechanism
This skill implements auto-declaration - it automatically adds a section to AGENTS.md upon installation. This ensures:
- - The agent knows
files-memory-system exists without being told - Memory locations are documented where the agent reads
- No manual configuration needed after installation
To verify registration:
CODEBLOCK4
To unregister (remove from AGENTS.md):
CODEBLOCK5
Overview
This skill provides a complete memory management system that enables OpenClaw agents to maintain context across multiple chat groups while keeping group-specific memories and skills isolated. It includes:
- - Group-isolated memory: Separate memory directories per group/channel
- Group-isolated skills: Skills installed per group, preventing cross-group pollution
- Global shared memory: Cross-group knowledge in INLINECODE12
- Long-term memory:
MEMORY.md for curated, permanent memories - Workspace organization: Structured
projects/ and repos/ directories
Session Start - Automatic Memory Loading
⚠️ 重要: 每次进入会话时,必须自动加载对应的记忆!
群聊中的自动加载流程
当收到群聊消息时,按以下顺序加载记忆:
- 1. 读取群组 GLOBAL.md - 获取群组关键信息和资源索引
CODEBLOCK6
- 2. 读取今日和昨日记录 - 获取最近的对话上下文
CODEBLOCK7
- 3. 读取跨群组全局记忆 - 获取跨群组共享的信息
CODEBLOCK8
私聊中的自动加载流程
- 1. 读取私聊记录 - 今日和昨日
CODEBLOCK9
- 2. 读取跨群组全局记忆
CODEBLOCK10
- 3. 读取长期精华记忆 (仅私聊)
CODEBLOCK11
记忆加载检查清单
群聊中必须加载:
- - [ ] 当前群组的 GLOBAL.md
- [ ] 今天的群组日志 (YYYY-MM-DD.md)
- [ ] 昨天的群组日志 (回顾上下文)
- [ ] 跨群组全局记忆 (memory/global/GLOBAL.md)
私聊中必须加载:
- - [ ] 私聊今日和昨日日志
- [ ] 跨群组全局记忆 (memory/global/GLOBAL.md)
- [ ] MEMORY.md (仅私聊)
Usage Scenarios
Scenario 1: User Says "Clone This Repo" in a Group Chat
Context: User in group "oc_a2b821..." says: "Clone https://github.com/user/project"
Automatic Actions:
- 1. Detect current group context: INLINECODE16
- Clone to: INLINECODE17
- Update group's GLOBAL.md with project info
- Confirm: "✅ Cloned to group repos/project/"
Manual Commands:
CODEBLOCK12
Agent Implementation (直接执行,无需用户交互):
当用户要求克隆仓库时,先判断当前是否在群聊中(查看 inbound metadata 中的 is_group_chat 字段),然后:
如果是群聊 (is_group_chat: true):
- 1. 从 metadata 读取
conversation_label 作为 group_id - 使用
--group 参数执行克隆:
CODEBLOCK13
如果是私聊 (is_group_chat: false):
CODEBLOCK14
关键要点:
- - ⚠️ 群聊中必须使用
--group 参数,否则仓库会克隆到全局目录 - INLINECODE24 必须在 URL 之前
- 群组ID从
conversation_label 获取 (如 oc_a2b821...) - 脚本会自动创建缺失的群组记忆目录
- 如果用户没指定项目名称,脚本会自动从 URL 提取
After Cloning - Update GLOBAL.md:
CODEBLOCK15
Scenario 2: Create New Project in Group Context
Context: User says: "Create a new tool for our group"
Automatic Actions:
- 1. Create project directory: INLINECODE27
- Initialize with template if needed
- Update GLOBAL.md
- Start working in the group-specific location
Manual Commands:
CODEBLOCK16
Scenario 3: Install Skill for Specific Group
Context: User says: "Install inkos skill for this group only"
Automatic Actions:
- 1. Install to: INLINECODE28
- Update group's GLOBAL.md
- Skill is isolated to this group only
Manual Commands:
CODEBLOCK17
Update GLOBAL.md:
CODEBLOCK18
Scenario 4: Record Information to Group Memory ⭐
Context: User in group chat says: "记录到群记忆里: 项目信息" / "记录到全局记忆里: API密钥" / "记住这个"
Automatic Actions (Agent Must Do):
- 1. Detect the intent: User wants to record information to group memory
- Determine target location (按优先级匹配):
- If "记录到群记忆里" →
memory/group_<channel>_<id>/GLOBAL.md
- If "记录到全局记忆里"/"记录到跨群记忆里" →
memory/global/GLOBAL.md
- If "记录到私聊里" →
memory/private/GLOBAL.md
- If "群文档"/"群组" (模糊指令) →
memory/group_<channel>_<id>/GLOBAL.md
- 3. Write to file immediately: Do not just say "I remember", actually write to file!
- Confirm: "✅ 已记录到群记忆" / "✅ 已保存到全局记忆"
Example 1: Record Project Info
CODEBLOCK19
Example 2: Record API Key (⚠️ Not Recommended)
CODEBLOCK20
Recommended User Commands:
- - "记录到群记忆里: [内容]" → 仅当前群可见
- "记录到全局记忆里: [内容]" → 所有群共享
- "记录到跨群记忆里: [内容]" → 同全局记忆
- "记录到私聊里: [内容]" → 仅私聊可见
Critical Rules:
- - ❌ DO NOT just say "I remember" without writing to file
- ❌ DO NOT store sensitive info without clarifying scope
- ✅ ALWAYS confirm the location where info is stored
- ✅ Use tables in GLOBAL.md for structured info
- ✅ Add timestamps for time-sensitive info
Scenario 5: Create Files in Group Chat ⭐
Context: User in group chat says: "帮我写一篇文章" / "创建一个文档" / "生成xxx文件"
Automatic Actions (Agent Must Do):
- 1. Detect the intent: User wants to create a file in group context
- Determine correct location:
- Default:
memory/group_<channel>_<id>/articles/ (for articles/docs)
- Code:
memory/group_<channel>_<id>/repos/ (for code projects)
- 3. Create the file: Write to the correct group-specific path
- Auto-update GLOBAL.md: ⚠️ CRITICAL - After creating file, auto-append to GLOBAL.md
- Confirm: "✅ 已创建并记录到群文档"
Scenario 6: Working Across Multiple Groups
Context: Same user in different groups
Group A (小说创作):
- - Skills: INLINECODE35
- Projects: INLINECODE36
Group B (编程学习):
- - Skills: INLINECODE37
- Projects: INLINECODE38
Behavior:
- - In Group A: Only sees
inkos, not INLINECODE40 - In Group B: Only sees
code-helper, not INLINECODE42 - No pollution between groups!
Scenario 5: Migrate Information to Global
Context: Information becomes relevant to multiple groups
Migration Process:
- 1. Move from: INLINECODE43
- To: INLINECODE44
- Update Group A with reference
- All groups can now access
Example:
CODEBLOCK21
⚠️ Security Note: Do NOT migrate API keys, passwords, or other sensitive credentials to global memory. Keep secrets in environment variables or private memory only.
Memory Architecture
Directory Structure
CODEBLOCK22
Automation Scripts
scripts/init-group-memory.sh - Initialize group memory structure:
CODEBLOCK23
scripts/ensure-group-memory.sh - Ensure group memory directory exists (on-demand):
CODEBLOCK24
scripts/ensure-private-memory.sh - Ensure private memory directory exists:
CODEBLOCK25
scripts/ensure-global-memory.sh - Ensure global memory directory exists:
CODEBLOCK26
scripts/auto-clone.sh - Clone repo to correct location:
CODEBLOCK27
Group-Isolated Skills System
| Scope | Location | Access | Priority |
|---|
| Group-specific | INLINECODE45 | Only current group | High |
| Global |
/workspace/skills/ | All groups | Low |
Promoting Cross-Group Memory Awareness
1. Include Reference in Group GLOBAL.md
Every group's GLOBAL.md should include:
CODEBLOCK28
2. Key Information to Store Globally
- - Relevant to multiple groups
- Common standards or conventions
- Shared resources (non-sensitive)
- Tool documentation and links
⚠️ Security Note: Do NOT store API keys, passwords, or other sensitive credentials in global memory. Use environment variables or private memory for secrets.
3. Migration from Group to Global
When information becomes relevant to multiple groups:
- 1. Move to INLINECODE47
- Update original with reference link
- Notify affected groups
Memory Auto-Initialization
All memory directories are automatically initialized using a dual approach (A + B):
Approach A: Installation-Time Setup
When installing files-memory-system, the following directories are automatically created:
- -
memory/private/ with INLINECODE49 - INLINECODE50 with INLINECODE51
Approach B: On-Demand Setup
When using
auto-clone.sh or other scripts, the system automatically detects and initializes missing directories:
- - Group context: Calls INLINECODE53
- Private context: Calls INLINECODE54
- Global operations: Calls INLINECODE55
This ensures all memory locations are always available when needed, even if:
- - The installation step was skipped
- The directory was accidentally deleted
- Working in a new workspace
Memory Directory Comparison
| Feature | Private Memory | Group Memory | Global Memory |
|---|
| Location | INLINECODE56 | INLINECODE57 | INLINECODE58 |
| Auto-init A |
✅ Install-time | ❌ No | ✅ Install-time |
|
Auto-init B | ✅ On-demand | ✅ On-demand | ✅ On-demand |
|
Skills | Uses global | Can isolate | N/A |
|
Projects | Uses global | Can isolate | N/A |
|
Scope | 1-on-1 chats | Specific group | All groups |
|
Ensure Script |
ensure-private-memory.sh |
ensure-group-memory.sh |
ensure-global-memory.sh |
|
Scope | 1-on-1 chats only | Specific to one group |
|
Auto-init | ✅ Yes (A+B) | ✅ Yes (B only) |
Security Notes
- -
MEMORY.md only loaded in private chats - Group skills completely isolated
- Preserve group memory on disband
⚠️ 关键规则
群聊中克隆仓库的硬性规定
❌ 禁止:直接使用 git clone 命令
✅ 必须:使用 auto-clone.sh 脚本并传入 --group 参数
当用户在群聊中要求克隆仓库时:
- 1. 不要执行 git clone → 这会克隆到 /workspace/repos/
- 必须执行 ./skills/files-memory-system/scripts/auto-clone.sh --group feishu → 这会克隆到群组目录
Group ID 获取方式:从 metadata 中的 conversationlabel 字段获取(如 oca2b821...)
🔴 会话开始强制检查清单 (群聊)
OpenClaw Bug: 群聊不会自动加载群记忆文件
每次在群聊中收到消息时,必须执行以下检查:
检查 metadata.isgroupchat:
├── IF true (群聊):
│ ├── 读取 memory/group/GLOBAL.md
│ ├── 读取 memory/group/YYYY-MM-DD.md (今天)
│ └── 读取 memory/global/GLOBAL.md
│
└── IF false (私聊):
├── 读取 memory/private/YYYY-MM-DD.md (今天)
└── 读取 memory/global/GLOBAL.md
禁止在群聊中执行任何操作前跳过此检查!
记忆系统
📖 新用户? 请先阅读 用户使用指南 了解如何快速上手!
安装
方法 1: 自动安装并自注册(推荐)
bash
cd ~/.openclaw/skills/files-memory-system
./scripts/install.sh
这将:
- 1. ✅ 将技能复制到 /workspace/skills/files-memory-system/(标准位置)
- ✅ 自动注册到 AGENTS.md,使代理知道该技能存在
- ✅ 每次代理启动时启用自动发现
方法 2: 手动安装
bash
1. 复制到标准位置
mkdir -p /workspace/skills
cp -r ~/.openclaw/skills/files-memory-system /workspace/skills/
2. 运行自注册
cd /workspace/skills/files-memory-system
./scripts/post-install.sh
方法 3: 使用 clawhub
bash
cd /workspace
clawhub install files-memory-system
然后手动运行:
./skills/files-memory-system/scripts/post-install.sh
自注册机制
该技能实现了自动声明——安装时会自动在 AGENTS.md 中添加一个章节。这确保了:
- - 代理知道 files-memory-system 存在,无需额外告知
- 代理读取的记忆位置已被记录
- 安装后无需手动配置
验证注册:
bash
grep -A 20 files-memory-system /workspace/AGENTS.md
取消注册(从 AGENTS.md 中移除):
bash
sed -i //,//d /workspace/AGENTS.md
概述
该技能提供了一个完整的记忆管理系统,使 OpenClaw 代理能够在多个聊天群组中保持上下文,同时保持群组特定的记忆和技能隔离。它包括:
- - 群组隔离记忆:每个群组/频道有独立的记忆目录
- 群组隔离技能:按群组安装的技能,防止跨群组污染
- 全局共享记忆:memory/global/ 中的跨群组知识
- 长期记忆:MEMORY.md 用于精心整理的永久记忆
- 工作区组织:结构化的 projects/ 和 repos/ 目录
会话开始 - 自动加载记忆
⚠️ 重要: 每次进入会话时,必须自动加载对应的记忆!
群聊中的自动加载流程
当收到群聊消息时,按以下顺序加载记忆:
- 1. 读取群组 GLOBAL.md - 获取群组关键信息和资源索引
memory/group/GLOBAL.md
- 2. 读取今日和昨日记录 - 获取最近的对话上下文
memory/group/YYYY-MM-DD.md (今天)
memory/group/YYYY-MM-DD.md (昨天)
- 3. 读取跨群组全局记忆 - 获取跨群组共享的信息
memory/global/GLOBAL.md
私聊中的自动加载流程
- 1. 读取私聊记录 - 今日和昨日
memory/private/YYYY-MM-DD.md (今天)
memory/private/YYYY-MM-DD.md (昨天)
- 2. 读取跨群组全局记忆
memory/global/GLOBAL.md
- 3. 读取长期精华记忆 (仅私聊)
MEMORY.md
记忆加载检查清单
群聊中必须加载:
- - [ ] 当前群组的 GLOBAL.md
- [ ] 今天的群组日志 (YYYY-MM-DD.md)
- [ ] 昨天的群组日志 (回顾上下文)
- [ ] 跨群组全局记忆 (memory/global/GLOBAL.md)
私聊中必须加载:
- - [ ] 私聊今日和昨日日志
- [ ] 跨群组全局记忆 (memory/global/GLOBAL.md)
- [ ] MEMORY.md (仅私聊)
使用场景
场景 1: 用户在群聊中说克隆这个仓库
上下文:用户在群组 oc_a2b821... 中说:克隆 https://github.com/user/project
自动操作:
- 1. 检测当前群组上下文:groupfeishuoca2b821...
- 克隆到:memory/groupfeishuoca2b821.../repos/project/
- 用项目信息更新群组的 GLOBAL.md
- 确认:✅ 已克隆到群组 repos/project/
手动命令:
bash
选项 1: 使用带有 --group 参数的自动克隆脚本(推荐)
./scripts/auto-clone.sh --group feishu oc_a2b821... https://github.com/user/project
选项 2: 直接 git clone
cd memory/group
feishuxxx/repos
git clone https://github.com/user/project
选项 3: 使用环境变量(向后兼容)
GROUP
ID=ocxxx CHANNEL=feishu ./scripts/auto-clone.sh https://github.com/user/project
代理实现(直接执行,无需用户交互):
当用户要求克隆仓库时,先判断当前是否在群聊中(查看 inbound metadata 中的 isgroupchat 字段),然后:
如果是群聊 (isgroupchat: true):
- 1. 从 metadata 读取 conversationlabel 作为 groupid
- 使用 --group 参数执行克隆:
bash
./skills/files-memory-system/scripts/auto-clone.sh \
--group feishu
\
https://github.com/user/project
如果是私聊 (isgroupchat: false):
bash
./skills/files-memory-system/scripts/auto-clone.sh \
--private \
https://github.com/user/project
关键要点:
- - ⚠️ 群聊中必须使用 --group 参数,否则仓库会克隆到全局目录
- --group id> 必须在 URL 之前
- 群组ID从 conversationlabel 获取 (如 oc_a2b821...)
- 脚本会自动创建缺失的群组记忆目录
- 如果用户没指定项目名称,脚本会自动从 URL 提取
克隆后 - 更新 GLOBAL.md:
markdown
群组项目 (repos/)
| 项目名称 | 类型 | 描述 | 位置 |
|---|
| project | cloned | 克隆的示例项目 | repos/project/ |
场景 2: 在群组上下文中创建新项目
上下文:用户说:为我们的群组创建一个新工具
自动操作:
- 1. 创建项目目录:memory/group_xxx/repos/my-tool/
- 如果需要,用模板初始化
- 更新 GLOBAL.md
- 在群组特定位置开始工作
手动命令:
bash
在群