kazuph

Ccusage Mbt — Development skill for Claude Code

Development community

Fast Claude Code usage tracker written in MoonBit.

How to install Ccusage Mbt

This entry records only its repository, not the path inside it, so there is no exact command to give. Open kazuph/ccusage-mbt and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Ccusage Mbt does

Fast Claude Code usage tracker written in MoonBit.

Alternatives in Development

  • HTML Report — /html-report - Generate Application Tracker Dashboard 36.6k ★
  • Career-Ops For Codex — Read CLAUDE.md for all project instructions, routing, and behavioral rules 32.5k ★
  • Thesis Tracker — 投资论文追踪:买入后的纪律系统 15.9k ★

README

ccusage-mbt

A blazing-fast CLI tool to aggregate Claude Code and Codex (OpenAI) API usage from local JSONL logs. Written in [MoonBit](https://www.moonbitlang.com/) with C FFI for maximum performance.

Why?

Claude Code and Codex store API interaction logs as JSONL files locally. Aggregating usage across thousands of sessions (4.7GB+ of Claude data, 600MB+ of Codex data) is painfully slow with interpreted languages.

`ccusage-mbt` solves this by:

  • Parsing JSONL at the C level using strstr() — no full JSON parse, no UTF-16 conversion
  • Deduplicating entries with an FNV-1a hash set in C
  • Reading Codex sessions via tail-read (only the last entry matters)
  • Filtering at the directory level before opening files

Benchmarks

Measured on MacBook Pro (M3 Max, 128GB RAM) with ~9,100 Claude JSONL files (4.7GB) and ~300 Codex JSONL files (667MB). All times are wall-clock (real) time.

Claude Code

Query Time Data Processed
Today 0.7s ~100M tokens
7 days 1.4s ~1.9B tokens
30 days 7.8s ~8.5B tokens

Codex (tail-read optimization)

Query Time
30 days (~300 sessions) 0.05s

Codex sessions use a tail-read strategy (last entry = session total), making them near-instant regardless of period.

Previously, the 30-day query took **1 minute 42 seconds** with the Node.js implementation (`ccusage`). That's a **~13x speedup**.

Binary Size

The compiled native binary is only **539KB**.

Architecture

┌─────────────────────────────────────────────────────────┐
│                    ccusage-mbt CLI                       │
│                   (MoonBit main.mbt)                     │
│                                                         │
│  Subcommands: daily | monthly | weekly | session        │
│  Flags: --since, --until, --source, --json, --breakdown │
├─────────────────────────────────────────────────────────┤
│              MoonBit Application