TOKENHAWK DOCS / v1

Know what your
agents consume.

Tokenhawk is a local, live token-usage monitor for Claude Code, Codex, Gemini CLI, Pi, and OpenCode. It turns the metadata already stored on your machine into an interactive terminal dashboard, compact status output, and exportable records.

Private by designTokenhawk never stores or exports prompts, responses, tool arguments, credentials, or transcript content.
01

Quick start

Install the latest compiled release on macOS or Linux:

Terminal
$ /bin/sh -c "$(curl -fsSL https://tokenhawk.dev/install.sh)"
$ tokenhawk

The installer detects your operating system and architecture, verifies the release checksum, and installs to ~/.local/bin. If needed, add that directory to your PATH.

Choose a version or install directory

Terminal
$ TOKENHAWK_VERSION=0.1.4 sh -c "$(curl -fsSL https://tokenhawk.dev/install.sh)"
$ TOKENHAWK_INSTALL_DIR="$HOME/bin" sh -c "$(curl -fsSL https://tokenhawk.dev/install.sh)"

Install with Go

If you already have Go 1.25 or newer, you can install Tokenhawk directly from the module root:

Terminal
$ go install github.com/polera/tokenhawk@latest

If the command is not found afterward, add $(go env GOPATH)/bin to your PATH.

Build from source

Building from source requires Go 1.25 or newer.

Terminal
$ git clone https://github.com/polera/tokenhawk.git
$ cd tokenhawk
$ go build -o tokenhawk .
$ ./tokenhawk

Run Tokenhawk in a dedicated terminal tab or window. Missing provider directories are allowed, so there is no setup required for tools you do not use.

02

Privacy model

Tokenhawk operates entirely on your machine. It reads provider session metadata from normal local stores and writes a rebuildable SQLite index beneath your operating system’s user-cache directory.

Tokenhawk reads
  • Session and model identifiers
  • Token category counts
  • Session timestamps and status
  • Project metadata and reported cost
Tokenhawk never reads
  • Prompts or responses
  • Tool arguments
  • Credentials
  • Transcript content

Provider transcript files remain untouched. OpenCode’s SQLite database is opened read-only, including its live WAL data. Source paths are omitted from exports unless you explicitly pass --include-source.

03

Dashboard

The dashboard separates active, inactive, and all sessions. At medium and wide terminal sizes each row shows provider, project/session, agent counts, model, input, cached input, output, normalized input-to-output ratio, reasoning tokens, total tokens, cost, and update time.

Tokenhawk all-sessions dashboard
All sessions view with cross-provider usage and cache warnings.

Keyboard controls

KeyAction
1 2 3Active, inactive, and all sessions
iToggle active and inactive lists
j k / arrowsNavigate sessions
pCycle provider filter
sSort by update time, tokens, or cost
/Filter by project or model metadata
EnterOpen session detail and resume command
e / xExport visible sessions as JSON / CSV
qQuit

Low-cache warning

A session is highlighted when it has at least 100,000 input tokens and less than an 80% cached-input ratio. Detail view identifies low-cache parent and subagent workloads independently.

04

Provider data

By default, Tokenhawk discovers usage data in these locations:

ProviderDefault sourceCost
Claude Code~/.claude/projects/**/*.jsonlAPI-equivalent estimate
Codex$CODEX_HOME/sessions/**/*.jsonl and archivesAPI-equivalent estimate
Gemini CLI~/.gemini/tmp/*/chats/session-*.jsonAPI-equivalent estimate
Pi${PI_CODING_AGENT_SESSION_DIR:-~/.pi/agent/sessions}/**/*.jsonlProvider-reported
OpenCode${XDG_DATA_HOME:-~/.local/share}/opencode/opencode.dbProvider-reported

Use the corresponding directory flags or the configuration file to point Tokenhawk at nonstandard roots. Run with --rebuild after changing source locations.

05

Live status inside agent sessions

The compact renderer always selects one session; it never combines usage from multiple sessions. Claude supplies an exact session ID. Wrappers for other clients select the active, most recently updated session for the current project directory.

TOKENHAWKcodexin 11.80Mcache 96.6%out 76.4k$4.28002/4 agents

Claude Code status line

Add this to ~/.claude/settings.json, merging it with any existing settings:

JSON
{
  "statusLine": {
    "type": "command",
    "command": "tokenhawk statusline claude",
    "refreshInterval": 2,
    "padding": 0
  }
}

The command consumes Claude’s status JSON from standard input and does not add anything to model context.

Codex, Gemini CLI, Pi, and OpenCode

