OpenCode

OpenCode usage on Linux

Track OpenCode usage on Linux. The XDG data path, AppImage and package options, and how to read the database without a desktop app.

Quick answer

OpenCode follows the XDG layout on Linux: data in `~/.local/share/opencode`, config in `~/.config/opencode`. Recent versions keep a SQLite database there; older ones keep JSON under `storage/`. UsageAtlas ships as an AppImage, .deb, and .rpm and reads that directory locally.

Linux paths

ItemPath
Data`~/.local/share/opencode`
Config`~/.config/opencode`
Database`opencode.db` inside the data folder
Legacy storage`storage/` JSON files
ls -la ~/.local/share/opencode
ls -la ~/.local/share/opencode/storage 2>/dev/null

Use the desktop app

  1. Download the AppImage, .deb, or .rpm from UsageAtlas.
  2. Launch it and confirm OpenCode is detected.
  3. Open History and choose a range.
  4. Keep it running if you want alerts for connected providers.

Or query the database

If you only need one number, sqlite3 is enough. List the tables first, then total token fields for a date range. The schema changes between versions, so inspect before writing a permanent script.

sqlite3 ~/.local/share/opencode/opencode.db ".tables"
sqlite3 ~/.local/share/opencode/opencode.db "select name from sqlite_master where type='table';"

OpenCode on Linux: paths and containers

Linux follows the XDG convention, so the database sits under your local share directory. That is convenient until you work in a container, where the path exists only inside the container image and vanishes on rebuild.

  • Confirm the data directory exists and grows during a session.
  • Bind-mount it if you use containers, or copy it out before rebuilds.
  • Keep the file readable only by your user.
  • Copy before opening with a viewer while the CLI is running.

UsageAtlas ships for Linux and reads the database without modification. See database location for paths and session history for contents.

Questions, answered

Where does OpenCode store data on Linux?

In ~/.local/share/opencode by default, or under XDG_DATA_HOME if that variable is set.

Which package should I install?

AppImage for any distribution, .deb for Debian and Ubuntu, .rpm for Fedora and openSUSE.

Can I read OpenCode usage without installing an app?

Yes. Query the SQLite database with sqlite3. The app is a convenience layer over the same data.

Browse by topic