Skip to content
#

OpenCode

Save OpenCode sessions with the SpecStory CLI.

#

Before you start

Install OpenCode and the SpecStory CLI. OpenCode needs SpecStory CLI 2.15.0 or later, and sessions created with OpenCode 2.0.14 or later. Open your project folder in a terminal and run specstory check opencode.

#

Run with SpecStory

specstory run opencode

Use OpenCode as usual. SpecStory saves the conversation in .specstory/history/. Cloud sync can run when you are logged in; add --no-cloud-sync to keep the session local.

#

Export existing sessions

specstory list opencode
specstory sync opencode

# Export a single session
specstory sync opencode -s <session-id>

SpecStory reads OpenCode's session history from ~/.local/share/opencode/opencode.db and matches it to your project. You can export conversations even if you did not start them through SpecStory. OpenCode keeps every session in one database on all operating systems, so the match uses the directory recorded for each session, and it must be exact: run these commands from the folder where you started OpenCode, not a parent or a subfolder.

A subagent's session is not exported on its own; its answer appears in the parent conversation. OpenCode stores a slash command as its expanded template, so the saved prompt shows that text instead of the command name. Attachments are listed by name and type, and encrypted reasoning cannot be exported as readable text.

If you set XDG_DATA_HOME, OpenCode stores its data under $XDG_DATA_HOME/opencode/ instead. If you set OPENCODE_DB, it uses that database file. Set the same variables for SpecStory so it reads the same place. SpecStory can't read sessions when OPENCODE_DB is :memory:. Pre-release OpenCode builds that write opencode-<channel>.db are not discovered automatically; set OPENCODE_DB to that file.

#

Capture in the background

specstory watch opencode

Leave this running while using OpenCode directly. Stop watching with Ctrl+C.

#

Find and resume a session

Run specstory search to find saved work or specstory resume to choose a previous session. OpenCode continues one of its own sessions in place with opencode -s, and can receive a session from another agent as reconstructed conversation text, which SpecStory loads with opencode session import. See search and resume for the picker and supported handoffs.

OpenCode's free Zen models decline to continue a conversation that was not produced through Zen. A session resumed from another agent needs another configured model to continue.

#

Troubleshooting

If OpenCode is not detected, check that opencode is on your PATH. If your CLI does not list OpenCode in specstory run --help, update SpecStory. To launch OpenCode from another location, set opencode_cmd in your config or pass specstory run opencode -c "/absolute/path/to/opencode"; use an absolute path, because OpenCode's command setting does not expand a leading ~. If no sessions appear, run the commands from the folder where you started OpenCode and confirm that its local history still exists.

See the CLI reference for custom commands, configuration, and debug logging.