Claude Code 会话统计工具 — 分析 AI Coding 工程指标
Project description
cc-statistics
English | 中文
AI Coding 会话统计工具 — 支持 Claude Code / Gemini CLI / Codex / Cursor,从本地数据中提取工程指标。
CLI Demo
核心亮点
- 多数据源 — 支持 Claude Code、Gemini CLI、Codex、Cursor,可切换或聚合统计
- 费用估算 — 内置 Opus / Sonnet / Haiku / Gemini 2.5 Pro / Flash / GPT-4o 等模型定价
- 多维统计 — 指令数、工具调用 Top 10、开发时长(AI vs 用户)、代码变更(按语言)、Token(按模型)
- 每日趋势 — 14 天费用趋势图,直观掌握 AI 使用规律
- 用量预警 — 设置单日/每周费用上限,超限时状态栏变红 + 系统通知
- 周报/月报 — 自动生成 Markdown 统计报告,支持飞书/钉钉/Slack 推送
- 纯本地 — 所有数据读取自本地文件,不联网,不上传
- 三种模式 — CLI 命令行 + Web Dashboard(跨平台)+ macOS 原生状态栏面板
- 双语 — 自动跟随系统语言,支持中文 / English 手动切换
会话管理:搜索、恢复、分享
Claude Code 原生只提供
claude --resume(交互式选择器)和claude --continue(续最近一个),没有内容搜索、没有导出、没有分享。cc-stats 补齐了这些能力。
搜索
按关键词搜索所有历史会话内容,快速定位到目标对话:
# CLI:按关键词搜索并导出
cc-stats --export-chat "登录bug"
macOS 面板内置搜索框,实时过滤会话列表,输入关键词即可匹配对话内容。
恢复
找到目标会话后,一键复制 claude --resume <session-id> 命令恢复对话:
- macOS 面板 — 点击会话卡片的「恢复」按钮,命令自动复制到剪贴板,粘贴到终端即可继续
- CLI —
--export-chat导出的 Markdown 文件头部包含 session ID,配合claude --resume使用
导出 & 分享
将对话导出为可读格式,方便存档或分享给团队:
# 导出为 Markdown(自动保存到桌面)
cc-stats --export-chat "重构方案"
# 包含工具调用详情
cc-stats --export-chat "重构方案" --include-tools
macOS 面板支持选中多条消息,一键生成分享长图(PNG),直接发到微信/飞书/Slack。
请 cc 吃 Token
如果这个工具对你有帮助,欢迎请 cc 吃点 Token :)
安装
# uv(推荐,速度最快)
uv tool install cc-statistics
# pipx(隔离环境,任意终端可用)
pipx install cc-statistics
# pip
pip install cc-statistics
# Homebrew(macOS / Linux)
brew install androidZzT/tap/cc-statistics
零依赖,纯 Python 标准库。
从源码安装(开发用)
git clone https://github.com/androidZzT/cc-statistics.git
cd cc-statistics
uv sync # 或 pip install -e .
使用
CLI 命令行(全平台)
cc-stats # 分析当前目录的所有会话
cc-stats --list # 列出所有项目(Claude + Gemini)
cc-stats compose-album # 按关键词匹配项目
cc-stats --all --since 3d # 最近 3 天所有项目
cc-stats --all --since 2w # 最近 2 周
cc-stats sailor --last 3 # 某项目最近 3 个会话
cc-stats --report week # 生成周报(Markdown)
cc-stats --report month # 生成月报
cc-stats --compare # 多项目对比
cc-stats --compare --since 1w # 最近一周项目对比
Webhook 通知(飞书 / 钉钉 / Slack)
将每日统计摘要推送到团队群:
# 飞书(自动检测)
cc-stats --notify https://open.feishu.cn/open-apis/bot/v2/hook/xxx
# 钉钉
cc-stats --notify https://oapi.dingtalk.com/robot/send?access_token=xxx
# Slack
cc-stats --notify https://hooks.slack.com/services/xxx
# 手动指定平台
cc-stats --notify <url> --platform feishu
推送内容包括:指令数、活跃时长、Token、费用、代码变更、效率评分。
配合 cron 实现每日自动推送:
# 每天 21:00 推送日报到飞书
0 21 * * * cc-stats --notify https://open.feishu.cn/open-apis/bot/v2/hook/xxx
Web Dashboard(全平台:macOS / Windows / Linux)
cc-stats-web
启动后自动打开浏览器,展示暗色主题统计面板:
- 数据源切换:Claude Code / Gemini CLI / All Sources
- 项目选择器 + 时间范围切换(Today / 7d / 30d / All)
- 4 项指标卡片:指令数、工具调用、活跃时长、预估费用
- 每日趋势:14 天费用条形图
- 开发时间:AI 占比环形图 + 时长明细
- 代码变更:Git commit 统计 + 按语言拆分
- Token 用量:按模型堆叠条形图 + 每模型费用
- 工具调用:Top 10 排行
macOS 状态栏面板(仅 macOS)
cc-stats-app
需要 Xcode Command Line Tools(
xcode-select --install),Swift 组件首次启动自动编译。
状态栏:
- Claude logo + 当日 Token 用量 + 预估费用
- 右键菜单切换显示模式(Token+费用 / Token / 费用 / 会话数)
- 超限变红预警
统计面板(原生 SwiftUI):
- 多数据源:Claude Code / Gemini CLI / Codex / Cursor,可切换或聚合展示
- 主题切换:跟随系统 / 深色 / 浅色
- 用量预警:单日/每周费用上限,超限系统通知
- 导出统计数据(JSON / CSV,自动保存到桌面并打开)
- 设置页:开机自启、语言切换、主题切换、版本更新检测
- 会话搜索 + 一键恢复(复制
claude --resume) - 进程管理:查看所有 Claude 进程内存占用
- 工具调用拆分:Skill 和 MCP 工具展开为具体名称
- 全局快捷键
Cmd+Shift+C
命令总览
| 命令 | 平台 | 说明 |
|---|---|---|
cc-stats |
全平台 | CLI 终端输出 |
cc-stats-web |
全平台 | 浏览器 Web 面板 |
cc-stats-app |
仅 macOS | 原生状态栏面板 |
数据来源
所有数据读取自本地文件,不联网,不上传:
| 数据源 | 路径 |
|---|---|
| Claude Code | ~/.claude/projects/<project>/<session>.jsonl |
| Gemini CLI | ~/.gemini/tmp/<project>/chats/<session>.json |
| Codex | ~/.codex/sessions/*.jsonl |
| Cursor | ~/Library/Application Support/Cursor/User/globalStorage/state.vscdb |
| Git 变更 | 项目目录的 git log --numstat |
致谢
- 状态栏 Clawd 动画素材来自 clawd-on-desk — 一个 Electron 桌面宠物应用,通过 hook 系统实时感知 AI coding agent 的工作状态并播放像素风动画。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cc_statistics-0.12.7.tar.gz.
File metadata
- Download URL: cc_statistics-0.12.7.tar.gz
- Upload date:
- Size: 135.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5528f606af169d913227c1edaec4bb2669cc8fb533bf0e59a8903d8390f3d8a6
|
|
| MD5 |
9ad0b0d4f8008fc1ea71c2158e9c8f50
|
|
| BLAKE2b-256 |
dfe8af8e06a04dfbbc0cebee0943d923cc6ca1715e6117f94405578a71ca17eb
|
Provenance
The following attestation bundles were made for cc_statistics-0.12.7.tar.gz:
Publisher:
publish.yml on androidZzT/cc-statistics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cc_statistics-0.12.7.tar.gz -
Subject digest:
5528f606af169d913227c1edaec4bb2669cc8fb533bf0e59a8903d8390f3d8a6 - Sigstore transparency entry: 1194139352
- Sigstore integration time:
-
Permalink:
androidZzT/cc-statistics@994e7046b574fc08a47e3aae4a2f3dca033ed681 -
Branch / Tag:
refs/tags/v0.12.7 - Owner: https://github.com/androidZzT
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@994e7046b574fc08a47e3aae4a2f3dca033ed681 -
Trigger Event:
release
-
Statement type:
File details
Details for the file cc_statistics-0.12.7-py3-none-any.whl.
File metadata
- Download URL: cc_statistics-0.12.7-py3-none-any.whl
- Upload date:
- Size: 146.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de2464b1e4142c0705dc04af50c46dcd9f5f2d9fb172e822162e6b43752088a7
|
|
| MD5 |
24eb5caa292e673c5e19b812cb63078d
|
|
| BLAKE2b-256 |
ce093491f9d1b0da6f39fdf42e70caa1dbd566749330068653974b53554d0433
|
Provenance
The following attestation bundles were made for cc_statistics-0.12.7-py3-none-any.whl:
Publisher:
publish.yml on androidZzT/cc-statistics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cc_statistics-0.12.7-py3-none-any.whl -
Subject digest:
de2464b1e4142c0705dc04af50c46dcd9f5f2d9fb172e822162e6b43752088a7 - Sigstore transparency entry: 1194139357
- Sigstore integration time:
-
Permalink:
androidZzT/cc-statistics@994e7046b574fc08a47e3aae4a2f3dca033ed681 -
Branch / Tag:
refs/tags/v0.12.7 - Owner: https://github.com/androidZzT
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@994e7046b574fc08a47e3aae4a2f3dca033ed681 -
Trigger Event:
release
-
Statement type: