tokentab 是一款本地 CLI 和 Web 工具,能读取 AI 编程助手(Claude Code、Codex、Gemini CLI)的会话日志,并按模型、项目、天数和活动类型汇总显示 token 用量和费用。

Stars

123

7 天增长

+12

Fork 数

17

开放 Issue

0

开源协议

MIT

最近更新

2026-07-18

AI 仓库情报摘要
FR-AI / ANALYSIS

为什么值得关注

无需 API 密钥或网络连接,完全离线使用现有的会话日志,并且基于 Python 标准库构建了轻量级仪表盘。

适合谁使用

  • 使用 Claude Code、Codex 或 Gemini CLI 等 AI 编程助手的开发者
  • 追踪团队 AI 工具成本的工程管理者
  • 偏好本地化分析的隐私敏感用户
  • 优化提示效率和模型选择的开发者

典型使用场景

  • AI 编程助手的月度成本报告
  • 识别哪些项目或模型消耗最多的 token
  • 分析活动类型(编码、调试等)以发现优化机会
  • 将使用摘要粘贴到 PR 或聊天中,无需转义码

项目优势

  • 除 Python 标准库和 `rich` 库外无其他依赖
  • 直接读取已有日志,无需额外设置或配置
  • 同时提供 CLI 和 Web 仪表盘,支持自动图表
  • 确定性的活动分类,快速且离线运行

使用前须知

  • 定价表为手动维护,可能过期;未知模型显示为 $0.00
  • 活动分类为启发式方法,可能不够精确
  • Cursor 支持尚未完成(仅为占位符)
  • 仅支持列出的三/四种工具,无通用日志导入功能

README 快速开始

tokentab

tokentab reads the session logs that Claude Code, Codex, Cursor and Gemini CLI already leave on disk and adds up token usage and cost - broken down by model, by project, by day, and by the kind of work each session was doing. It runs entirely locally: no account, no API key, nothing leaves your machine.

Installing

Clone the repo and install it into your environment:

git clone https://github.com/sequilade/tokentab
cd tokentab
pip install -e .
tokentab

That puts a tokentab command on your path. You can also run it without installing at all - see From source.

What it reads

It understands three tools out of the box, plus a Cursor slot that's wired up but not finished (more on that below).

ToolWhere its logs live
Claude Code~/.claude/projects/**/*.jsonl
Codex~/.codex/sessions/**/rollout-*.jsonl
Gemini CLI~/.gemini/tmp/**/session-*.json
Cursor(stub - see below)

If a tool isn't installed, it's just skipped. You'll only ever see the tools you actually use.

Using it

The bare command gives you the last 7 days across everything:

tokentab

Some other things it does:

tokentab today                     # just today
tokentab month                     # this calendar month
tokentab -p all                    # everything you've ever run
tokentab --provider claude         # one tool only
tokentab --project myapp           # one project
tokentab --from 2026-06-01 --to 2026-06-15   # a specific window
tokentab --json | jq .             # machine-readable, pipe it wherever
tokentab web                       # the same thing, in a browser, with charts

Colour drops automatically when you pipe the output somewhere, so pasting into a PR or a chat doesn't drag a load of escape codes along with it.

The web dashboard

tokentab web

Opens http://localhost:4747 and lays the same numbers out as a monthly statement - total up top, everything itemised below. It reads from disk on every request (the data's tiny, so there's no reason to cache and risk showing you something stale) and binds to localhost only - nothing gets uploaded, same as the CLI. It doesn't even pull fonts from a CDN; it uses whatever serif and mono your system already has, so it works with the network unplugged. Pick a port with --port, or pass --no-open i

项目描述

A CLI that reads Claude Code, Codex, and Gemini CLI session logs and works out how much they cost, by model, project, and day.

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

0xwilliamortiz
精选
0xwilliamortiz GitHub avatar

openclaude-improved

OpenClaude is an open-source CLI coding agent that runs on any platform and supports a wide range of LLM providers, offering the same tools and workflows as Claude Code.

AI 与机器学习大语言模型
577
7-e1even
精选
7-e1even GitHub avatar

learn-agent

A collection of notes on building coding agents, derived from the production development of the desktop agent Reina, with each mechanism simplified into a zero-dependency, single-file Node.js demo.

AI 与机器学习大语言模型
218
makecindy
精选
makecindy GitHub avatar

cindy

Cindy is an open-source AI agent that runs locally on your machine, integrates multiple AI harnesses and models, and provides memory, skills, and automation to perform real work in your projects and apps.

AI 与机器学习大语言模型
958