ClaudeMods
☰
ZH-TW
● 0 人在線上 · 瀏覽 0 次
贊助提交作品
GitHub 儲存庫 · 發布者 agarzon

agarzon

個人 Claude Code 技能與工作流程擴充。

agarzon@agarzon

agarzon/claude-plugins/tree/master/plugins/agarzon

已翻譯

關於這個 mod

claude-plugins

Alexander Garzon 的個人 Claude Code 外掛 marketplace。這是一個公開的 GitHub 儲存庫,也兼作 CC marketplace,透過 Claude Code 原生的 autoUpdate,將自訂技能、掛鉤、主題與輸出樣式(之後還有命令/代理程式/MCP)分發到所有機器。

安裝

claude plugin marketplace add agarzon/claude-plugins
claude plugin install agarzon@agarzon-plugins

在 ~/.claude/plugins/known_marketplaces.json 的 agarzon-plugins 項目設定 autoUpdate: true,機器就會在下一個工作階段拉取新的技能。

新增技能、掛鉤、mod、主題或輸出樣式

  1. 放入 plugins/agarzon/skills/<name>/SKILL.md(或 output-styles/<name>.md,或編輯 hooks/hooks.json,或編輯 hooks/register.tsx 中的 mod;使用 claude plugin validate plugins/agarzon 與 claude plugin test plugins/agarzon 檢查 mod)。
  2. 更新 plugins/agarzon/.claude-plugin/plugin.json 中的 version。
  3. 提交並推送。啟用 autoUpdate 的機器會在下一個工作階段拉取它。

第 2 步不可省略——沒有版本更新就不會傳播任何內容。

內容

  • handoff/wrap(技能)——將待處理工作存到 HANDOFF.md,在新的工作階段繼續,或結束今天的工作。見下文。
  • 工作階段 mod(hooks/register.tsx)——提示快取倒數與警告、輸出樣式切換器、上下文填充提示、交接自動化,以及已載入的技能清單。見下文。
  • claude-mem 同步(掛鉤與指令碼)——讓 claude-mem 記憶在各台機器之間保持同步。見下文。
  • ELI5(輸出樣式)——使用簡單的詞、簡短的回答,適合腦袋已經很疲憊時。可選擇 agarzon:ELI5——外掛樣式使用 plugin:style 命名空間,單獨的 ELI5 不會解析到任何內容。可在 /config 面板選取,或在 settings.json 中設定 "outputStyle": "agarzon:ELI5"。注意,內嵌的 /config outputStyle= 補全只提供五個內建樣式,所以這個樣式不會出現在那裡。output-styles/ 中的檔案會依慣例被拾取,不需要 plugin.json 鍵。

handoff 與 wrap

位於儲存庫根目錄、並透過 .git/info/exclude 排除在 git 外的 HANDOFF.md,是跨工作階段傳遞工作的待辦清單。它只保存待處理工作:完成後移除各項,檔案空了就刪除。

  • /handoff 會寫入或合併檔案,然後呼叫 mod 的 handoff_ready 工具。回合結束時,mod 會執行 /rename <name>、/clear、/rename <name>-2,並傳送 “Read HANDOFF.md and continue” 給下一個工作階段。Claude Code 會讓工作階段名稱跨過 /clear 保留,所以第二次重新命名能讓兩個工作階段在歷史中分開。
  • /wrap 會處理同一個檔案,加上日終整理工作(提交、刪除要清理的產物、記憶與 vault 更新,在一個批次中核准),重新命名工作階段並停止。
  • 找到 HANDOFF.md 的新工作階段會在提示框上方提供 Load/Dismiss。

工作階段 mod

mod 是一個外掛掛鉤模組:hooks/hooks.json 會在經典命令掛鉤旁的 modules 下列出它。它會在提示框上方繪製這一列:

