opencode-session-dblisted
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