Skip to content
freeknetPublic

About

Terminal monitor for which Claude Code sessions are burning tokens

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Claudemon

Terminal monitor for which Claude Code sessions are burning tokens

CI License: MIT MSRV

Claudemon tails Claude Code's session transcripts and shows, live, which sessions are using the most tokens, what that is costing, how full each context window is, and what each session is doing. It is for anyone running several Claude Code sessions at once who wants to know which one to throttle back before a rate limit or a bill says so.

By default it reads only local files (~/.claude/projects/**.jsonl, each session's subagent transcripts, and the ~/.claude/sessions/*.json sidecars); nothing leaves your machine. It can also read WSL distributions and other machines over SSH.

Quick start

cargo install --path .           # puts `claudemon` on your PATH
claudemon                        # the dashboard
claudemon --once                 # one plain-text snapshot
claudemon --json                 # one JSON snapshot, for scripts and status bars

The first run indexes every transcript (seconds to a minute, depending on history) and caches the result; later runs read only what was appended.

What it shows

Five views, switched with Tab or 1–5:

View Rows Detail pane
Sessions every live or recently active session: load/min with a budget gauge, $/hour, 5-hour and today's load, context fill, model, 20-minute trend rates, periods, lifetime tokens and cost, context and budget gauges, last prompt, most-used tools, working directory, resume command
Projects sessions grouped by working directory the project's sessions, busiest first
Models usage per model across all sessions, with each model's share of this month's spend list prices, context window, usage per period
History one row per day with a bar chart the selected day, calendar totals, a 30-day chart
Sources this machine, each WSL distribution and SSH host, with its state where it reads from, its last error, its figures

Above the table, KPI tiles show live sessions, total load, spend per hour, today, this month, and how many sessions are over budget.

Keys

Key Does
Tab / Shift+Tab, 1–5 switch view
↑↓ / jk, PgUpPgDn, g/G move
/ filter by name, project, model, id or state
s / S cycle sort key / reverse it
c copy claude --resume <id> for the selected session
o open the session's working directory
a include sessions that ended long ago
+ / - raise / lower the budget
b ring the bell when a session crosses the budget
[ / ] resize the detail pane
p / r pause / refresh now
? help
q, Esc quit (Esc first closes help or clears the filter)

The mouse works too: click a tab or a row, scroll with the wheel.

More machines: WSL and SSH

Sessions running elsewhere can be shown alongside this machine's, each tagged with where it runs (a SOURCE column appears once there is more than one source), and summed into every total.

WSL. claudemon --wsl, or [[source]] wsl = "auto" in the config, reads the Claude Code directory of every running WSL distribution through \\wsl.localhost, with nothing installed inside WSL. Stopped distributions are left alone rather than booted. wsl = "Debian" reads just that one.

SSH. claudemon --ssh devbox, or a [[source]] ssh = "devbox" table, runs claudemon --stream on that host over your normal ssh (so ~/.ssh/config aliases, keys and the agent apply) and merges what it reports. The host does its own reading and caching; only a small JSON frame per refresh crosses the network.

  • Install claudemon on the host: Linux builds for x86_64 and aarch64 are on the releases page, or cargo install --git https://github.com/freeknet/claudemon.
  • Key or agent authentication must already work: claudemon runs ssh with BatchMode=yes and never answers a password prompt.
  • If claudemon is not on the host's PATH, set command in the source.
  • A dropped connection retries on its own (2 s, doubling to a minute). The Sources view shows each host's state and its last error in plain words.
  • CLAUDEMON_SSH names a different ssh client to run.

Remote Control sessions are covered by adding the machine that runs them. Claude Code cloud sessions (claude.ai/code) are not: their transcripts never reach a machine you control, and no documented interface reports their usage per session.

[[source]]
wsl = "auto"

[[source]]
ssh = "devbox"                       # any ssh destination
command = "~/.cargo/bin/claudemon"   # optional

What the numbers mean

Load is cost-weighted tokens: input 1x, cache-write 1.25x, cache-read 0.1x, output 5x. A cache-heavy agent session and an output-heavy one land on the same scale, and the budget (default 200k/min) is compared against load per minute over the rolling window (default 5 minutes). Load does not change when prices do, so a budget keeps its meaning.

Dollars are estimates at API list prices for each request's model, with 1-hour cache writes at 2x input and fast mode at 2x. On a subscription plan they show what the same work would cost on the API. Unknown models count as $0.

Daily, weekly and monthly figures use local calendar days (weeks start on Monday).

Configuration

Every setting has a flag, and can also live in a config file (%APPDATA%\claudemon\config.toml on Windows, ~/.config/claudemon/config.toml elsewhere). Flags win over the file. Write a commented starting point with:

claudemon --init-config
Flag Config key Default
--window <DURATION> window 5m
--budget <LOAD> budget 200000
--interval <SECS> interval 1
--claude-dir <DIR> claude_dir $CLAUDE_CONFIG_DIR or ~/.claude
--all all off
--bell bell off
detail_rows 12
--days <N> 30
--wsl [[source]] wsl = "auto" off
--ssh <HOST> (repeatable) [[source]] ssh = "HOST" none
--no-cache reindex every run
--config <FILE> the path above

Development

cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --all-features
cargo deny check                                         # licences, advisories, sources

All of these are clean on main and enforced by CI (.github/workflows/ci.yml). A warning is a build failure there. See CONTRIBUTING.md for the rest.

Documentation

Licence

MIT. See LICENSE.


Scaffolded with create-rust-app.

About

Terminal monitor for which Claude Code sessions are burning tokens

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages