claudetop

作者 liorwn已验证

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

210
Stars
9
Forks
Shell
语言
2026/8/23
添加时间

⚠️ 第三方软件声明

本 Skill 为第三方开源软件,独立托管于 GitHub。SkillTip 仅为信息目录,不控制或维护底层仓库。所显示的安全检查为自动化且范围有限,安装前请自行审查源码。

阅读服务条款

安装

添加到你的 Claude Code skills 目录:

# Add to your Claude Code skills
git clone https://github.com/liorwn/claudetop

快速入门

使用 claudetop 等 Skills 的指南。

安全报告

已验证

上次扫描:—

{
  "status": "PASSED",
  "issues": []
}

README.md

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 ✓

The problem

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.

Install

Clone and install (recommended)

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

One-liner

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

As a Claude Code plugin

claude plugin marketplace add liorwn/claudetop
claude plugin install claudetop

This gives you the SessionEnd hook + all slash commands (/claudetop:stats, /claudetop:dashboard, /claudetop:branch, /claudetop:export, /claudetop:pricing) automatically.

Then restart Claude Code.

What you see

Before claudetop

>

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

After claudetop

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

Features

Real-time cost tracking

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

Model cost comparison

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.

Cache efficiency

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.

Smart alerts

Only appear when something needs your attention:

AlertWhat happenedWhat to do
$5 MARK / $10 / $25Cost milestone crossedGut-check: am I getting value?
OVER BUDGETDaily budget exceededWrap up or switch models
CONSIDER FRESH SESSION>2hrs + >60% contextStart fresh — diminishing returns
LOW CACHE<20% cache after 5minContext was reset, tokens being re-read
BURN RATE>$15/hr velocityRunaway subagents or tight loops
SPINNING?>$1 spent, zero code outputStuck in a research loop
TRY /fast>$0.05/line on OpusThis task doesn't need the biggest model
COMPACT SOONContext window >80% fullAuto-compaction is imminent

Session history & analytics

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)

Deep analytics engine

The analytics engine scans all Claude Code JSONL session files — not just hook-recorded ones. It captures your complete history including sessions from before claudetop was installed, subagent costs, and per-turn token breakdowns.

claudetop-engine scan       # Scan all JSONL files → SQLite
claudetop-engine today      # Today (with per-turn tool breakdown)
claudetop-engine stats      # All-time (subagents, top tools, projects)
claudetop-engine dashboard  # Live web dashboard at localhost:8080

The live dashboard features an activity heatmap, cost-by-model charts, project and tool breakdowns, subagent cost attribution, and a sortable session table — all with model filtering and time range selection. Auto-refreshes every 30 seconds.

Zero dependencies — uses only Python 3 standard library (sqlite3, http.server, json).

Session tagging

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

Daily budget

export CLAUDETOP_DAILY_BUDGET=50

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

Themes

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

iTerm2 integration

Push claudetop data into iTerm2's chrome — tab titles, status bar, and badge watermark:

export CLAUDETOP_ITERM=all           # Enable everything
export CLAUDETOP_ITERM=title         # Tab/window title only
export CLAUDETOP_ITERM=badge         # Watermark overlay only
export CLAUDETOP_ITERM=statusbar     # User variables for status bar
export CLAUDETOP_ITERM=bgcolor       # Background color tint by state
export CLAUDETOP_ITERM=title,badge   # Combine any options

Tab title — Shows project | $4.21 | Opus 4.6 | ctx:38% in your iTerm2 tab. Zero configuration.

Badge — Faint watermark in the terminal background with cost, model, and context at a glance. Great for keeping cost visible while scrolling through output.

Background color — Subtly tints the terminal background based on session state:

TintMeaning
GreenHealthy session (low context, under $5) or session ended (idle/waiting)
AmberCaution — cost milestone, compact soon, low cache, spinning
RedAlert — over budget, burn rate spike, $25 mark
DefaultNormal — no special state, uses your profile's background

When a session ends, the background stays green so you can see at a glance which terminals are idle vs active. Resets to default when the next session starts clean.

