[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-96161":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":15,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":21,"hasPages":19,"topics":22,"createdAt":10,"pushedAt":10,"updatedAt":28,"readmeContent":29,"aiSummary":30,"trendingCount":15,"starSnapshotCount":15,"syncStatus":31,"lastSyncTime":32,"discoverSource":33},96161,"tokentab","crwdla\u002Ftokentab","crwdla","A CLI that reads Claude Code, Codex, and Gemini CLI session logs and works out how much they cost, by model, project, and day.","",null,"Python",409,155,9,0,184,56.58,"MIT License",false,"main",true,[23,24,25,26,27],"ai","ai-token-monitor","claude-code","token-optimization","token-usage","2026-09-20 04:01:32","# tokentab\n\ntokentab 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.\n\n\u003Cimg src=\"assets\u002Fdashboard.png\" width=\"620\" alt=\"tokentab web dashboard\" \u002F>\n\n## Installing\n\nClone the repo and install it into your environment:\n\n```\ngit clone https:\u002F\u002Fgithub.com\u002Fcrwdla\u002Ftokentab\ncd tokentab\npip install .\npython cli.py\n```\n\nThat puts a `tokentab` command on your path. You can also run it without installing at all - see [From source](#from-source).\n\n## What it reads\n\nIt understands three tools out of the box, plus a Cursor slot that's wired up but not finished (more on that below).\n\n| Tool | Where its logs live |\n| --- | --- |\n| **Claude Code** | `~\u002F.claude\u002Fprojects\u002F**\u002F*.jsonl` |\n| **Codex** | `~\u002F.codex\u002Fsessions\u002F**\u002Frollout-*.jsonl` |\n| **Gemini CLI** | `~\u002F.gemini\u002Ftmp\u002F**\u002Fsession-*.json` |\n| **Cursor** | *(stub - see below)* |\n\nIf a tool isn't installed, it's just skipped. You'll only ever see the tools you actually use.\n\n## Using it\n\nThe bare command gives you the last 7 days across everything:\n\n```\npython cli.py\n```\n\nSome other things it does:\n\n```\npython cli.py -today                     # just today\npython cli.py -month                     # this calendar month\npython cli.py -p all                    # everything you've ever run\npython cli.py --provider claude         # one tool only\npython cli.py --project myapp           # one project\npython cli.pyb --from 2026-06-01 --to 2026-06-15   # a specific window\npython cli.py --json | jq .             # machine-readable, pipe it wherever\npython cli.py -web                       # the same thing, in a browser, with charts\n```\n\nColour 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.\n\n### The web dashboard\n\n```\npython cli.py -web\n```\n\nOpens `http:\u002F\u002Flocalhost: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` if you don't want it grabbing your browser.\n\nIt's built on Python's standard-library HTTP server - no Flask, no framework, nothing extra to install.\n\n## How the numbers are worked out\n\n**Tokens** come straight from the logs - every one of these tools records its own token counts per call, so nothing here is guessed. The one wrinkle is caching: Claude splits cache reads and writes out separately, and Gemini reports input *including* the cached part, so tokentab pulls the cached tokens back out before pricing to avoid charging you twice for the same thing.\n\n**Prices** are a hand-kept table in [`tokentab\u002Fpricing\u002Fprices.py`](tokentab\u002Fpricing\u002Fprices.py), in dollars per million tokens. It's a table on purpose - the tool never reaches out to the network to price anything, and a slightly-stale number beats a crash when a vendor renames a model overnight. The matching is fuzzy: `claude-opus-4-6-20260514` still finds `claude-opus-4-6`. If a model shows up as `$0.00`, it means the name didn't match anything in the table - add a line and it's sorted. The CLI says so when it happens instead of quietly counting it as free.\n\n**Activity** (coding \u002F debugging \u002F refactor \u002F testing \u002F etc.) is a guess based on which tools got used and the wording of your first message in a session. It's deterministic - no model calls - so it's fast and you can eyeball whether it's roughly right. Treat it as a hint, not gospel.\n\n\n## Adding another tool\n\nEvery provider is a single module in `tokentab\u002Fproviders\u002F` that exposes a `collect()` function returning a flat list of `UsageRecord`s (the shape's in [`tokentab\u002Ftypes.py`](tokentab\u002Ftypes.py)). Write the module, add it to the list in `tokentab\u002Fproviders\u002F__init__.py`, done - pricing, grouping, the dashboard, all of it just works because everything downstream only ever touches that one shared shape. The three real parsers are worth a read as templates; Claude's is the simplest place to start.\n\n## From source\n\n```\ngit clone https:\u002F\u002Fgithub.com\u002Fcrwdla\u002Ftokentab\ncd tokentab\npip install -e .\ntokentab\n```\n\n\nThe only third-party dependency is [rich](https:\u002F\u002Fgithub.com\u002FTextualize\u002Frich), for the terminal tables. Everything else - the web server, the parsers, the JSON - is Python's standard library.\n\n## Reading the output\n\nA few patterns worth knowing when you look at your own numbers:\n\n- **Cache hit under ~80%, consistently** - your context probably isn't stable between calls, or caching isn't switched on. One weird session is nothing; weeks of it is worth a look.\n- **A big model dominating cost on lots of tiny calls** - you might be reaching for the expensive one on work a cheaper model would one-shot.\n- **\"chat\" or \"exploring\" eating a big share** - a lot of the spend went to talking and reading rather than editing. Sometimes that's the job; sometimes it's a sign a session wandered.\n\nThese are starting points, not verdicts. The tool shows you the data: you know what the work actually was.\n\n## Notes\n\nPrices are best-effort - if you spot a stale one, a one-line PR or an issue is welcome. Everything runs locally.\n\n## License\n\nMIT - do what you like with it.\n","tokentab 是一个本地运行的命令行工具，用于解析 Claude Code、Codex 和 Gemini CLI 等 AI 编程工具生成的本地会话日志，精确统计各模型、项目及日期维度下的 token 消耗量与预估费用。它直接读取原始日志中的真实 token 计数（不估算），支持按时间范围、工具提供商、项目名等多维过滤，并提供纯本地 Web 仪表盘（无外部依赖、不联网、不上传数据）。适用于开发者、AI 工程师及技术团队对本地 AI 编程活动进行成本归因、用量审计和资源优化。",2,"2026-09-11 02:30:08","CREATED_QUERY"]