← ClaudeAtlas

opencode-session-dblisted

Read OpenCode sessions, messages, and tool outputs directly from the SQLite database at ~/.local/share/opencode/. Use when asked to "read opencode sessions", "query opencode db", "find old sessions", "search session history", "read message history", "export session", "inspect opencode data", "look up past conversations", or any task requiring direct access to OpenCode's local storage. Does NOT require a running OpenCode server.
dzianisv/opencode-plugins · ★ 8 · AI & Automation · score 74
Install: claude install-skill dzianisv/opencode-plugins
# OpenCode Session DB Read OpenCode sessions and messages directly from SQLite — no running server needed. ## Database Location ``` ~/.local/share/opencode/opencode.db # latest/beta channel ~/.local/share/opencode/opencode-{channel}.db # dev, local, etc. ``` Override: `OPENCODE_DB` env var. WAL mode is enabled; always open read-only. ## Schema Overview 11 tables. The key ones for session reading: | Table | PK | Key columns | |---|---|---| | `project` | `id` | `worktree`, `name` | | `session` | `id` | `project_id`, `title`, `slug`, `directory`, `time_created`, `time_updated`, `time_archived` | | `message` | `id` | `session_id`, `time_created`, `data` (JSON: role, tokens, cost, model, error) | | `part` | `id` | `message_id`, `session_id`, `time_created`, `data` (JSON: type, text, tool info) | | `todo` | `(session_id, position)` | `content`, `status`, `priority` | ### Message `data` JSON structure ```json {"role": "user"|"assistant", "tokens": {...}, "cost": N, "model": {...}, "error": {...}} ``` ### Part `data` JSON structure — discriminated by `type` - `text` — `{type:"text", text:"..."}` - `tool` — `{type:"tool", tool:"toolName", input:{...}, output:"...", state:"completed"|"error"|...}` - `reasoning` — `{type:"reasoning", text:"..."}` - `step-start`/`step-finish` — step boundaries - `snapshot`/`patch`/`compaction` — context management - `file` — file references - `agent`/`subtask` — delegation ## Common Queries Always open read-only: `sqlite3 -readonly "$D