Status bar — Sets iTerm2 user-defined variables that you can display in the status bar (top or bottom of terminal). Configure in iTerm2: Preferences > Profiles > Session > Status Bar > add "Interpolated String" components:

VariableContentExample
\(user.claudetop_cost)Session cost$4.21
\(user.claudetop_model)Current modelOpus 4.6
\(user.claudetop_ctx)Context usage38%
\(user.claudetop_project)Project namemy-project
\(user.claudetop_duration)Session time20m 0s
\(user.claudetop_cache)Cache hit ratio66%
\(user.claudetop_velocity)Burn rate$5.10/hr
\(user.claudetop_tokens_in)Input tokens152.3K
\(user.claudetop_tokens_out)Output tokens45.2K
\(user.claudetop_lines)Lines changed+256/-43
\(user.claudetop_tag)Session tag#auth-refactor

No-op on non-iTerm2 terminals — escape sequences are silently ignored.

Context composition

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.

Plugins

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

Included (enabled by default):

PluginWhat it shows
git-branch.shmain* (branch + dirty indicator)

Example plugins (copy to enable):

cp ~/.claude/claudetop.d/_examples/spotify.sh ~/.claude/claudetop.d/
PluginWhat it shows
spotify.sh♫ Artist - Song (macOS)
gh-ci-status.shCI ✓ or CI ✗ (GitHub Actions)
meeting-countdown.shMtg in 12m: Standup (macOS Calendar)
ticket-from-branch.shPROJ-123 (from branch name)
weather.shCurrent weather (wttr.in)
news-ticker.shTop HN story
pomodoro.shFocus timer
system-load.shCPU 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.

Dynamic pricing

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):

ModelInputCache WriteCache ReadOutputNotes
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/MTok2x 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

Color coding

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

MetricGreenYellowRed
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 day6am-10pmMagenta after 10pm

Requirements

  • Claude Code with status line support
  • jqbrew install jq / apt install jq
  • bc — pre-installed on macOS and most Linux

Contributing

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/.

License

MIT

常见问题

What is claudetop?

claudetop is an open-source cli tools skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by liorwn. htop for your Claude Code sessions — real-time cost, cache efficiency, model comparison, and smart alerts. It has 210 GitHub stars.

Is claudetop safe to use?

Yes. claudetop passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.

How do I install claudetop?

Clone the repository with "git clone https://github.com/liorwn/claudetop" and add it to your Claude Code skills directory (see the Installation section above).

What programming language is claudetop written in?

claudetop is primarily written in Shell. It is open-source under liorwn on GitHub, so you can review or fork the full source.

Are there alternatives to claudetop?

Yes. SkillsLLM lists many other CLI Tools skills you can browse and compare side by side. Open the CLI Tools category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh claudetop against similar tools.

评论 (0)

暂无评论,成为第一个分享想法的人!

ui-ux-pro-max-skill

by nextlevelbuilder

12

An AI skill that provides design intelligence for building professional UI/UX across multiple platforms.

119,92012,870Python
CLI 工具ai-skillsantigravity
查看详情

happy

by slopus

Mobile and Web client for Codex and Claude Code, with realtime voice, encryption and fully featured

23,4501,980TypeScript
CLI 工具
查看详情

claudecodeui

by siteboon

Use Claude Code, OpenCode, Cursor CLI, and Codex on mobile and web with CloudCLI (aka Claude Code UI). CloudCLI is a free open source webui/GUI that helps you manage your Claude Code session and projects remotely.

13,3941,866TypeScript
CLI 工具
查看详情

CRS-自建Claude Code镜像,一站式开源中转服务,让 Claude、OpenAI、Gemini、Droid 订阅统一接入,支持拼车共享,更高效分摊成本,原生工具无缝使用。

12,5471,869JavaScript
CLI 工具
查看详情

ccstatusline

by sirmalloc

🚀 Beautiful highly customizable statusline for Claude Code CLI with powerline support, themes, and more.

12,508545TypeScript
CLI 工具
查看详情

开发者还喜欢

基于喜欢此 Skill 的开发者投票和收藏

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情