Memory

collective-memory

Try it

Broadcast 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

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 update
  • file: which file to write into (default MEMORY.md)

File routing rules:

Content typeTarget file
Facts, rules, lessons, tool paths, APIsMEMORY.md
Workflows, do/don't, dev conventionsAGENTS.md
Tool commands, config params, account infoTOOLS.md
Information about the user themselvesUSER.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):

  1. $COLLECTIVE_MEMORY_TARGETS env
  2. ~/.claude/projects/ (Claude Code)
  3. ~/.openclaw/agents/ (OpenClaw)
  4. CWD's immediate sibling directories
  5. 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]
FlagRepeatableDescription
--workspace noSingle workspace (legacy mode). Requires --file.
--target :yesExplicit workspace:filename pair, e.g. /proj:MEMORY.md
--discover-under yesAuto-find first-level subdirs. Requires --file.
--file noDefault file used by --workspace and --discover-under
--key noRequired. Heading lookup key.
--content noRequired. Full block to upsert, must include its own ## heading.
--dry-runnoPreview only; no files written.
--jsonnoEmit 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 install required)

Key Files

FilePurpose
scripts/update_memory.pyThe upsert engine. Multi-target + dry-run + JSON.

Related skills

Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.

by Iván1 installs

Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.

by johnpatternai21 installs8 stars

Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.

by nssa.io1.0k installs47 stars

Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.

by Iván1 installs

Read and write Excel workbooks, worksheets, ranges, tables, and charts in OneDrive through Microsoft Graph with managed OAuth.

by byungkyu800 installs42 stars

More from songhonglei

Browse all skills

Recover 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 丢了, 找回某个文件, 重放编辑.

by blqbzf

小红书图文笔记自动发布技能。通过 ego-browser 自动化完成图片上传、标题填写、正文编辑、 话题标签、发布等全流程。附带 28 种多样式风格卡片生成器(含 3 种照片背景氛围主题), 卡片主题、布局、背景图、遮罩强度、模糊、颗粒等参数均可自由配置。 当用户要求发小红书、发布图文笔记、上传到小红书、小红书发帖或涉及小红书内容发布时触发此技能。 前置依赖:ego-browser (ego-lite) 已安装且正在运行,小红书账号已登录。

by songhonglei2 installs1 stars

Guided token optimization for AI agent workspaces. Triggers on phrases like "save tokens", "optimize tokens", "context window too large", "memory files too b...

by songhonglei2 installs1 stars

将 Markdown/纯文本内容智能分析、排版并导出为高分辨率精美长图或分享海报(内置 18 种视觉风格)。 当用户说「生成长图」「做海报」「文字转图片」「高颜值排版」「做大图」「make a poster」 「export as image」「generate image from text/markdown」等意图时触发本技能。

by songhonglei2 installs

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"。

by songhonglei1 installs1 stars

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".

by songhonglei3 installs