⧗ cache 42m │ [ Concise ] │ ctx 62% → /handoff
loaded: ponytail·hook 1.3k  superpowers·hook 3.3k  plugin-authoring 4.9k ×2
  • 快取倒數。 提示快取的生命週期是 1 h(記錄中只顯示 ephemeral_1h 寫入)。主迴圈完成一次發出 API 呼叫的回合後時鐘會重新開始;子代理程式回合與本機命令不計入。剩下 10 min 時會顯示通知並播放聲音(WSL 使用 powershell.exe,macOS 使用 afplay)。超過零後,下一則訊息會以 2x 輸入價格重新快取整個上下文。
  • 輸出樣式。 按鈕會循環切換 /config 的 outputStyle 列。它只提供內建樣式,所以 agarzon:ELI5 不在輪換中。
  • 上下文提示。 填充達到 60 % 時,通知和 ctx 標記會建議 /handoff。
  • 已載入清單。 目前上下文中的每個技能內文和每個掛鉤注入的區塊都會列出;從記錄讀取,因此在 --resume 後仍會保留。技能是青色,掛鉤是洋紅色;當內文在上下文中出現超過一次時顯示 紅色 ×N。重啟或使用 --resume 時會發生這種情況:Claude Code 的「已載入」去重存在處理程序記憶體中,因此重新呼叫會再次注入整個內文,而輸入 /skill 每次都會重新注入。只有 /compact 或新的工作階段會移除複本。

mod API 仍在搶先體驗階段,各發布版本之間會變動;claude plugin validate 會回報目前執行版本會拒絕的內容。

技能 frontmatter 中的 allowed-tools 是命令專用鍵;把它加入 SKILL.md 會使技能載入失敗,並顯示 Execute skill: <name>。

claude-mem 同步

claude-mem 將記憶存放在每台機器各自的本機 SQLite 資料庫中,因此每台機器都累積自己的歷史,彼此永遠看不到對方的。這些掛鉤不用伺服器就能補上這個缺口。

| 檔案 | 作用 | |---|---| | hooks/hooks.json | SessionStart → 匯入對等端 · Stop → 發布自己的新列 | | scripts/mem-sync.sh | 掛鉤入口:export | import | | scripts/mem-export.sh | DB → /api/import 負載。增量模式使用 --since <epoch> | | scripts/mem-import.sh | 分塊、有序、可恢復的匯入。--dry-run 不傳送也會進行 FK 檢查 |

恢復的工作階段會保留 content_session_id,但取得新的 memory_session_id;而 sdk_sessions 對 content_session_id 設有唯一限制。因此,對等端傳來一個你已持有的工作階段版本時,會被當作重複項丟棄,而它的摘要接著會因外鍵失敗,永久卡住該對等端的匯入。mem-import.sh 會在送出前把傳入的工作階段 id 改寫成本機 id。每一端在接收時都會重新連結,所以兩台機器對標籤的看法不同也沒關係。--dry-run 抓不到這件事:它的 FK 檢查只在負載內部進行。

資料以 JSON 透過 Syncthing 在 ~/General/claude-mem-sync/<device>.json 之間傳送——永遠不要用 git,這個儲存庫是公開的。設定 CLAUDE_MEM_SYNC_DIR 可將它指到其他地方。

每個檔案只有一個寫入者,這才安全:每台機器只會寫自己的 <device>.json,所以沒有兩台機器會碰同一個檔案,.sync-conflict-* 也不會出現。裝置名稱取自 CLAUDE_MEM_CLOUD_SYNC_DEVICE_NAME,否則取自 claude-mem 的設定,再否則取自 hostname -s。

匯出會直接讀 SQLite,不使用 claude-mem 的讀取 API;該 API 最多只能處理接近 200 列,還會改寫工作階段 id,讓自己的輸出重新匯入時無法通過外鍵檢查。匯入會經過 worker 的 POST /api/import,因此去重、交易與 FTS 觸發器都交給供應商處理。

同步從不阻塞工作階段:每條路徑都以 0 結束,問題會寫到 ~/.claude-mem/logs/mem-sync.log。

可接受的上限。 只能追加——刪除與標題/專案編輯不會傳播。在兩台機器上完成的相同工作會保留兩份,因為去重鍵使用工作階段 id,而它們在每台機器上都不同。每個工作階段在匯入後只會保留一個摘要。嵌入不會同步;Chroma 在每台機器上都是本機的。

