Claudetop – htop for Claude Code sessions (see your AI spend in real-time)

2026-03-1419:265128github.com

htop for your Claude Code sessions — real-time cost, cache efficiency, model comparison, and smart alerts - liorwn/claudetop

You're spending $20/day on Claude Code and can't see it.

claudetop shows you exactly where your tokens and dollars go — in real time.

Install MIT License Plugins

claudetop in action — healthy session (top) vs problem session (bottom)

14:32  my-project/src/app  Opus  20m 0s  +256/-43  #auth-refactor
152.3K in / 45.2K out  ████░░░░░░ 38%  $3.47  $5.10/hr  ~$174/mo
cache: 66%  efficiency: $0.012/line  opus:~$3.20  sonnet:~$0.88  haiku:~$0.23
in:80% out:20% (fresh:15% cwrite:7% cread:76%)
$5 MARK  |  main*  |  ♫ Artist - Song  |  PROJ-123  |  CI ✓

Claude Code doesn't show you what you're spending. You finish a session, check your billing dashboard, and discover a $65 charge for what felt like 30 minutes of work. You have no idea which session caused it, which model was wasteful, or whether your cache was even working.

I built claudetop after noticing my model estimate showed $10 but the actual bill was $65. Turns out, compaction was hiding 80% of my token usage. The cost was real — the visibility wasn't.

curl -fsSL https://raw.githubusercontent.com/liorwn/claudetop/main/install.sh | bash

Or clone and run manually:

git clone https://github.com/liorwn/claudetop.git
cd claudetop && ./install.sh

Then restart Claude Code. That's it.

A blank prompt. No context. No cost. No idea.

14:32  my-project/src/app  Opus  20m 0s  +256/-43  #auth-refactor
152.3K in / 45.2K out  ████░░░░░░ 38%  $3.47  $5.10/hr  ~$174/mo
cache: 66%  efficiency: $0.012/line  opus:~$3.20  sonnet:~$0.88  haiku:~$0.23
$5 MARK  |  TRY /fast  |  main*  |  CI ✓  |  ♫ Bonobo - Kerala

Every response, you see:

  • What project you're in and how deep
  • What model is running and for how long
  • What it costs right now, per hour, and projected monthly
  • How efficient your cache is (are you wasting tokens?)
  • What it would cost on a different model (should you switch?)
  • Smart alerts when something is wrong

Your actual session cost (green), burn rate per hour, and monthly forecast extrapolated from your history. No more billing surprises.

See what your session would cost on Opus, Sonnet, or Haiku — with cache-aware pricing that accounts for your actual cache hit ratio. The current model is bolded so you can instantly compare.

Pricing updates automatically from the pricing.json in this repo — when Anthropic changes prices, claudetop stays current.

Your cache hit ratio tells you if you're being efficient. Green (≥60%) means most of your input tokens are being reused. Red (<30%) means something is forcing full re-reads — maybe compaction, maybe a model switch.

Only appear when something needs your attention:

Alert What happened What to do
$5 MARK / $10 / $25 Cost milestone crossed Gut-check: am I getting value?
OVER BUDGET Daily budget exceeded Wrap up or switch models
CONSIDER FRESH SESSION >2hrs + >60% context Start fresh — diminishing returns
LOW CACHE <20% cache after 5min Context was reset, tokens being re-read
BURN RATE >$15/hr velocity Runaway subagents or tight loops
SPINNING? >$1 spent, zero code output Stuck in a research loop
TRY /fast >$0.05/line on Opus This task doesn't need the biggest model
COMPACT SOON Context window >80% full Auto-compaction is imminent

Every session is automatically logged. See where your money goes:

claudetop-stats # Today's summary
claudetop-stats week # This week
claudetop-stats month # This month
claudetop-stats all # All time
claudetop-stats tag auth # Filter by tag
claudetop-stats  This Week
──────────────────────────────────────────────────────

Summary
  Sessions:     12
  Total cost:   $47.30
  Avg / session:  $3.94
  Daily avg:      $9.46

Cost by model
  claude-opus-4-6:       $38.20
  claude-sonnet-4-6:     $9.10

