用 git notes 做多 Claude Code 会话共享时间线,省掉互发消息
Commercial_Base488 · reddit · 2026-10-16
作者并行运行多个 Claude Code 会话(每项目一个外加 reviewer 会话),会话间互发状态消息浪费 token 且常有延迟重复。他的解法:每个会话把完成的事写成 git note(git notes --ref=timeline append),新会话启动时通过 SessionStart hook 运行约 40 行的 Python 脚本,汇总各仓库最近一天的 commits 和 notes 按时间排序,注入前 20 行到上下文。
关键细节:
- 用 git config notes.displayRef refs/notes/timeline 让 notes 出现在 git log
- 脚本用 git log --branches --tags 而非 --all,避免 notes ref 自身的噪声提交
- CLAUDE.md 加规则:开工前查时间线防重复,完成/交接留 note,仅紧急请求才发消息且限一行
- 优点:状态 ping 基本消失、可查重、抗 compaction/重启(时间线存于 git 而非会话上下文)、零额外基础设施
- 注意:notes 默认不 push,需 git push origin refs/notes/;启动输出保持短以免每 session 白付 token
所属事件:开发者用 git notes 协调多个 Claude Code 并行会话(2 条相关)→
「编程与Agent」频道最新
- 用 AGY Rules 与 PreInvocation Hook 实现多聊天目录隔离 — bibryam · 2026-10-16
- 用 Gemini 玩 Minecraft 模组:游戏内变身任意蜘蛛侠 — zacharynado · 2026-10-16
- 截图丢进 tldraw 标注问题再喂给 Claude:UI 改进工作流 — max__drake · 2026-10-16
- 从聊天框到「交互指挥家」:动态多模态 AI 应用设计思路 — dr_cintas · 2026-10-16
- IBM 工程师亲测五级 AI 编码:7 个并行 agent 各建分支再合并 — TejasKumar_ · 2026-10-16
- 10 个让 AI Agent 拆解应用与游戏的开源逆向工具仓库 — victor_explore · 2026-10-16