Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.
Memory
collective-memory
Try itBroadcast a single memory note to multiple AI-agent workspaces in one shot, upserting into MEMORY.md / AGENTS.md / TOOLS.md / USER.md across all targets. Pur...
What it does
**Author**: Evan Song · github.com/Songhonglei **Repository**: https://github.com/Songhonglei/better-agent-skills **License**: MIT
The skill document
Collective Memory
- Author: Evan Song · github.com/Songhonglei
- Repository: https://github.com/Songhonglei/better-agent-skills
- License: MIT
Broadcast a single memory note to multiple agent workspaces in one shot —
idempotent upsert into MEMORY.md, AGENTS.md, TOOLS.md, USER.md, or
any Markdown file across all targets.
Pure file-ops, zero network, zero LLM. The calling agent decides what to write and which key to look up; this script does the file work atomically.
Execution Flow
Step 1 — Extract the memory
From the user's request, extract three things:
content: the full Markdown block (must include its own##heading line)key: 1–5 word lookup phrase used to find an existing heading to updatefile: which file to write into (defaultMEMORY.md)
File routing rules:
| Content type | Target file |
|---|---|
| Facts, rules, lessons, tool paths, APIs | MEMORY.md |
| Workflows, do/don't, dev conventions | AGENTS.md |
| Tool commands, config params, account info | TOOLS.md |
| Information about the user themselves | USER.md |
When unsure, default to MEMORY.md.
Step 2 — Resolve agent targets (hybrid: explicit > discovery > confirm)
Pick the first strategy that yields targets:
A. Explicit (preferred when known)
--target /path/to/ws1:MEMORY.md \
--target /path/to/ws2:MEMORY.md
Or via env: COLLECTIVE_MEMORY_TARGETS="/ws1:MEMORY.md,/ws2:MEMORY.md".
B. Auto-discover (when user says "all my agents")
--discover-under ~/.claude/projects --file MEMORY.md
--discover-under ~/.openclaw/agents --file MEMORY.md
--discover-under ~/code --file AGENTS.md
Each --discover-under finds first-level subdirectories.
Discovery defaults to check (in order, stop at first non-empty):
$COLLECTIVE_MEMORY_TARGETSenv~/.claude/projects/(Claude Code)~/.openclaw/agents/(OpenClaw)- CWD's immediate sibling directories
- Ask the user
Step 3 — Confirm before broadcasting (REQUIRED for ≥2 targets)
Show the plan and wait for user y/n:
About to broadcast to 3 target(s):
• /home/me/code/proj-a → MEMORY.md
• /home/me/code/proj-b → MEMORY.md
• /home/me/code/proj-c → MEMORY.md
Content: [first 80 chars of content]
Lookup key: [key]
Proceed? (y/n)
Single target → skip confirmation, run directly.
Sensitive content guard: if content contains token, password,
secret, api_key, private_key, or _token= patterns, always add a
red warning line to the confirmation prompt:
⚠️ This memory contains apparent secrets. Broadcasting will write to every target. Are you sure? (y/n)
Step 4 — (Optional) AI synonym pre-pass
Before invoking the script, the calling agent may read each target file's
existing ## headings and decide if key semantically matches one of them.
If yes, replace key with the exact heading text to ensure precise overwrite.
The script itself does no AI calls — only literal heading tokenization (English single-char + CJK 2-gram OR match).
Step 5 — Execute broadcast
Recommended multi-target form (single Python invocation):
python3 /scripts/update_memory.py \
--target /path/to/ws1:MEMORY.md \
--target /path/to/ws2:MEMORY.md \
--target /path/to/ws3:MEMORY.md \
--key "API key path" \
--content "## API key path
stored in .secrets/api-keys.env (chmod 600)"
Auto-discover form:
python3 /scripts/update_memory.py \
--discover-under ~/.claude/projects \
--discover-under ~/.openclaw/agents \
--file MEMORY.md \
--key "API key path" \
--content "## API key path
..."
Legacy single-target (backward compatible):
python3 /scripts/update_memory.py \
--workspace /path/to/ws --file MEMORY.md \
--key "..." --content "..."
Step 6 — Report results
The script prints one line per target with status: updated / appended /
would_update / would_append / error. With --json, the output is
machine-readable for downstream tooling.
Broadcast to 3 target(s):
✅ [appended] /home/me/code/proj-a → MEMORY.md
✅ [updated] /home/me/code/proj-b → MEMORY.md
❌ [error] /home/me/code/proj-c → MEMORY.md — workspace not found
Exit code 0 = all targets OK; 1 = at least one failure.
CLI Reference
python3 update_memory.py [options]
| Flag | Repeatable | Description |
|---|---|---|
--workspace | no | Single workspace (legacy mode). Requires --file. |
--target : | yes | Explicit workspace:filename pair, e.g. /proj:MEMORY.md |
--discover-under | yes | Auto-find first-level subdirs. Requires --file. |
--file | no | Default file used by --workspace and --discover-under |
--key | no | Required. Heading lookup key. |
--content | no | Required. Full block to upsert, must include its own ## heading. |
--dry-run | no | Preview only; no files written. |
--json | no | Emit JSON result instead of human text. |
Match Behaviour
- Step 1: tokenize
key(English/digit runs lowercased, CJK 2+ char spans) → OR-match against every##heading in the file → if hit, replace that section up to the next same-or-higher level heading. - Step 2: no heading matched → append to the end of the file.
- Both branches are idempotent: re-running the same command never produces duplicate sections.
What This Skill Is NOT
- Not a real-time sync service. Each invocation is one-shot file write.
- Not an LLM-based merger. Tokenization is literal; if you want fuzzy semantic matching, do it in Step 4 (AI pre-pass) before calling the script.
- Not a remote-agent broadcaster by itself. For remote agents (ACP / HTTP / SSH), the calling agent must orchestrate transport separately and invoke this script on each remote machine.
Dependencies
- Python 3.8+ (standard library only — no
pip installrequired)
Key Files
| File | Purpose |
|---|---|
scripts/update_memory.py | The upsert engine. Multi-target + dry-run + JSON. |
Related skills
Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.
Save, search, and manage personal notes and knowledge bases in Get笔记 on explicit request.
Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.
Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.
Read and write Excel workbooks, worksheets, ranges, tables, and charts in OneDrive through Microsoft Graph with managed OAuth.
More from songhonglei
Browse all skillsRecover lost agent session content and file changes from on-disk conversation logs. Streaming and OOM-safe on 700MB+ daily JSONL. Two commands: search.py for keyword search across recent sessions (with hit snippets, file-op listing, JSON for agent consumption); extract.py for pulling full write/edit content from a single session by ID prefix, with optional replay-rebuild for pure-edit sequences and safe restore-to-disk (refuses silent overwrites without --yes). Multi-agent aware via --agent main|all|a,b. Configurable data root via --root flag or SESSION_RECOVERY_ROOT env var (default ~/.openclaw/agents/). Trigger when user wants to find lost session content, recover files written by an agent, locate which session modified a file, search session history by keyword, or rebuild a file from an edit replay. Also triggers on 找回会话, 会话被覆盖, 历史会话搜索, 文件被删了, session 丢了, 找回某个文件, 重放编辑.
小红书图文笔记自动发布技能。通过 ego-browser 自动化完成图片上传、标题填写、正文编辑、 话题标签、发布等全流程。附带 28 种多样式风格卡片生成器(含 3 种照片背景氛围主题), 卡片主题、布局、背景图、遮罩强度、模糊、颗粒等参数均可自由配置。 当用户要求发小红书、发布图文笔记、上传到小红书、小红书发帖或涉及小红书内容发布时触发此技能。 前置依赖:ego-browser (ego-lite) 已安装且正在运行,小红书账号已登录。
Guided token optimization for AI agent workspaces. Triggers on phrases like "save tokens", "optimize tokens", "context window too large", "memory files too b...
将 Markdown/纯文本内容智能分析、排版并导出为高分辨率精美长图或分享海报(内置 18 种视觉风格)。 当用户说「生成长图」「做海报」「文字转图片」「高颜值排版」「做大图」「make a poster」 「export as image」「generate image from text/markdown」等意图时触发本技能。
Generic skill-quality auditor for any agent skill (Claude, OpenClaw, Cursor, etc.). Runs a 7-dimension static analysis (D1 process closure & idempotency, D2 tool/command conventions, D3 portability & defense, D4 skill usability, D5 security & op risk, D6 code & doc quality, D7 dependency & footprint) with explicit ERR / WARN severity, 120-point scoring (pass line 90 + zero ERR), and an opt-in `--fix` workflow that always backs up first. Two depths: L1 static (~2 min) and L2 dryRun (~5 min, read-only hub + reachability checks). Strict red lines — read-only by default, never executes the audited skill's writes. Use when the user asks to "audit a skill", "check skill quality", "is this skill ready to ship", "lint my skill", or runs this tool by name. Triggers also: "审计这个 Skill"、"检查 Skill 质量"、"Skill 能上线吗"、 "skill-deep-audit"、"审一下 xxx skill"。
Turn any content — Markdown, plain text, images, tables, Excel (.xlsx), Word (.docx) — into a polished single-page HTML, pick one of 19 built-in themes, set the page Title and FavIcon, then publish it as a live page. When the input is already a well-designed HTML page (or an image with a clear layout), it switches to "layout inheritance" mode: the original layout is kept intact and only the colour theme is swapped, instead of tearing it apart and rebuilding. Use when the user says "turn this into a web page", "make this an HTML page", "convert this doc/table/Excel to HTML", "make it pretty", "把这个转成网页", "做成 HTML 页面", "内容转 HTML".