Top projects by cost
  rri-os                 $22.50  (4 sessions)
  pistol-claw            $14.80  (5 sessions)
  the-table              $10.00  (3 sessions)

Track costs per feature, bug, or initiative:

export CLAUDETOP_TAG=auth-refactor
# ... work on auth ...
claudetop-stats tag auth-refactor
# Total cost: $12.40 across 3 sessions
export CLAUDETOP_DAILY_BUDGET=50

Shows budget: $12 left at 80% → OVER BUDGET ($52/$50) when exceeded.

export CLAUDETOP_THEME=full # Default: 3-5 lines
export CLAUDETOP_THEME=minimal # 2 lines
export CLAUDETOP_THEME=compact # 1 line

See what's eating your context window:

in:80% out:20% (fresh:15% cwrite:7% cread:76%)

High cread = cache is working well. High fresh = re-reading files every turn.

Drop any executable script into ~/.claude/claudetop.d/ — it becomes part of your status line.

Included (enabled by default):

Plugin What it shows
git-branch.sh main* (branch + dirty indicator)

Example plugins (copy to enable):

cp ~/.claude/claudetop.d/_examples/spotify.sh ~/.claude/claudetop.d/
Plugin What it shows
spotify.sh ♫ Artist - Song (macOS)
gh-ci-status.sh CI ✓ or CI ✗ (GitHub Actions)
meeting-countdown.sh Mtg in 12m: Standup (macOS Calendar)
ticket-from-branch.sh PROJ-123 (from branch name)
weather.sh Current weather (wttr.in)
news-ticker.sh Top HN story
pomodoro.sh Focus timer
system-load.sh CPU load average

Write your own in 4 lines:

#!/bin/bash
JSON=$(cat)
COST=$(echo "$JSON" | jq -r '.cost.total_cost_usd')
printf "\033[32m\$%s\033[0m" "$COST"

Make it executable, drop it in ~/.claude/claudetop.d/, done.

Pricing updates daily from this repo. When Anthropic changes prices, we update pricing.json and everyone gets the new rates next morning.

Current pricing (Claude 4.6, March 2026):

Model Input Cache Write Cache Read Output Notes
Opus 4.6 $5/MTok $6.25/MTok $0.50/MTok $25/MTok
Sonnet 4.6 $3/MTok $3.75/MTok $0.30/MTok $15/MTok 2x input / 1.5x output when >200K tokens
Haiku 4.5 $1/MTok $1.25/MTok $0.10/MTok $5/MTok

Extended thinking tokens are billed at standard output rates. No additional charge.

To update manually: ~/.claude/update-claudetop-pricing.sh

Every metric uses traffic-light colors — green means healthy, red means act:

Metric Green Yellow Red
Cost velocity <$3/hr <$8/hr ≥$8/hr
Cache ratio ≥60% ≥30% <30%
Efficiency <$0.01/line <$0.05/line ≥$0.05/line
Context bar <50% 50-80% ≥80%
Time of day 6am-10pm Magenta after 10pm
  • Claude Code with status line support
  • jqbrew install jq / apt install jq
  • bc — pre-installed on macOS and most Linux

Pricing changed? Model added? Open a PR updating pricing.json. Everyone gets the update next morning.

Built a useful plugin? PRs welcome in plugins/examples/.

MIT


Read the original article

