Claude Code 会话统计工具 — 分析 AI Coding 工程指标
Project description
cc-statistics
English | 中文
Claude Code 会话统计工具 — 从本地 ~/.claude/ 数据中提取 AI Coding 工程指标。
核心亮点
- 费用估算 — 根据 Opus / Sonnet / Haiku / GPT-4o 定价自动计算预估花费
- 会话搜索 & 恢复 — 搜索历史会话内容,点击即可复制
claude --resume命令,一键恢复对话 - 多维统计 — 指令数、工具调用 Top 10、开发时长(AI vs 用户)、代码变更(按语言拆分)、Token 消耗(按模型拆分)
- 每日趋势 — 14 天费用趋势图,直观掌握 AI 使用规律
- 用量预警 — 设置单日/每周费用上限,超限时状态栏变红 + 系统通知
- 纯本地 — 所有数据读取自本地文件,不联网,不上传
- 三种模式 — CLI 命令行 + Web Dashboard(跨平台)+ macOS 原生状态栏面板
- 双语 — 自动跟随系统语言,支持中文 / English 手动切换
安装
# 推荐:pipx 全局安装(隔离环境,任意终端可用)
pipx install cc-statistics
# 或者 pip 安装
pip install cc-statistics
无第三方依赖,仅使用 Python 标准库。
从源码安装(开发用)
git clone https://github.com/androidZzT/cc-statistics.git
cd cc-statistics
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
使用
CLI 命令行(全平台)
cc-stats # 分析当前目录的所有会话
cc-stats --list # 列出所有项目
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 # 生成月报
Web Dashboard(全平台:macOS / Windows / Linux)
cc-stats-web
启动后自动打开浏览器,展示暗色主题统计面板:
- 项目选择器 + 时间范围切换(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 / Codex / Cursor,可切换或聚合展示
- 主题切换:跟随系统 / 深色 / 浅色
- 用量预警:单日/每周费用上限,超限系统通知
- 导出统计数据(JSON / CSV,自动保存到桌面并打开)
- 设置页:开机自启、语言切换、主题切换、版本更新检测
- 会话搜索 + 一键恢复(复制
claude --resume) - 进程管理:查看所有 Claude 进程内存占用
- 工具调用拆分:Skill 和 MCP 工具展开为具体名称
- 全局快捷键
Cmd+Shift+C
命令总览
| 命令 | 平台 | 说明 |
|---|---|---|
cc-stats |
全平台 | CLI 终端输出 |
cc-stats-web |
全平台 | 浏览器 Web 面板 |
cc-stats-app |
仅 macOS | 原生状态栏面板 |
数据来源
所有数据读取自 ~/.claude/ 本地文件,不联网,不上传:
| 数据 | 来源 |
|---|---|
| 会话消息 | ~/.claude/projects/<project>/<session>.jsonl |
| 工具调用 | JSONL 中 assistant 消息的 tool_use 块 |
| Token 用量 | JSONL 中 assistant 消息的 usage 字段 |
| Git 变更 | 项目目录的 git log --numstat |
请 cc 吃 Token
如果这个工具对你有帮助,欢迎请 cc 吃点 Token :)
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.8.1.tar.gz.
File metadata
- Download URL: cc_statistics-0.8.1.tar.gz
- Upload date:
- Size: 68.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bce1efe627e627f7b6ddc0365e6bd2219985f6e76d6965b47e68ae1ebbdccffb
|
|
| MD5 |
3c9f027508e42b6fe5c9cc2b17c07521
|
|
| BLAKE2b-256 |
1721a6e1b50d876c6869b99a5d641570afd23729616ebf8c56c3532a12a3db6f
|
Provenance
The following attestation bundles were made for cc_statistics-0.8.1.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.8.1.tar.gz -
Subject digest:
bce1efe627e627f7b6ddc0365e6bd2219985f6e76d6965b47e68ae1ebbdccffb - Sigstore transparency entry: 1134924291
- Sigstore integration time:
-
Permalink:
androidZzT/cc-statistics@24074fe5fc9daa462ebf96ddcc8ff2b6f23dae5a -
Branch / Tag:
refs/tags/v0.8.1 - Owner: https://github.com/androidZzT
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@24074fe5fc9daa462ebf96ddcc8ff2b6f23dae5a -
Trigger Event:
release
-
Statement type:
File details
Details for the file cc_statistics-0.8.1-py3-none-any.whl.
File metadata
- Download URL: cc_statistics-0.8.1-py3-none-any.whl
- Upload date:
- Size: 81.2 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 |
0f6cf4aa727b763adef6c41796639c56b416c3e82205608d83190532e31fb8c6
|
|
| MD5 |
d18bfb5e647b2535d01297681af96aad
|
|
| BLAKE2b-256 |
19861062cc6a331fcd34dd9701f506e5817d9aa5a0d771bd93b2c59762433d61
|
Provenance
The following attestation bundles were made for cc_statistics-0.8.1-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.8.1-py3-none-any.whl -
Subject digest:
0f6cf4aa727b763adef6c41796639c56b416c3e82205608d83190532e31fb8c6 - Sigstore transparency entry: 1134924323
- Sigstore integration time:
-
Permalink:
androidZzT/cc-statistics@24074fe5fc9daa462ebf96ddcc8ff2b6f23dae5a -
Branch / Tag:
refs/tags/v0.8.1 - Owner: https://github.com/androidZzT
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@24074fe5fc9daa462ebf96ddcc8ff2b6f23dae5a -
Trigger Event:
release
-
Statement type: