README
ΒΆ
A fast, zero-dependency CLI cost calculator and statusline provider for Claude Code β single binary, no runtime needed.
Parses JSONL logs from ~/.claude/projects/, deduplicates streaming responses, and breaks down spending by model, day, and project β with accurate per-model pricing including separate cache write tiers.
Table of Contents
Installation
Homebrew (macOS / Linux)
brew install backstabslash/tap/goccc
Alternatives
Go install (requires Go):
go install github.com/backstabslash/goccc@latest
From source:
git clone https://github.com/backstabslash/goccc.git && cd goccc
go build -o goccc . # macOS / Linux
go build -o goccc.exe . # Windows
Pre-built binaries are available on the releases page for macOS, Linux, and Windows (amd64 / arm64).
Usage
goccc # Summary of all-time usage
goccc -days 7 -all # Last 7 days with daily and project breakdowns
goccc -daily # Daily breakdown only
goccc -projects # Project breakdown only
goccc -project webapp -daily # Filter by project name (substring match)
goccc -days 1 # Today's usage
goccc -projects -top 5 # Top 5 most expensive projects
goccc -days 30 -all -json # JSON output for scripting
goccc -json | jq '.summary.total_cost' # Pipe to jq for custom analysis
Claude Code Statusline
goccc can serve as a Claude Code statusline provider β a live cost dashboard right in your terminal prompt.
πΈ $1.23 session Β· π° $5.67 today Β· π 45% ctx Β· π 2 MCPs (confluence, jira) Β· π€ Opus 4.6
- πΈ Session cost β parsed from the current session's JSONL files using goccc's pricing table
- π° Today's total β aggregated across all sessions today (shown only when higher than session cost)
- π Context % β context window usage percentage
- π MCPs β active MCP servers (from settings, marketplace plugins, and project config; respects per-project disables)
- π€ Model β current model
Cost and context values are color-coded yellow β red as they increase.
Setup
Add to ~/.claude/settings.json:
Using Homebrew (recommended β fast, no runtime needed):
{
"statusLine": {
"type": "command",
"command": "goccc -statusline"
}
}
Using Go (requires Go installed; binary is cached after first download):
{
"statusLine": {
"type": "command",
"command": "go run github.com/backstabslash/goccc@latest -statusline"
}
}
To hide the MCP indicator, add -no-mcp.
Flags
| Flag | Short | Default | Description |
|---|---|---|---|
-days |
-d |
0 |
Only show the last N calendar days (0 = all time) |
-project |
-p |
Filter by project name (substring, case-insensitive) | |
-daily |
false |
Show daily breakdown | |
-projects |
false |
Show per-project breakdown | |
-all |
false |
Show all breakdowns (daily + projects) | |
-top |
-n |
0 |
Max entries in breakdowns (0 = all) |
-json |
false |
Output as JSON | |
-no-color |
false |
Disable colored output (also respects NO_COLOR env) |
|
-base-dir |
~/.claude |
Base directory for Claude Code data | |
-statusline |
false |
Statusline mode for Claude Code (reads session JSON from stdin) | |
-no-mcp |
false |
Hide MCP servers from statusline output | |
-version |
-V |
Print version and exit |
How It Works
Claude Code stores conversation logs as JSONL files under ~/.claude/projects/<project-slug>/. Each API call produces one or more log entries β streaming responses generate duplicates with the same requestId.
goccc:
- Walks
.jsonlfiles under the projects directory, skipping non-matching project directories and files older than the date range (by mtime) - Pre-filters lines with a byte scan before JSON parsing β only
"type":"assistant"entries carry billing data (tolerates both compact and spaced JSON formatting) - Deduplicates streaming entries by
requestId(last entry wins) - Calculates costs using Anthropic's published pricing, including separate rates for 5-minute and 1-hour cache writes
- Aggregates by model, date (local timezone), and project
Preserving Log History
Claude Code periodically deletes old log files. To keep more history for cost tracking, increase the cleanup period in ~/.claude/settings.json:
{
"cleanupPeriodDays": 365
}
The default is 30 days. Set it higher to retain more data for goccc to analyze.
Documentation
ΒΆ
There is no documentation for this package.