Use ctx with OpenCode

Import OpenCode local database history and search it from ctx.

Install ctx on the machine where OpenCode stores local history:

curl -fsSL https://ctx.rs/install | sh

See Install for setup and data-root details.

ctx can import OpenCode history from its local SQLite database when that database exists on the machine. ctx opens provider-owned history read-only and stores searchable session data in its own local SQLite index.

Import OpenCode history

Run setup or target OpenCode directly:

ctx setup
ctx import --provider opencode
ctx sources --json

If your OpenCode database is outside the default location, pass the path explicitly:

ctx import --provider opencode --path ~/.local/share/opencode/opencode.db

Search OpenCode history

Use a provider filter when the prior work happened in OpenCode:

ctx search "database retry failure" --provider opencode --json
ctx show event <ctx-event-id> --window 3
ctx show session <ctx-session-id> --mode lite

Omit the provider filter when the topic may have crossed agents.

Prompt an agent

Use ctx to search prior OpenCode sessions for this task. Inspect the best event or session before relying on it, then cite the ctx ID if the retrieved history changes your plan.

That instruction works for any shell-capable coding agent, including Codex, Claude Code, Cursor, and OpenCode itself when it can run local commands.