Retok: Token-efficiency analyzer for Claude Code and Codex CLI (zero deps) Retok, a zero-dependency Python CLI tool for analyzing token efficiency in Claude Code and OpenAI Codex CLI usage logs, has been released on GitHub. The tool estimates costs, measures cache hit rates, and provides actionable recommendations to reduce AI coding agent expenses. It requires Python 3.7+ and scans local transcript directories to generate reports. English | 日本語 /d-date/retok/blob/main/README.ja.md A CLI tool that analyzes your AI coding agent usage logs — Claude Code and OpenAI Codex CLI — to measure token efficiency , estimate cost, and print actionable recommendations. Runs on Python 3 with the standard library only — no dependencies. ══════════════════════════════════════════════════════════════════════════ retok — Token Efficiency Report last 30 days / 472 files ══════════════════════════════════════════════════════════════════════════ ■ Overview Estimated cost $2,119.66 Claude Code / Codex $2,091.00 / $28.66 Cache hit rate 89.4% Cost per prompt $1.593 ... ■ Recommendations Re-caching after cache TTL expiry: ~135.0M tokens $873.49 Returning to a session left idle beyond the cache TTL usually 1 hour re-caches the entire context at twice the input rate. ... Requires Python 3.7+. No dependencies. git clone https://github.com/d-date/retok.git cd retok ./retok To run it from anywhere, symlink it into your PATH the symlink is resolved, so translations in locales/ keep working : ln -s "$ pwd /retok" ~/.local/bin/retok or /usr/local/bin/retok retok Alternatively, grab just the script — everything works, but the report falls back to English because locales/ is not present: curl -fsSLo ~/.local/bin/retok https://raw.githubusercontent.com/d-date/retok/main/retok chmod +x ~/.local/bin/retok ./retok report for the last 30 days ./retok --days 7 change the window ./retok --project myapp filter by project name substring ./retok --provider codex only one provider claude | codex ./retok --lang en report language default: $LANG ./retok --json JSON output for other tools ./retok --top 20 rows in ranking tables ./retok --dirs ~/somewhere/projects override Claude Code roots ./retok --codex-dirs ~/somewhere/sessions override Codex roots By default it scans Claude Code transcripts in ~/.claude/projects plus $CLAUDE CONFIG DIR/projects when that environment variable is set and Codex CLI rollouts in ~/.codex/sessions . If you keep transcripts elsewhere multiple profiles, custom config dirs , pass every root with --dirs / --codex-dirs . Usage records are deduplicated globally, so overlapping roots are never double-counted. | Metric | Meaning | |---|---| | Estimated cost | USD estimate based on published per-model pricing table below | | Cache hit rate | cache read / input + cache read + cache write — higher is cheaper | | Cost per prompt | Cost consumed per human instruction | | Subagent share | Consumption by subagents Task/Explore;