opencode-session-db

opencode-session-db is a skill for Claude Code, Codex from dzianisv/opencode-plugins. It costs 96 tokens per session (2,489 once invoked), scanned A, original, MIT.

A read-only way to inspect OpenCode's local SQLite database, which stores coding-session records. It can access sessions, messages, tool results, and task lists without a running OpenCode server.

In plain words
What is it for?
Use it to search session history, inspect messages and tool outputs, find old sessions, export records, or query OpenCode data.
Why use it?
It helps you find information from earlier sessions when the normal session interface is unavailable or inconvenient.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions OpenCode.

Good fit Use it to search session history, inspect messages and tool outputs, find old sessions, export records, or query OpenCode data.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/dzianisv/opencode-plugins/opencode-session-db
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add dzianisv/opencode-plugins --skill opencode-session-db
Clone the repo
git clone --depth 1 https://github.com/dzianisv/opencode-plugins

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for opencode-session-db

README.md
[![agentmods](https://agentmods.dev/badge/skills/dzianisv/opencode-plugins/opencode-session-db/github.svg)](https://agentmods.dev/skills/dzianisv/opencode-plugins/opencode-session-db)
Your own site
<a href="https://agentmods.dev/skills/dzianisv/opencode-plugins/opencode-session-db"><img src="https://agentmods.dev/badge/skills/dzianisv/opencode-plugins/opencode-session-db/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for opencode-session-db

Your own site · 80×15
<a href="https://agentmods.dev/skills/dzianisv/opencode-plugins/opencode-session-db"><img src="https://agentmods.dev/badge/skills/dzianisv/opencode-plugins/opencode-session-db.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 96 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,489 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00096 $0.02489
Opus 5.5 $0.00038 $0.00996
Sonnet 5.5 $0.00019 $0.00498
Haiku 4.5 $0.00010 $0.00249

Measured 1mo ago against content hash 0a29f9d5e0f9, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

opencode-session-db scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/query.sh), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/opencode-session-db/SKILL.md · 282 lines

How it starts

The opening of the file, as written. The whole thing — 282 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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

{"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 "$DB"

# Set DB path
DB=~/.local/share/opencode/opencode.db

List recent sessions

SELECT s.id, s.title, datetime(s.time_created/1000, 'unixepoch') as created,
       datetime(s.time_updated/1000, 'unixepoch') as updated, p.name as project
FROM session s JOIN project p ON s.project_id = p.id
WHERE s.time_archived IS NULL
ORDER BY s.time_updated DESC LIMIT 20;

Search sessions by title

SELECT id, title, datetime(s.time_updated/1000, 'unixepoch') as updated
FROM session s WHERE title LIKE '%search term%'
ORDER BY time_updated DESC;

Read the full file on GitHub · 282 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 282 lines · 96 tokens per session scan A 0a29f9d5e0f9

Subscribe to this mod's changes

opencode-session-db is a skill published in the GitHub repository dzianisv/opencode-plugins (11 stars, last pushed 3mo ago), licensed MIT. It adds 96 tokens to every session and 2,489 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

cmux-backend

Backend TypeScript and Cloud VM development rules for cmux. Use when editing web/app/api, web/services, backend scripts, Cloud VM lifecycle, provider integrations, Postgres, Stack Auth pricing gates, migrations, or provider image build scripts.

manaflow-ai/cmux · 53 tokens

db-sculptor

Design database schemas with Prisma/Drizzle, PostgreSQL index strategy (B-tree, GIN, GiST, BRIN, Hash), query optimization (EXPLAIN ANALYZE), migration safety (expand/contract, zero-downtime), and sharding/partitioning. Use when user asks to design schema, create migrations, optimize slow queries, add indexes, choose…

EliasOulkadi/shokunin · 123 tokens

neon-postgres

Guides and best practices for working with Neon Serverless Postgres. Covers getting started, local development with Neon, choosing a connection method, Neon features, authentication (@neondatabase/auth), PostgREST-style data API (@neondatabase/neon-js), Neon CLI, and Neon's Platform API/SDKs. Use for any Neon-related…

EliasOulkadi/shokunin · 76 tokens

chromadb

Manage the ChromaDB vector database that stores the ecosystem's persistent memory. Use when user asks to check memory storage, backup memory, search stored entries, delete entries, or reset the vector database. Do NOT use for general question answering about past sessions (use the memory skill for that).

EliasOulkadi/shokunin · 61 tokens

db-admin

PostgreSQL database administration — backup/restore (pgdump, PITR, WAL archiving), health monitoring (connections, bloat, cache hit ratio, dead tuples), connection pooling (PgBouncer), replication (streaming, logical), vacuum/autovacuum tuning, and scheduled backups with retention. Use when user asks to backup a…

EliasOulkadi/shokunin · 122 tokens

rp1-migrate

Safely migrate legacy rp1 project artifacts to the current layout.

rp1-run/rp1 · 18 tokens