一次性整合

要替逐漸分歧的機器播種,請繞過掛鉤,手動合併快照:

mem-export.sh --db <snapshot>.db --out peer.json
mem-import.sh peer.json --dry-run   # expect 0 orphans
mem-import.sh peer.json

用 sqlite3 <db> ".backup <out>" 建立快照——資料庫是 WAL 模式且有作用中的寫入者,因此 cp 可能會擷取撕裂狀態。

接著在每台機器上播種水位線,讓第一次 Stop 掛鉤只發布新工作,不要重新傳送機器已經共享的歷史:

date +%s000 > ~/.claude-mem/mem-sync.watermark

跳過這一步,第一次匯出就會發布機器持有的每一列——這是正確的,但第一次同步會不必要地變大,接著每個對等端都會重新匯入並跳過它們。

完整設計與理由請見 docs/design.md。

安裝

請先查看作者 README,確認 marketplace 與外掛名稱;指令可能隨儲存庫結構而變動。

claude plugin marketplace add agarzon/claude-plugins
claude plugin install agarzon
原文 / README

claude-plugins

Alexander Garzon's personal Claude Code plugin marketplace. A public GitHub repo that doubles as a CC marketplace, distributing custom skills, hooks, themes and output styles (and later commands/agents/MCP) across all machines via Claude Code's native autoUpdate.

Install

claude plugin marketplace add agarzon/claude-plugins
claude plugin install agarzon@agarzon-plugins

Set autoUpdate: true for the agarzon-plugins entry in ~/.claude/plugins/known_marketplaces.json so machines pull new skills on the next session.

Add a skill, hook, mod, theme, or output style

  1. Drop plugins/agarzon/skills/<name>/SKILL.md (or output-styles/<name>.md, or edit hooks/hooks.json, or the mod in hooks/register.tsx; check a mod with claude plugin validate plugins/agarzon and claude plugin test plugins/agarzon).
  2. Bump version in plugins/agarzon/.claude-plugin/plugin.json.
  3. Commit and push. Machines with autoUpdate pull it on the next session.

Step 2 is not optional — without a version bump nothing propagates.

Contents

  • handoff / wrap (skills) — save pending work to HANDOFF.md and continue in a fresh session, or close the day. See below.
  • Session mod (hooks/register.tsx) — prompt-cache countdown and warning, output-style switcher, context-fill nudge, handoff automation, and the list of loaded skills. See below.
  • claude-mem sync (hooks + scripts) — keeps claude-mem memory in step across machines. See below.
  • ELI5 (output style) — small words, short answers, for a fried brain. Selectable as agarzon:ELI5 — plugin styles are namespaced plugin:style, and bare ELI5 resolves to nothing. Pick it in the /config panel, or set "outputStyle": "agarzon:ELI5" in settings.json. Note that the inline /config outputStyle= completion only offers the five built-ins, so this style never appears there. Files in output-styles/ are picked up by convention; no plugin.json key needed.

handoff and wrap

HANDOFF.md, at the repo root and kept out of git through .git/info/exclude, is the to-do list that carries work between sessions. It holds only pending work: each item is removed when done and the file is deleted when empty.

  • /handoff writes or merges the file, then calls the mod's handoff_ready tool. When the turn ends the mod runs /rename <name>, /clear, /rename <name>-2, and sends the next session "Read HANDOFF.md and continue". Claude Code carries a session's name across /clear, so the second rename keeps the two sessions apart in history.
  • /wrap does the same file plus the end-of-day chores (commits, artifacts to delete, memory and vault updates, approved in one batch), renames the session and stops.
  • A new session that finds a HANDOFF.md offers Load / Dismiss above the prompt.

Session mod

A mod is a plugin hooks module: hooks/hooks.json lists it under modules, next to the classic command hooks. The row it draws above the prompt:

