A terminal dashboard for OpenCode usage statistics.
oc-stats reads your local OpenCode SQLite database or JSON export files and displays token usage, cost estimates, model and provider distributions, and a 365-day activity heatmap directly in your terminal. Inspired by Claude Code's /stats command, this is an independent implementation focused on local execution, export, and shareability.
If you're already using OpenCode and want a quick view of your usage, costs, and activity trends, this tool is ready to go.
This is an unofficial community project and is not affiliated with, endorsed by, or maintained by the OpenCode team.
- Terminal dashboard UI built on
ratatui - Automatically reads OpenCode local database, or loads export files via
--json - Displays total tokens, costs, session count, message count, prompt count, and other overview metrics
- View usage breakdown by model and provider
- Supports three time ranges: all time, last 7 days, and last 30 days
- Built-in 365-day activity heatmap for observing long-term usage trends
- Supports dark / light theme via command-line argument
- Copy current view to clipboard: prioritize image export (share card), with automatic fallback to text summary
- Local model pricing cache with update / clean commands
- Output data calculation aligns with
opencode statsandopencode stats --modelsfor consistency
OpenCode Stats provides three data perspectives:
| Year view | Model usage | Provider usage |
|---|---|---|
![]() |
![]() |
![]() |
Each page also supports exporting a transparent-background share card directly to clipboard:
cargo install opencode-statsAfter installation, run:
oc-statsDownload the archive for your platform from the Releases page, extract it, and run oc-stats directly.
The current release workflow builds for:
- Windows
x86_64-pc-windows-msvc - macOS
x86_64-apple-darwin - macOS
aarch64-apple-darwin - Linux
x86_64-unknown-linux-gnu - Linux
x86_64-unknown-linux-musl
git clone https://github.com/Cateds/opencode-stats.git
cd opencode-stats
cargo build --releaseThe compiled binary will be located at:
target/release/oc-statsOr build directly using the git path:
cargo install --git https://github.com/Cateds/opencode-stats.gitBy default, the program automatically locates your OpenCode local database and loads the data:
oc-statsoc-stats --db /path/to/opencode.dboc-stats --json /path/to/export.jsonoc-stats --theme auto
oc-stats --theme dark
oc-stats --theme lightBy default, oc-stats keeps stored costs as-is, including cost: 0, to preserve compatibility with existing behavior. If your OpenCode setup stores cost: 0 as a placeholder for responses that still have token usage, use --ignore-zero to treat those zero values as missing and estimate the cost instead.
oc-stats --ignore-zeroView the local pricing cache path:
oc-stats cache pathUpdate the local pricing cache:
oc-stats cache updateClean the local pricing cache:
oc-stats cache cleanOnce the program is running, you can quickly navigate pages and time ranges using the keyboard:
Tab/Left/Right/h/l— Switch pagesUp/Down/j/k— Move focus withinModels/Providerspagesr— Cycle through time ranges1/2/3— Quickly switch time rangesCtrl+S— Copy current view to clipboardq/Esc/Ctrl+C— Exit the program
Pages:
Overview— Overall usage summaryModels— Usage statistics by modelProviders— Usage statistics by provider
Time ranges:
All timeLast 7 daysLast 30 days
oc-stats supports two input sources:
- OpenCode local SQLite database
- OpenCode exported JSON files
Default database locations:
- Windows:
%APPDATA%/opencode/opencode.db - Linux:
~/.local/share/opencode/opencode.db - macOS:
~/Library/Application Support/opencode/opencode.db
Model pricing is read from local cache first and refreshed from remote when needed:
- Local cache path:
~/.cache/oc-stats/models.json - Remote source:
https://models.dev/api.json - Cache TTL: 1 hour
If local overrides exist in your OpenCode configuration, they take precedence.
When complete pricing information is unavailable, the program falls back to estimated cache read/write costs. If the database already contains actual costs, those values are prioritized.
If the database stores cost: 0 for a nonzero-token response, oc-stats keeps that stored zero by default. Pass --ignore-zero to estimate the cost instead.
- Quickly view your OpenCode token consumption
- Analyze usage preferences by model or provider
- Understand recent and long-term usage trends
- Export statistics as images or text for easy sharing
MIT
- Font: Cascadia Code, under SIL Open Font License
- Experience inspired by Claude Code's
/statscommand - Reference project: ocmonitor-share



