既有 Stop 钩子 token-stats-hook 记的是跨会话累计快照, 无法区分"这次会话 用了多少"; session-end-log 在 SessionEnd 时按 session_id 解析本次 transcript 做单会话统计, 产出一行可回溯的索引写入 ~/.claude/log.md, 方便事后盘点 哪场会话烧了哪些 token。Python 写零依赖, Ubuntu 自带 python3 免构建。
既有 Stop 钩子 token-stats-hook 记的是跨会话累计快照, 无法区分"这次会话 用了多少"; session-end-log 在 SessionEnd 时按 session_id 解析本次 transcript 做单会话统计, 产出一行可回溯的索引写入 ~/.claude/log.md, 方便事后盘点 哪场会话烧了哪些 token。Python 写零依赖, Ubuntu 自带 python3 免构建。