⧗ cache 42m │ [ Concise ] │ ctx 62% → /handoff
loaded: ponytail·hook 1.3k  superpowers·hook 3.3k  plugin-authoring 4.9k ×2
  • Cache countdown. The prompt cache lives 1 h (transcripts show only ephemeral_1h writes). The clock restarts when a main-loop turn that made an API call completes; subagent turns and local commands do not count. At 10 min left: a toast and a sound (powershell.exe on WSL, afplay on macOS). Past zero the next message re-caches the whole context at 2x input price.
  • Output style. The button cycles the /config outputStyle row. It offers only the built-in styles, so agarzon:ELI5 is not in the rotation.
  • Context nudge. At 60 % fill, a toast and the ctx marker suggest /handoff.
  • Loaded list. Every skill body and every hook-injected block in context now, read from the transcript so it survives --resume. Skills cyan, hooks magenta, red ×N when a body is in context more than once. That happens across a restart or --resume: Claude Code's "already loaded" dedupe lives in process memory, so a re-invocation injects the whole body again, and a typed /skill re-injects every time. Only /compact or a fresh session removes the copies.

The mod API is early access and changes between releases; claude plugin validate reports anything the running build would refuse.

allowed-tools in a skill's frontmatter is a command-only key; adding it to a SKILL.md makes the skill fail to load with Execute skill: <name>.

claude-mem sync

claude-mem stores its memory in a local SQLite database per machine, so each machine accumulates its own history and none of them ever see each other's. These hooks close that gap without a server.

| File | Role | |---|---| | hooks/hooks.json | SessionStart → import peers · Stop → publish own new rows | | scripts/mem-sync.sh | the hook entry point: export | import | | scripts/mem-export.sh | DB → /api/import payload. --since <epoch> for incremental | | scripts/mem-import.sh | chunked, ordered, resumable import. --dry-run does an FK check without sending |

A resumed session keeps its content_session_id but gets a new memory_session_id, while sdk_sessions is unique on content_session_id — so a peer's version of a session you already hold is dropped as a duplicate and its summaries then fail the foreign key, jamming that peer's import permanently. mem-import.sh rewrites incoming session ids to the local ones before posting. Each side relinks on the way in, so the two machines disagreeing about the label is harmless. --dry-run cannot catch this: its FK check is payload-internal.

Data travels as JSON in ~/General/claude-mem-sync/<device>.json over Syncthing — never git, this repo is public. Set CLAUDE_MEM_SYNC_DIR to point elsewhere.

One writer per file is what makes this safe: a machine only ever writes its own <device>.json, so no two machines touch the same file and .sync-conflict-* cannot happen. Device name comes from CLAUDE_MEM_CLOUD_SYNC_DEVICE_NAME, else claude-mem's settings, else hostname -s.

Export reads SQLite directly rather than claude-mem's read API, which caps out near 200 rows and rewrites session ids such that its own output fails the foreign key on re-import. Import goes through the worker's POST /api/import so dedupe, transactions and FTS triggers stay the vendor's problem.

Sync never blocks a session: every path exits 0 and problems go to ~/.claude-mem/logs/mem-sync.log.

Accepted ceilings. Append-only — deletions and title/project edits do not propagate. Identical work done on two machines survives twice, because dedupe keys on session id and those differ per machine. Only one summary per session survives an import. Embeddings never sync; Chroma is local per machine.

One-time consolidation

To seed machines that have been drifting apart, bypass the hooks and merge snapshots by hand:

mem-export.sh --db <snapshot>.db --out peer.json
mem-import.sh peer.json --dry-run   # expect 0 orphans
mem-import.sh peer.json

Take snapshots with sqlite3 <db> ".backup <out>" — the database is WAL-mode with a live writer, so cp can capture a torn state.

Then seed the watermark on each machine so the first Stop hook publishes only new work instead of re-shipping the history the machines already share:

date +%s000 > ~/.claude-mem/mem-sync.watermark

Skip this and the first export publishes every row the machine holds — correct, but a needlessly large first sync that every peer then re-imports and skips.

See docs/design.md for the full design and rationale.

更多類似作品