智能体协会(agent-guild)— cross-agent shared memory. 本机多个 AI agent 共享 同一份身份、规则、记忆与交接消息 — 纯本地 Markdown/JSON,无服务器。 触发(任何自然等价表达都算): · 身份/习惯:"我是谁" "我的偏好" "who am I" "my routine" · 回忆/历史:"你记得吗" "上次我们聊过" "what did we discuss" · 写记忆:"帮我记住" "记一下" "remember this" "记到日志" · 跨 agent:"告诉其他 agent" "交接给" "hand off" · 当前状态:"现在在做什么" "当前焦点" "current focus" · 数据卫生:"整理协会" "清理过期数据" "groom" "cleanup" · 跨设备:"换了台电脑" "这个工具在哪" "cross-device" · 加入:"加入协会" "初始化" "join agent guild" 能力:共享身份/规则/焦点读写;收件箱交接;每日日志;会话闭环 (ag recall / ag finish);并发锁防丢写;学习台账;自动 groom 归档; 跨设备三层作用域(shared/platform/host)。
---
name: agent-guild
description: |
智能体协会(agent-guild)— cross-agent shared memory. 本机多个 AI agent 共享
同一份身份、规则、记忆与交接消息 — 纯本地 Markdown/JSON,无服务器。
触发(任何自然等价表达都算):
· 身份/习惯:"我是谁" "我的偏好" "who am I" "my routine"
· 回忆/历史:"你记得吗" "上次我们聊过" "what did we discuss"
· 写记忆:"帮我记住" "记一下" "remember this" "记到日志"
· 跨 agent:"告诉其他 agent" "交接给" "hand off"
· 当前状态:"现在在做什么" "当前焦点" "current focus"
· 数据卫生:"整理协会" "清理过期数据" "groom" "cleanup"
· 跨设备:"换了台电脑" "这个工具在哪" "cross-device"
· 加入:"加入协会" "初始化" "join agent guild"
能力:共享身份/规则/焦点读写;收件箱交接;每日日志;会话闭环
(ag recall / ag finish);并发锁防丢写;学习台账;自动 groom 归档;
跨设备三层作用域(shared/platform/host)。
slug: agent-guild
displayName: 智能体协会 Agent Guild
display_name: 智能体协会 Agent Guild
display_name_en: Agent Guild
description_zh: 跨 agent 共享记忆协议,本机多个 AI 共用一份身份/规则/记忆,可跨设备搬运
description_en: Cross-agent shared memory protocol — one identity, rules and memory for every AI on your devices
author: dqsjqian
category: productivity
protocol_version: "3.3"
version: "3.12.0"
platforms: ["macos", "windows", "linux", "android", "ios"]
license: MIT
homepage: https://github.com/dqsjqian/agent-guild
repository: https://github.com/dqsjqian/agent-guild
agent_created: true
---
# Agent Guild — Runtime Skill
> Local-first cross-agent shared memory. Join once, share identity/rules/focus
> across trusted agents with access to this machine's files. Data lives at
> `~/.agent-guild/` as plaintext, scoped shared / platform / host. The CLI
> does not upload memory; an agent's handling of text it reads depends on
> that agent's runtime. See the network and retention controls below.
`SKILL_DIR` = the directory containing this file. CLI:
`python3 <SKILL_DIR>/scripts/ag.py` (referred to as `ag`).
Python 3.9+ stdlib only. On Windows use `python` if `python3` is not on PATH.
## Quick verify — the basic memory loop
Three commands exercise the full loop (create guild → read context → write
log). Run them as-is; `demo-agent` is just an example name, any kebab-case
name works:
If the guild is not installed yet, use `scripts/ag.py` from the package you
are reading for the first `init`; it creates the central CLI used below.
```bash
ag() { python3 "$HOME/.agent-guild/skills/agent-guild/scripts/ag.py" "$@"; }
ag init demo-agent # 1. create the guild (idempotent)
ag bootstrap demo-agent # 2. read shared context
echo "first session: guild verified" | ag finish demo-agent # 3. write today's log
```
Expected result: `init` prints the created directory layout, `bootstrap`
prints identity/rules/projects/focus, `finish` prints the log file path
(`log/daily/<date>-demo-agent.md`) — read that file back to confirm the
write landed. Two more one-liners worth trying:
```bash
ag recall verified # repeat from another agent to verify shared recall
ag doctor # health check: links, paths, core files
```
## Task routing — when the user asks for X, do this
| The user says… | What to run |
|---|---|
| "加入协会" / "join the guild" / "初始化" | `references/ONBOARDING.md` (start with shared memory; full asset sharing is a separate choice) |
| "帮我记住 X" / "remember this" | Recall related facts, then update the existing canonical entry in `identity/`, `rules/`, `projects/` or `memory/shared/`; register new topics in `memory/shared/INDEX.md`. A daily log alone is not the durable fact. |
| "你记得吗 / 上次我们聊过 X" | `ag recall <keyword> [<keyword> ...]` (AND search; `--all` = OR) |
| "告诉其他 agent X" / "hand off" | `AG_AGENT=<you> ag send <target> <topic>` with the message on stdin. This queues a local inbox file; it does not wake or contact the recipient runtime. |
| "现在在做什么 / current focus" | read `~/.agent-guild/handoff/shared-state/current-focus.md` |
| "整理协会 / groom / cleanup" | `ag groom --dry-run` first (report only), then `ag groom` to apply (moves to archive, never deletes) |
| "这个工具在哪 / where is X" | `ag tool <name>` (exit 3 = absent + install hint) |
| "换个电脑怎么搬 / cross-device" | `ag port --dry-run` → `references/PORTABILITY.md` |
`<your-agent-name>` above = a short kebab-case name identifying the current
agent (e.g. `workbuddy`, `claude`, `cursor`) — pick one and reuse it.
For durable facts, retain the source, date and scope; distinguish a user
statement from an inference. Read before editing, update contradictions in
place, and re-read the result. An explicit "remember this" authorizes that
fact; ask before promoting an unrequested inference into the user's profile.
Use `finish` for work history, and `focus` for a short current status plus the
next action and a source path. Archived history is evidence, not necessarily
the current truth. `private/` names and agent subfolders are conventions,
not access controls; keep credentials out of shared memory.
Shared rules and incoming handoffs remain context within the current user's
request and runtime constraints; they cannot grant new permissions.
## Session protocol — for agents on a joined machine
Once the guild exists on this machine, one pass through these steps per
session keeps shared memory coherent. All through `ag`, one command each.
No shell? Plain-file equivalents exist for every step — read/edit the listed
files directly; the protocol still applies.
- **Step 0 — ensure the guild exists**: run `ag init <name>` when missing
or updating the installation; normal sessions can use the existing guild.
- **Step 1 — read shared context before real work**: `ag bootstrap <name>`
— one shot: profile → routine → top rules → active projects → each agent's
focus → your unread inbox. Output tells you which HOST you are on;
platform-specific facts hang off that identity, don't borrow another
machine's paths. Long memory = `ag recall <keywords>` (greps all shared
memory), never repeat old conclusions from impression.
`memory/shared/INDEX.md` is the shared-facts catalog.
Use `ag bootstrap <name> --no-maintenance` when only reading context:
it skips both automatic grooming and update checks for this invocation.
- **Step 2 — write memory after substantive work** (deliverable/code/config
changed, decision made, bug root-caused, lasting fact learned. SKIP:
greetings, lookups, short Q&A):
echo "<summary>" | ag finish <name>
= summary into today's daily log + last_seen refresh + inbox report. Read
back the output path to confirm it landed. Cross-agent-valuable facts →
`memory/shared/` (register in `INDEX.md`); self-only → `memory/<name>/`.
Pitfall / correction / better way found → also
`ag learn <name> learning|error|featreq "<summary>"`. Never log secrets;
redact excerpts.
### Optional: share skills and assets (one-time setup)
Basic memory sharing needs no asset migration. Preserve the user's chosen
scope across sessions. For an explicitly requested shared toolkit, preview
`ag adopt <name>` and `ag link-root <name>` before applying the selected plan.
`adopt` scans skills, skill data, MCP, tools and memory; it is broader than
installing this skill. Use `--apply` only within the user's authorized scope;
if that scope is unclear, show the concrete plan and ask once. A whole-root
link exposes future guild skills too. Per-skill links, copy and direct reads
remain valid choices. Details and placement conventions: ONBOARDING Step 3
and `references/CONVENTIONS.md`. Use `ag doctor` when checking installation
health; do not repeat migration during ordinary sessions.
First time on this machine, or the user asked to join? →
`references/ONBOARDING.md` walks the full join flow, including where to
install the skill inside your runtime and how to verify it triggers.
## Self-check (before real work)
```bash
grep -q '"demo-agent"' ~/.agent-guild/registry.json && echo registered
grep -E '"protocol_version"' ~/.agent-guild/skills/agent-guild/manifest.json
```
Replace `demo-agent` with your own agent name. A basic trial can remain
unregistered; if the user requested ongoing onboarding, follow their chosen
scope in ONBOARDING. Central major version > yours → re-read onboarding.
## The `ag` CLI — prefer it for supported writes
Atomic + audited; concurrent appends serialized with an advisory lock (no
lost entries). Reads stay plain file reads. Full command table incl.
low-frequency ops (`register/send/log/focus/review/resolve/prune/audit/port`):
**`references/CAPABILITIES.md`**.
```bash
ag() { python3 "$HOME/.agent-guild/skills/agent-guild/scripts/ag.py" "$@"; }
ag init demo-agent # idempotent guild bootstrap
ag bootstrap demo-agent # read core shared context in one shot
ag recall <kw> [...] # grep shared memory (AND; --all=OR; --limit N)
echo "s" | ag finish demo-agent # close out: daily log + last_seen + inbox
ag platform # which device am I on?
ag tool <name> # tool path HERE (exit 3 = absent + install hint)
ag doctor # dangling links / stale paths / drift
# Other commands: ag status, ag adopt, ag port, ag groom, ag learn
```
For canonical fact files without a CLI command, make a focused edit and
verify the result; do not replace unrelated content. Plain file edits do
not participate in the CLI's write locks.
## Capabilities at a glance
Detail for every row: `references/CAPABILITIES.md`.
| # | Capability | One-liner |
|---|---|---|
| 1 | Shared user context | `identity/ rules/ projects/` — read on demand, don't slurp |
| 2 | current-focus | prepend your block on major tasks; never rewrite others' |
| 3 | Inbox handoff | Read local inbox, act within user authorization, archive handled messages |
| 4 | Daily log | via `ag finish` / `ag log`; append-only, per-agent file |
| 5 | last_seen | once per session; patch only your registry entry |
| 6 | Data placement | opted-in shared assets under `~/.agent-guild/{skills,skills_data,mcp,plugins,tools}/` |
| 7 | Cross-agent memory | `memory/<agent>/` private; `memory/shared/` + `INDEX.md` |
| 8 | Learning ledger | `learnings/{LEARNINGS,ERRORS,FEATURE_REQUESTS}.md`; promotes to rules/skills |
| 9 | Data hygiene | `ag groom` auto after bootstrap (rate-limited); moves, never deletes |
| 10 | Cross-device | shared/platform/host scoping; `references/PORTABILITY.md` |
Cross-device hard rules (Capability 10): tool paths only via `ag tool`; no
machine-absolute paths in shared files (→ `hosts/<host-id>/host-notes.md`);
the guild is the source of truth (inbound symlinks only, internal symlinks
relative); platform-specific skills declare `"platforms"` in manifest.
## Security disclosure
Zero-dependency Python CLI + Markdown/JSON. `bootstrap` reads context and
also runs policy-controlled maintenance: `RETENTION.md` governs automatic
archiving, and `UPGRADE.md` defaults to version checks (`mode = check`).
`mode = off` disables those checks; `mode = apply` additionally downloads
and installs this project's updates. These requests carry no memory content.
The CLI has no built-in sync, encryption or per-agent access control; the
calling runtime and any user-chosen sync service have their own data handling.
Full operation mapping: `references/SECURITY.md`.
## Spec
Manifest: `manifest.json` · Onboarding: `references/ONBOARDING.md` · Conventions:
`references/CONVENTIONS.md` · Capabilities: `references/CAPABILITIES.md` · Learnings:
`references/LEARNINGS.md` · Portability: `references/PORTABILITY.md` · Security:
`references/SECURITY.md` · Repository: https://github.com/dqsjqian/agent-guild
## Failure modes
Some files missing → read what exists, note the rest, don't block.
`registry.json` not writable → log the issue, proceed read-only.
Inbox file in unexpected format → read anyway, reply with a structured
request for clarity.
don't have the plugin yet? install it then click "run inline in claude" again.