Local logs can show token use for Claude Code and Codex CLI, but a dollar estimate built from those logs is not automatically your subscription bill. To track spending usefully, identify the billing basis, check which token fields your parser captures, and make any budget check reject usage it cannot price.
What you need before tracking costs
You need access to the tools’ local usage logs, a rate table for the models and token categories you want to estimate, and the provider’s account usage or billing view for reconciliation. JSONL is a text format that stores one JSON record per line. A tutorial from Shattered.io describes a Python ledger that reads Claude Code and Codex CLI JSONL logs and applies a user-maintained rate table.
The tutorial describes Claude Code logs beneath ~/.claude/projects and Codex session rollouts beneath ~/.codex/sessions. OpenAI’s Codex source also uses JSONL session rollouts. The tutorial’s sample reports are synthetic, not real usage or bills.
1. Decide what the cost figure represents
First identify how you use each tool: through a subscription or through API billing. An API-equivalent estimate applies API rates to logged token counts. It can help compare usage, but it does not by itself show what a subscription charged or how much of a plan’s allowance you used. Provider account usage or billing is the relevant reference for those account-level figures.
| Measurement | Local usage report | Provider account view |
| Token use | Counts recorded in local logs | Usage reported for the account or plan |
| Dollar amount | Estimate calculated from a rate table | Provider-side billing or usage figure |
| Best use | Compare recorded activity by tool, model, project, or time period | Reconcile account usage or charges |
A local estimate is only as complete as its log parser and rate table. Missing a model price or a required token-category rate can leave part of the usage out of the calculated total.
2. Check the scope of Codex token records
OpenAI’s inspected Codex fixture contains both total_token_usage, a cumulative total, and last_token_usage, the usage for an individual request. The published ledger tutorial derives request usage by subtracting successive cumulative snapshots. The two fields therefore offer different ways to inspect usage in the records.
| Field | Recorded scope | What it helps you inspect |
total_token_usage | Cumulative usage | The running session total |
last_token_usage | Per-request usage | The usage recorded for an individual request |
The fixture also contains cached_input_tokens, cache_write_input_tokens, and reasoning_output_tokens. The tutorial’s Codex parser does not retain cache_write_input_tokens. That is a useful field to check when auditing parser coverage; its presence alone does not establish how it should be priced.
3. Make the budget check reject unpriced usage
Static inspection of the tutorial’s published code found that its aggregator counts unpriced tokens, but its guard checks only the calculated dollar total. If a model or required rate is missing, the guard can pass without including that usage in its total. A spending check meant to enforce a ceiling should reject a run whenever any usage remains unpriced.
The tutorial’s Codex check is also a shell wrapper: running codex directly instead of through that wrapper bypasses the check. Anthropic documents UserPromptSubmit as running before Claude processes a prompt and says exit code 2 blocks a supported event. That is a prompt-boundary check, not a way to stop work that is already running.
4. Reconcile estimates and track accepted work
Compare local totals with the usage or billing information in each provider account. Keep the figures separate when one is an API-rate estimate and the other reflects a subscription or account-level usage. A single combined local ledger can help organize activity across tools, but it does not replace those provider views.
Token spend also does not capture the time spent reviewing or revising an output. One Reddit contributor described tracking API-equivalent cost per accepted draft separately from editing time, reporting $2.40 in token costs and three hours of editing for one overview. That is one person’s account, not a general benchmark. Still, recording accepted results and editing time alongside token estimates can help distinguish a low-cost run from work that required substantial rework.
5. Choose a dashboard for visibility, not billing authority
A review by AI Coding Daily demonstrated CodeBurn displaying daily cost estimates, project and model breakdowns, tool and MCP activity, and provider filtering. The reviewer said its cost estimates use API pricing, so subscription users should treat them as API-equivalent figures rather than subscription charges.
For Claude Code sessions initiated through iOS Remote Control, the author of the community-built tool optimAIzr says its local-log method can read the logs when the session runs on the user’s computer. The author says cloud sessions do not leave those logs on that machine. The same author says Claude desktop Code-tab sessions write logs under ~/.claude/projects, while ordinary Claude chats are outside that local-log method.