Ccusage:一个用于分析从本地JSONL文件获取的Claude代码使用情况的命令行工具。
Ccusage: A CLI tool for analyzing Claude Code usage from local JSONL files

原始链接: https://github.com/ryoppippi/ccusage

## ccusage:分析您的 Claude 代码使用成本 **ccusage** 是一款快速、轻量级的命令行工具,可直接从本地 JSONL 文件分析您的 Claude 代码 token 使用情况和相关成本。它体积小巧,无需安装,即可通过 `bunx ccusage` 或 `npx ccusage@latest` 运行。 **主要功能包括:** * **详细报告:** 提供每日、每月、会话和 5 小时区块报告。 * **实时监控:** 实时仪表盘显示使用情况和成本预测。 * **模型细分:** 跟踪每个 Claude 模型(Opus、Sonnet 等)的使用情况和成本。 * **筛选与输出:** 日期筛选、JSON 导出以及可自定义的数据目录路径。 * **成本跟踪:** 以美元显示成本,包括缓存 token 的使用情况。 * **离线模式:** 使用缓存定价,无需互联网连接即可工作。 ccusage 提供用户友好、色彩丰富的输出,并针对宽屏和窄终端进行了优化。完整文档和实用技巧可在 [ccusage.com](https://ccusage.com) 找到。

一个新的命令行工具“Ccusage”帮助用户分析他们从本地JSONL文件中的Claude Code使用情况,可能揭示高昂的成本。一位订阅100美元/月Max套餐的用户报告每月花费600-800美元,质疑Anthropic的定价(Sonnet为3美元/15美元/Mtok,Opus为15美元/75美元/Mtok),并认为可能被多收了5-10倍的费用。他们想知道Claude Code是否会面临与Cursor类似的限制。 尽管在*纯粹*编码方面,Claude的基准测试表现不如O3/Grok4等竞争对手,但评论员强调Claude在指令遵循、可靠性以及独特的“心智理论”方面更胜一筹。人们也对像安装npm包一样,轻易运行具有完全系统访问权限的代码的安全性表示担忧。最后,一位用户表达了对使用Grok的伦理担忧,因为它与埃隆·马斯克有关联。
相关文章

原文

npm version NPM Downloads install size DeepWiki Mentioned in Awesome Claude Code

Analyze your Claude Code token usage and costs from local JSONL files — incredibly fast and informative!

Quick Start (Recommended)

Thanks to ccusage's incredibly small bundle size (install size), you can run it directly without installation:

# Using bunx (recommended for speed)
bunx ccusage

# Using npx
npx ccusage@latest

# Using deno (with security flags)
deno run -E -R=$HOME/.claude/projects/ -S=homedir -N='raw.githubusercontent.com:443' npm:ccusage@latest

💡 Tip: We recommend using bunx instead of npx for a massive speed improvement!

Local Installation (Optional)

Since ccusage has such a small bundle size, installation is entirely optional:

# Basic usage
ccusage          # Show daily report (default)
ccusage daily    # Daily token usage and costs
ccusage monthly  # Monthly aggregated report
ccusage session  # Usage by conversation session
ccusage blocks   # 5-hour billing windows

# Live monitoring
ccusage blocks --live  # Real-time usage dashboard

# Filters and options
ccusage daily --since 20250525 --until 20250530
ccusage daily --json  # JSON output
ccusage daily --breakdown  # Per-model cost breakdown
  • 📊 Daily Report: View token usage and costs aggregated by date
  • 📅 Monthly Report: View token usage and costs aggregated by month
  • 💬 Session Report: View usage grouped by conversation sessions
  • 5-Hour Blocks Report: Track usage within Claude's billing windows with active block monitoring
  • 📈 Live Monitoring: Real-time dashboard showing active session progress, token burn rate, and cost projections with blocks --live
  • 🤖 Model Tracking: See which Claude models you're using (Opus, Sonnet, etc.)
  • 📊 Model Breakdown: View per-model cost breakdown with --breakdown flag
  • 📅 Date Filtering: Filter reports by date range using --since and --until
  • 📁 Custom Path: Support for custom Claude data directory locations
  • 🎨 Beautiful Output: Colorful table-formatted display with automatic responsive layout
  • 📱 Smart Tables: Automatic compact mode for narrow terminals (< 100 characters) with essential columns
  • 📋 Enhanced Model Display: Model names shown as bulleted lists for better readability
  • 📄 JSON Output: Export data in structured JSON format with --json
  • 💰 Cost Tracking: Shows costs in USD for each day/month/session
  • 🔄 Cache Token Support: Tracks and displays cache creation and cache read tokens separately
  • 🌐 Offline Mode: Use pre-cached pricing data without network connectivity with --offline (Claude models only)
  • 🔌 MCP Integration: Built-in Model Context Protocol server for integration with other tools
  • 🚀 Ultra-Small Bundle: Unlike other CLI tools, we pay extreme attention to bundle size - incredibly small even without minification!

Full documentation is available at ccusage.com

Check out these 47 Claude Code ProTips from Greg Baugues.

47 Claude Code ProTips from Greg Baugues

Star History Chart

MIT © @ryoppippi

联系我们 contact @ memedata.com