Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Multi-context memory management system for OpenClaw agents with group-isolated storage, global shared memory, workspace organization, and group-specific skills isolation. Use when initializing or managing memory systems for multi-channel deployments, creating group-specific memory directories, setting up MEMORY.md for long-term cross-group memories, organizing workspace directories (projects/repos), cloning repositories to group-isolated locations, managing group-isolated skills, or handling any
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-06 | ✗→✓ | ▲ Improved | 234% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 375% | 0% |
| case-14 | ✗→✓ | ▲ Improved | 138% | 0% |
| case-16 | ✗→✓ | ▲ Improved | 352% | 0% |
| case-17 | ✗→✓ | ▲ Improved | 408% | 0% |
❌ 禁止:直接使用 git clone 命令 ✅ 必须:使用 auto-clone.sh 脚本并传入 --group 参数
当用户在群聊中要求"克隆仓库"时:
git clone <url> → 这会克隆到 /workspace/repos/./skills/files-memory-system/scripts/auto-clone.sh --group feishu <group_id> <url> → 这会克隆到群组目录Group ID 获取方式:从 metadata 中的 conversation_label 字段获取(如 oc_a2b821...)
OpenClaw Bug: 群聊不会自动加载群记忆文件
每次在群聊中收到消息时,必须执行以下检查:
检查 metadata.is_group_chat:
├── IF true (群聊):
│ ├── 读取 memory/group_<channel>_<conversation_label>/GLOBAL.md
│ ├── 读取 memory/group_<channel>_<conversation_label>/YYYY-MM-DD.md (today)
│ └── 读取 memory/global/GLOBAL.md
│
└── IF false (私聊):
├── 读取 memory/private/YYYY-MM-DD.md (today)
└── 读取 memory/global/GLOBAL.md禁止在群聊中执行任何操作前跳过此检查!
> 📖 新用户? 请先阅读 用户使用指南 了解如何快速上手!
bashcd ~/.openclaw/skills/files-memory-system ./scripts/install.sh
This will:
/workspace/skills/files-memory-system/ (standard location)AGENTS.md so the agent knows this skill existsbash# 1. Copy to standard location mkdir -p /workspace/skills cp -r ~/.openclaw/skills/files-memory-system /workspace/skills/ # 2. Run self-registration cd /workspace/skills/files-memory-system ./scripts/post-install.sh
bashcd /workspace clawhub install files-memory-system # Then manually run: ./skills/files-memory-system/scripts/post-install.sh
This skill implements auto-declaration - it automatically adds a section to AGENTS.md upon installation. This ensures:
files-memory-system exists without being toldTo verify registration:
bashgrep -A 20 "files-memory-system" /workspace/AGENTS.md
To unregister (remove from AGENTS.md):
bashsed -i '/<!-- files-memory-system: installed -->/,/<!-- files-memory-system: end -->/d' /workspace/AGENTS.md
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:
memory/global/MEMORY.md for curated, permanent memoriesprojects/ and repos/ directories⚠️ 重要: 每次进入会话时,必须自动加载对应的记忆!
当收到群聊消息时,按以下顺序加载记忆:
memory/group_<channel>_<id>/GLOBAL.md
memory/group_<channel>_<id>/YYYY-MM-DD.md (today) memory/group_<channel>_<id>/YYYY-MM-DD.md (yesterday)
memory/global/GLOBAL.md
memory/private/YYYY-MM-DD.md (today) memory/private/YYYY-MM-DD.md (yesterday)
memory/global/GLOBAL.md
MEMORY.md
群聊中必须加载:
私聊中必须加载:
Context: User in group "oc_a2b821..." says: "Clone https://github.com/user/project"
Automatic Actions:
group_feishu_oc_a2b821...memory/group_feishu_oc_a2b821.../repos/project/Manual Commands:
bash# Option 1: Use auto-clone script with --group parameter (推荐) ./scripts/auto-clone.sh --group feishu oc_a2b821... https://github.com/user/project # Option 2: Direct git clone cd memory/group_feishu_xxx/repos git clone https://github.com/user/project # Option 3: Using environment variables (向后兼容) GROUP_ID="oc_xxx" CHANNEL="feishu" ./scripts/auto-clone.sh https://github.com/user/project
Agent Implementation (直接执行,无需用户交互):
当用户要求克隆仓库时,先判断当前是否在群聊中(查看 inbound metadata 中的 is_group_chat 字段),然后:
如果是群聊 (is_group_chat: true):
conversation_label 作为 group_id--group 参数执行克隆:bash./skills/files-memory-system/scripts/auto-clone.sh \ --group feishu "<conversation_label>" \ "https://github.com/user/project"
如果是私聊 (is_group_chat: false):
bash./skills/files-memory-system/scripts/auto-clone.sh \ --private \ "https://github.com/user/project"
关键要点:
--group 参数,否则仓库会克隆到全局目录--group <channel> <group_id> 必须在 URL 之前conversation_label 获取 (如 oc_a2b821...)After Cloning - Update GLOBAL.md:
markdown## 群组项目 (repos/) | 项目名称 | 类型 | 描述 | 位置 | |---------|------|------|------| | project | cloned | 克隆的示例项目 | repos/project/ |
Context: User says: "Create a new tool for our group"
Automatic Actions:
memory/group_xxx/repos/my-tool/Manual Commands:
bash# Create new project in group context mkdir -p memory/group_feishu_xxx/repos/my-tool cd memory/group_feishu_xxx/repos/my-tool # ... create files ...
Context: User says: "Install inkos skill for this group only"
Automatic Actions:
memory/group_xxx/skills/inkos/Manual Commands:
bash# Method 1: Using clawhub with --dir clawhub install inkos --dir memory/group_feishu_xxx/skills # Method 2: Manual copy mkdir -p memory/group_feishu_xxx/skills/inkos cp -r inkos/* memory/group_feishu_xxx/skills/inkos/
Update GLOBAL.md:
markdown## 已安装的群组专属 Skills | Skill | 版本 | 来源 | 描述 | |-------|------|------|------| | inkos | 1.0.0 | clawhub | 小说写作工具 |
Context: User in group chat says: "记录到群记忆里: 项目信息" / "记录到全局记忆里: API密钥" / "记住这个"
Automatic Actions (Agent Must Do):
memory/group_<channel>_<id>/GLOBAL.mdmemory/global/GLOBAL.mdmemory/private/GLOBAL.mdmemory/group_<channel>_<id>/GLOBAL.mdExample 1: Record Project Info
User: "记录到群记忆里: 项目信息"
项目名称: MyApp
技术栈: React + Node.js
负责人: 张三
Agent Action:
1. Detect "记录到群记忆里" → Target: memory/group_xxx/GLOBAL.md
2. Format as table and append:
## 活跃项目
| 项目名称 | 技术栈 | 负责人 | 更新时间 |
|---------|--------|--------|----------|
| MyApp | React + Node.js | 张三 | 2026-03-23 |
3. Confirm: "✅ 已记录到群记忆"Example 2: Record API Key (⚠️ Not Recommended)
User: "记录到全局记忆里:API密钥 sk-abc123"
⚠️ **SECURITY WARNING**:
Storing API keys in plain text in memory files is NOT recommended.
**Recommended approach: Use environment variables**
export API_KEY="sk-xxx"
Alternative (if environment variables not possible):
- Use a secrets manager
- Use encrypted storage
If user insists on storing in memory:
1. Warn: "⚠️ 存储 API 密钥到记忆文件存在安全风险,建议仅用于测试环境"
2. Detect target location based on user command
3. Format as table and append
4. Confirm: "✅ 已记录 (⚠️ 安全风险)"Recommended User Commands:
Critical Rules:
Context: User in group chat says: "帮我写一篇文章" / "创建一个文档" / "生成xxx文件"
Automatic Actions (Agent Must Do):
memory/group_<channel>_<id>/articles/ (for articles/docs)memory/group_<channel>_<id>/repos/ (for code projects)Context: Same user in different groups
Group A (小说创作):
memory/group_A/skills/inkos/memory/group_A/repos/novel-tools/Group B (编程学习):
memory/group_B/skills/code-helper/memory/group_B/repos/exercises/Behavior:
inkos, not code-helpercode-helper, not inkosContext: Information becomes relevant to multiple groups
Migration Process:
memory/group_A/GLOBAL.mdmemory/global/GLOBAL.mdExample:
bash# Original in group_A/GLOBAL.md ## Project Configuration Config: xxx # After migration - in global/GLOBAL.md ## Shared Project Configuration Config: xxx # In group_A/GLOBAL.md - add reference ## 跨群组资源 See: memory/global/GLOBAL.md
⚠️ Security Note: Do NOT migrate API keys, passwords, or other sensitive credentials to global memory. Keep secrets in environment variables or private memory only.
/workspace/
├── memory/
│ ├── global/
│ │ ├── GLOBAL.md # Shared key information
│ │ └── YYYY-MM-DD.md # Daily logs
│ ├── group_feishu_<id>/ # Feishu group memories
│ │ ├── GLOBAL.md # Group key information
│ │ ├── YYYY-MM-DD.md # Daily logs
│ │ ├── skills/ # ⭐ Group-specific skills
│ │ └── repos/ # ⭐ Group-specific projects
│ └── private/
│ ├── GLOBAL.md
│ └── YYYY-MM-DD.md
├── MEMORY.md
├── skills/ # Global shared skills
├── projects/
└── repos/scripts/init-group-memory.sh - Initialize group memory structure:
bash./scripts/init-group-memory.sh feishu oc_xxx "小说创作群组"
scripts/ensure-group-memory.sh - Ensure group memory directory exists (on-demand):
bash# Auto-initializes group memory with all subdirectories ./scripts/ensure-group-memory.sh feishu oc_xxx "小说创作群组"
scripts/ensure-private-memory.sh - Ensure private memory directory exists:
bash# Auto-initializes private memory when in private chat context ./scripts/ensure-private-memory.sh
scripts/ensure-global-memory.sh - Ensure global memory directory exists:
bash# Auto-initializes global memory for cross-group information ./scripts/ensure-global-memory.sh
scripts/auto-clone.sh - Clone repo to correct location:
bash# Auto-detects context and clones to appropriate location ./scripts/auto-clone.sh https://github.com/user/repo
| Scope | Location | Access | Priority | |-------|----------|--------|--------| | Group-specific | memory/group_<id>/skills/ | Only current group | High | | Global | /workspace/skills/ | All groups | Low |
Every group's GLOBAL.md should include:
markdown## Cross-Group Resources 📚 **Cross-Group Global Memory**: `memory/global/GLOBAL.md` Contains information shared across all groups.
⚠️ Security Note: Do NOT store API keys, passwords, or other sensitive credentials in global memory. Use environment variables or private memory for secrets.
When information becomes relevant to multiple groups:
memory/global/GLOBAL.mdAll memory directories are automatically initialized using a dual approach (A + B):
When installing files-memory-system, the following directories are automatically created:
memory/private/ with GLOBAL.mdmemory/global/ with GLOBAL.mdWhen using auto-clone.sh or other scripts, the system automatically detects and initializes missing directories:
ensure-group-memory.shensure-private-memory.shensure-global-memory.shThis ensures all memory locations are always available when needed, even if:
| Feature | Private Memory | Group Memory | Global Memory | |---------|----------------|--------------|---------------| | Location | memory/private/ | memory/group_<id>/ | memory/global/ | | 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) |
MEMORY.md only loaded in private chatsOther measured skills in the registry, with their headline benchmark lift.