Skip to main content

Claude Code 会话统计工具 — 分析 AI Coding 工程指标

Project description

cc-statistics

English | 中文

Claude Code 会话统计工具 — 从本地 ~/.claude/ 数据中提取 AI Coding 工程指标。

CC Stats Dashboard

核心亮点

  • 费用估算 — 根据 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cc_statistics-0.8.2.tar.gz (70.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cc_statistics-0.8.2-py3-none-any.whl (83.0 kB view details)

Uploaded Python 3

File details

Details for the file cc_statistics-0.8.2.tar.gz.

File metadata

  • Download URL: cc_statistics-0.8.2.tar.gz
  • Upload date:
  • Size: 70.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cc_statistics-0.8.2.tar.gz
Algorithm Hash digest
SHA256 34b5ab1d775ae1482ad2d28c559487b3be516ee7b944cc6890bfa0f8a6bf1efc
MD5 d3e66c97ff94a58e170a24625d253983
BLAKE2b-256 b95320f052c3f1552d35812109e85c26bdcd2cccde08188219c94ae7849876b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for cc_statistics-0.8.2.tar.gz:

Publisher: publish.yml on androidZzT/cc-statistics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cc_statistics-0.8.2-py3-none-any.whl.

File metadata

  • Download URL: cc_statistics-0.8.2-py3-none-any.whl
  • Upload date:
  • Size: 83.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cc_statistics-0.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3a6c2b7151c61f4dee68bf44d58409fc96638673c7b6cdba39ddf72e42168293
MD5 585d311deb83b4e7834d1fd42a81ae01
BLAKE2b-256 3b69de926d3d8049a46d7431735da2f6d632d3f34381479787b5976d2d545210

See more details on using hashes here.

Provenance

The following attestation bundles were made for cc_statistics-0.8.2-py3-none-any.whl:

Publisher: publish.yml on androidZzT/cc-statistics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page