Comments

  • By sgarland 2026-03-1419:58

        curl -fsSL https://raw.githubusercontent.com/liorwn/claudetop/main/install.sh | bash
        Installing claudetop...
        cp: /Users/sgarland/claudetop.sh: No such file or directory
    
    You need to have it handle being piped; right now it expects to find itself at $PWD. It also makes several other assumptions, like the location of Claude, and that the user wants stats being `/usr/local/bin`.

  • By alexsmirnov 2026-03-160:01

    The calculation misses subagents tokens, that can be a significant differences. Better to parse session jsonl files ~/.claude/projects/<project>/<session id>.jsonl and ~/.claude/projects/<project>/<session id>/subagents/<agent id>.jsonl

  • By liorwn 2026-03-1419:265 reply

    I built this after noticing a $65 charge for what felt like a $10 session. Turns out, context compaction was hiding 80% of my token usage. Real cost, no visibility.

    claudetop is a status line for Claude Code that shows your burn rate, cache efficiency, model cost comparison, and smart alerts (like "TRY /fast" when Opus is overkill for the task). Plugin system for extensibility — Spotify, CI status, calendar, etc.

    Single bash script, zero dependencies beyond jq. One-command install.

    • By cortesoft 2026-03-1419:534 reply

      I am always a hit confused when people talk about these charges... are you not using the subscriptions with the flat rates? I am on the $100 a month plan, and am constantly using clause code and never coming close to my limits. Maybe I am just not using it at the levels of some people...

      • By Gobd 2026-03-1419:592 reply

        I have noticed the same with the $100/mo plan, I hit the limt only once with heavy usage. Then when I use my employer's AWS Bedrock it's not uncommon for my spend to $50/day of serious work. It doesn't make much sense.

        • By sroussey 2026-03-1420:07

          Anthropic is subsidizing Claude Code. It makes lots of sense.

        • By verdverm 2026-03-1420:071 reply

          The paid plans require you to use their interfaces or tooling. The main reason I pay per token is so I have tooling freedom. I'm not keen to let Big AI decide how I interact with this game changing technology.

          • By cortesoft 2026-03-1420:58

            I haven't yet been blocked by their tooling. All the current tools I use seem to work fine with the claude code interface, can just call it with -p.

      • By copperx 2026-03-1420:003 reply

        $100 is for casual usage. To use it for work requires $200/mi plus extra usage.

        • By Gobd 2026-03-1420:08

          CC does all of my work and I have hit the $100/mo Max plan limit only once, and I probably could have just called it quits for the day at that point.

        • By cortesoft 2026-03-1420:55

          Are you saying that is the Claude rules for the subscription or saying because work uses more of it?

      • By verdverm 2026-03-1420:051 reply

        I pay per token using an API (Vertex)

        1. Higher limits and quota, goes up with more spend

        2. I don't think it gets quant nerf's during busy times, since you are paying directly

        3. With Gemini flash + CC prompts, it's nearly as good, so less spend and latency. I don't know how people deal with the delays between turns. I get to iterate much faster for most tasks

        • By cortesoft 2026-03-1420:571 reply

          I don't seem to have any delays between turns with my Claude subscription, so not sure what you mean there.

          Your second point seems like a guess.

          For your first point, I bumped to the $100 plan because i was hitting limits with the $20 one, but haven't hit the limit with the new one yet...

          • By verdverm 2026-03-1520:03

            I mean the 10-30s to wait for a frontier model to respond when the lite/flash models are just fine for almost all tasks

      • By MattGaiser 2026-03-1420:042 reply

        How many agents are you using at once?

    • By jakeinspace 2026-03-1420:002 reply

      Please type things yourself. Or at least prompt your LLM of choice to sound less canned.

      • By CubsFan1060 2026-03-1420:07

        41 minute old account. "I built post". LLM sounding everything. I'd be surprised if there was a real person behind this at all.

      • By brikym 2026-03-1421:45

        /authentic-writer skill: No em dashes or emojis. add in a few typos and bad grammmer. Avoid it's not not X but Y. imagine you're a mere human and your pinky finger is very tired so you forget to uppercase sometimes.

    • By js2 2026-03-1423:32

      I asked Claude Opus yesterday if it could put my token cost (and tokens remaining) into the status bar and it insisted there was no way to get this information.

      ETA: ah, this isn't getting real time cost from an Anthropic API or anything. It's estimating it based on token usage and a JSON config file that specifies token cost.

    • By Self-Perfection 2026-03-1421:02

      > like "TRY /fast" when Opus is overkill for the task

      In fact using /fast in this case would only increase spending. /fast mode uses the same opus but consumes $$$$ faster to produce tokens faster )

      https://code.claude.com/docs/en/fast-mode

    • By sneak 2026-03-1420:20

      I believe there is a new HN guideline asking people not to post AI slop as comments.

HackerNews