The universal wrapper requires tmux. Outside tmux it creates a temporary dedicated session. Inside tmux it temporarily replaces the right-side status and restores the previous settings when the client exits.

Terminal
$ tokenhawk wrap codex --cd /path/to/project
$ tokenhawk wrap gemini --model gemini-2.5-pro
$ tokenhawk wrap pi --model anthropic/claude-sonnet-4-5
$ tokenhawk wrap opencode /path/to/project

All remaining arguments are forwarded unchanged to the selected client. You can also use tokenhawk wrap claude if you prefer the universal wrapper.

Direct renderer

Terminal
$ tokenhawk status --provider codex --project "$PWD"
$ tokenhawk status --provider claude --session SESSION_ID --format json
$ tokenhawk status --provider gemini --project "$PWD" --format ansi

The renderer incrementally scans provider stores by default. Add --no-scan when another Tokenhawk process already maintains the index. Set NO_COLOR=1 to turn ANSI output into plain text.

06

Headless export

Export all matching sessions without opening the TUI:

Terminal
$ tokenhawk export --format json --output usage.json
$ tokenhawk export --format csv --output usage.csv \
    --provider codex --since 2026-07-01

Filters include --provider, --model, --project, --status, --since, and --until. Dates accept RFC 3339 or YYYY-MM-DD.

  • JSON contains nested per-model and subagent usage.
  • CSV contains tagged session/model and subagent/model rows, including cost and running status.
  • Local source paths stay excluded unless --include-source is set.
07

Configuration

Tokenhawk loads tokenhawk/config.toml beneath your operating system’s user-config directory. Every field is optional and command-line flags take precedence.

TOML
claude_dir = "~/.claude/projects"
codex_dir = "~/.codex"
gemini_dir = "~/.gemini/tmp"
pi_dir = "~/.pi/agent/sessions"
opencode_db = "~/.local/share/opencode/opencode.db"
active_window = "5m"
refresh = "2s"
db_path = "~/.cache/tokenhawk/index.db"
pricing_file = "~/.config/tokenhawk/pricing.json"
include_source = false
After changing source rootsRun tokenhawk --rebuild. Pricing catalog and override changes are fingerprinted and automatically trigger a one-time rebuild.
08

Pricing

Claude, Codex, and Gemini costs are estimates of public API list-price equivalents, not subscription charges, invoices, free-tier consumption, discounts, or taxes. Pi and OpenCode record calculated costs themselves; Tokenhawk labels those values reported and preserves them.

The bundled, effective-dated catalog prices only exact, known model IDs. Unknown models remain unpriced instead of inheriting a guessed family rate.

Override a rate

JSON
{
  "version": "company-rates-1",
  "rates": [{
    "provider": "codex",
    "model": "my-exact-model-id",
    "effective_from": "2026-01-01",
    "input_per_million": 1.0,
    "cached_input_per_million": 0.1,
    "cache_creation_per_million": 1.0,
    "output_per_million": 8.0
  }]
}
09

Commands & flags

CommandPurpose
tokenhawkOpen the interactive terminal dashboard
tokenhawk statusRender one selected session as plain, ANSI, tmux, or JSON
tokenhawk statusline <provider>Render status from a native provider hook
tokenhawk wrap <provider>Run a supported client with a tmux status bar
tokenhawk exportWrite matching sessions as JSON or CSV
tokenhawk versionPrint the installed version

Shared selection and storage flags

--providerFilter to claude, codex, gemini, pi, or opencode.
--modelFilter by model metadata.
--projectFilter or select by project path.
--statusFilter active or inactive sessions.
--sessionSelect an exact session ID for status output.
--configLoad a specific configuration file.
--dbUse a specific index database.
--rebuildReset and rebuild the local index.
--refreshSet the TUI reconciliation interval.
--active-windowSet how recently a session must update to be active.
10

Troubleshooting

Tokenhawk is installed but the command is missing.

Make sure ~/.local/bin (or your custom TOKENHAWK_INSTALL_DIR) is on your shell’s PATH, then open a new terminal.

A provider does not appear.

Confirm the provider has created at least one local session and that its source path matches the defaults above. For a custom location, set the corresponding config field or CLI flag and run tokenhawk --rebuild.

The wrapper cannot start.

tokenhawk wrap requires tmux and the selected provider client to be installed and available on your PATH.

A cost is marked unpriced.

The model identifier does not exactly match a bundled price. Add an exact identifier through a pricing override file instead of relying on a guessed family rate.

How do I disable ANSI color?

Set NO_COLOR=1. ANSI status-line output will render as plain text.

Ready to watch your sessions? Install Tokenhawk