Overview
CodePiper tracks token usage from every Claude Code session and aggregates it into dashboards and CLI reports. This gives you visibility into how much your agents are consuming, which models they’re using, and how well caching is working.
Analytics data comes from Claude Code transcript tailing. The daemon parses JSONL transcripts in real time, extracting token counts per request. Codex sessions have limited analytics (PTY output only, no token-level data).
What’s Tracked
| Metric | Description |
|---|---|
| Prompt tokens | Tokens sent to the model (input) |
| Completion tokens | Tokens generated by the model (output) |
| Cache creation tokens | Tokens written to the prompt cache |
| Cache read tokens | Tokens served from the prompt cache |
| Total tokens | Sum of all token types per request |
| Model | Which model handled the request |
| Tool usage | Which tools the agent invoked and how often |
Cache Hit Rate
Cache hit rate measures how effectively prompt caching is reducing your token costs:
cache_hit_rate = cache_read_tokens / (prompt_tokens + cache_creation_tokens + cache_read_tokens)A high cache hit rate (70%+) means most of your input tokens are being served from cache, significantly reducing both latency and cost on cached models.
Cost Estimation
CodePiper estimates costs using per-model pricing tables:
- Each request’s tokens are multiplied by the model’s per-million-token rates
- Separate rates for input, output, cache write, and cache read
- The estimate covers all supported Claude models (Opus, Sonnet, Haiku across versions)
Cost estimates are approximate. Actual billing depends on your Anthropic plan and any volume discounts.
Dashboard Views
The Analytics page in the web dashboard shows:
Token Usage Over Time
A time-series chart showing prompt, completion, cache creation, and cache read tokens per day. Filter by range: today, 7 days, 30 days, or all time.
Model Distribution
Breakdown of token usage by model. Shows which models your sessions are spending the most tokens on, helping you optimize model selection.
Activity Timeline
Daily message counts (user and assistant) across all sessions. Useful for understanding usage patterns and peak activity.
Tool Usage
Top 15 most-used tools across all sessions. Extracted from assistant message events in transcripts.
Sessions by Provider
Distribution of sessions between Claude Code and Codex.
CLI Reports
# Overview with cost estimatecodepiper analyticscodepiper analytics overview --days 7
# Token breakdown by modelcodepiper analytics tokens --days 30
# Top tools usedcodepiper analytics tools --days 7
# Daily activity timelinecodepiper analytics activity --days 30
# Sessions by providercodepiper analytics sessionsThe --days flag accepts 1 (today), 7, 30, or 0 (all time).
Data Pipeline
The analytics pipeline works as follows:
- Claude Code writes JSONL transcript entries as the session runs
- The TranscriptTailer reads the file with byte-offset tracking (crash-safe, no data loss on restart)
- Token counts, model info, and tool usage are extracted from each entry
- Data is persisted to the
token_usageandeventstables in SQLite - The analytics endpoints aggregate this data with SQL queries filtered by time range
All processing happens locally. No data leaves your machine.
What’s next
- Architecture: How the transcript tailer and event bus work
- Sessions & Providers: Provider-specific analytics capabilities
- Workflows: Track token usage across workflow executions