Docs

Everything Agent Ledger does, and how it gets its numbers.

Getting started

You need Node.js 20 or newer. Then run:

npx agent-ledger

Agent Ledger reads your logs (usually a second or two the first time, much less after that), starts a local server on http://127.0.0.1:4545 (or the next free port) and opens your browser. Press Ctrl+C in the terminal to stop it.

To install it permanently: npm install -g agent-ledger, then run agent-ledger.

Using the dashboard

While the tab is open the dashboard re-reads changed logs every minute. The refresh button does it immediately.

Terminal report

agent-ledger report                       # last 30 days by project
agent-ledger report --since month --by model
agent-ledger report --since 2026-09-01 --until 2026-09-15 --tool codex
agent-ledger report --since all --by day --json
OptionValues
--since7d, 30d (default), 90d, month, last-month, all, any Nd, or a date YYYY-MM-DD
--untilEnd date YYYY-MM-DD (default today)
--byproject (default), model, tool, day
--toolclaude-code, codex or gemini
--jsonMachine-readable output
--port, --no-openDashboard only: choose the port, don't open a browser
--claude-dir, --codex-dir, --gemini-dirRead logs from another folder (repeatable). Also settable as logDirs in the config file

agent-ledger update-prices downloads the latest public price list.

Where logs are read from

ToolDefault foldersOverride
Claude Code~/.claude/projects, ~/.config/claude/projectsCLAUDE_CONFIG_DIR or --claude-dir
Codex~/.codex/sessions, ~/.codex/archived_sessionsCODEX_HOME or --codex-dir
Gemini CLI~/.gemini/tmp/*/chatsGEMINI_CLI_HOME or --gemini-dir

How costs are calculated

Every model request in the logs records its token counts. Agent Ledger prices each request separately:

Prices come from the LiteLLM public price list. A snapshot ships with Agent Ledger; Update prices fetches the current one. You can override any model's price in Settings.

The number shown is API-equivalent cost. On a subscription you pay the plan fee, not this amount. Not included: web search fees, batch discounts and negotiated rates.

How projects are grouped

Each session belongs to the folder it started in. If that folder is inside a git repository, the repository root is the project, so sessions started in my-app/packages/web count toward my-app. Agent Ledger never treats your home folder as a repository.

Active time and time saved

Active time counts the time between messages in a session. Any gap longer than 5 minutes is left out.

Time saved = lines added by the AI's file edits ÷ your pace in lines per hour (50 by default). Claude Code logs every edit it makes. Codex logs edits made through its patch tool, but not edits made through shell commands. This is an estimate, and depends entirely on the pace you set.

Data Agent Ledger stores

Agent Ledger only reads the tools' logs; it never changes them. It writes its own files here:

OSSettings and saved historyDownloaded prices
macOS~/Library/Application Support/agent-ledger~/Library/Caches/agent-ledger
Linux$XDG_CONFIG_HOME/agent-ledger (or ~/.config/agent-ledger)$XDG_CACHE_HOME/agent-ledger (or ~/.cache/agent-ledger)
Windows%APPDATA%\agent-ledger%LOCALAPPDATA%\agent-ledger\Cache

With a backup there are two more files here: cloud.json (sync state, and on systems without a keychain the sign-in token; never the passphrase or key) and cloud-history.json (daily totals restored from your other computers).

history.json contains token counts, timestamps, working folders and session titles parsed from your logs. It is how history survives when Claude Code deletes transcripts older than 30 days. To remove everything, delete both folders. Set AGENT_LEDGER_HOME to keep all of it in one folder of your choice.

Encrypted backup and sync (optional)

Without an account everything stays on this computer, exactly as before. Signing in backs up your settings so a new or replacement computer gets them back, and keeps two computers in step.

agent-ledger cloud login        # emailed code, then a passphrase (first computer) or your passphrase (others)
agent-ledger cloud status
agent-ledger cloud sync
agent-ledger cloud history off  # stop backing up daily totals
agent-ledger cloud logout       # this computer only; local data stays
agent-ledger cloud delete       # deletes the backup on the server

The same steps are in the dashboard under Settings → Backup and sync, which also lists your devices (and can revoke one).

Troubleshooting