Skills Artificial Intelligence AI Agent Cost Ledger

AI Agent Cost Ledger

v20261022
cost-ledger
This tool provides a unified cost view for AI agents like Claude Code, Codex, and Grok. It reads local logs to calculate spend, token usage, and cache hit ratios per provider and model. It flags unpriced models and supports filtering by time range, project, and provider. Output can be JSON or Markdown. All data stays local, ensuring privacy. Ideal for auditing AI usage costs and comparing provider pricing.
Get Skill
101 downloads
Overview

Cost Ledger

Reads the logs the agents already wrote (~/.claude/projects, $CODEX_HOME or ~/.codex) and prices them from data/prices.json (dated, editable).

Run

node ${CLAUDE_PLUGIN_ROOT}/scripts/ledger.mjs --since 7d
node ${CLAUDE_PLUGIN_ROOT}/scripts/ledger.mjs --provider codex --format json

One mission, or one project

--from and --to (ISO times) cut the window and --project <absolute path> keeps one project's rows; the console's mission page uses them for a mission's spend. An explicit --from/--to replaces the default 7-day look-back.

Read the result correctly

  • USD and Codex credits are never added. GPT-6 Codex models are priced in credits; their cached-input rate is unpublished, so the figure is an upper bound.
  • Estimates at list price, not bills. Subscriptions bill by window, not by token. /usage is authoritative for the live Claude session; the Console or provider dashboard is authoritative for invoices.
  • Unpriced models are listed, never counted as $0. Say so, and offer to add them to data/prices.json.
  • Counting rules (why numbers differ from naive sums): Claude messages are de-duplicated by message.id + requestId; Codex uses deltas of the running total_token_usage (never also last_token_usage), cached input is a subset of input, and forked rollouts are de-duplicated.
  • Claude transcript output tokens can under-count streamed output.

If the log directory is missing, say so; do not invent numbers.

Info
Name cost-ledger
Version v20261022
Size 1.94KB
Updated At 2026-10-23
Language