r/opencode • • 16d ago

OpenCode lists sessions but can't search the content inside them, so I made a tiny CLI for it

OpenCode stores its sessions in a SQLite database at ~/.local/share/opencode/opencode.db. I made a small CLI wrapper around it that searches inside those sessions. OpenCode session list and the TUI picker both work on titles, so there is no way to find a string inside an old conversation. You can run it from your terminal, or from inside OpenCode through a skill.

Example outputs:

Keyword search over old sessions:

$ ocsearch "connection timed out"
▌ 2026-11-03 14:12:08  Rate limiter retry backoff  ses_e9f2a41c0ffeQw1mXbT7LpRnD  [5 matches]
    2026-11-03 14:09:51  [assistant]
        …api/client.go:88: dial tcp 10.0.0.4:5432: connect: connection timed out…
    +4 more matches

Dump a whole session transcript into a markdown file:

$ ocsearch ses_e9f2a41c0ffeQw1mXbT7LpRnD
wrote /tmp/ocsearch/ses_e9f2a41c0ffeQw1mXbT7LpRnD.md: 48120 bytes, 1337 lines

Python3 required, no dependencies. For the installation:

git clone https://github.com/demirciAhmet/ocsearch && cd ocsearch
install -m755 ocsearch search_session.py ~/.local/bin/

https://github.com/demirciAhmet/ocsearch

3 Upvotes

0 comments sorted by