OpenCode utilizes a single relational SQLite database (defaulting to ~/.local/share/opencode/opencode.db) for session storage, providing ACID transactional integrity and structured queries. When you wish to transition sensitive tasks to locally hosted open-source models (via Ollama or vLLM in OpenCode) or hand off back to frontier cloud models (Claude/Codex), Watch provides a verified bidirectional bridge.
Unlike tools that rely strictly on append-only JSONL files, OpenCode organizes sessions across normalized relational tables including sessions, messages, and parts. Direct external tampering can corrupt foreign key constraints. Watch maps the UnifiedTurn abstraction cleanly into OpenCode's relational schema while preserving exact directory context (cwd) and timestamps.
Step 1: Identify source session ID and working directory
Locate your active session ID. Claude Code stores files in ~/.claude/projects/; Codex in ~/.codex/sessions/; OpenCode indexes sessions via globally unique IDs. Verify that the working directory is an absolute path to maintain project boundary alignment.
Step 2: Preflight target database status (Check)
Run Watch CLI with --check to probe the target OpenCode database. Watch validates write permissions and locks on ~/.local/share/opencode/opencode.db (or the custom path specified by WATCH_OPENCODE_DB) to prevent concurrent write contention.
Step 3: Execute bidirectional handoff (Handoff)
Select the source session in Watch Desktop and target OpenCode, or run the CLI open command. Watch extracts incremental turns, executes atomic SQLite transactions across sessions, messages, and parts, and issues the destination session ID.
Step 4: Resume session natively in OpenCode (Resume)
After conversion, execute opencode -s <session-id> in the workspace directory or trigger the launch button in Watch Desktop. OpenCode resumes from the recorded conversation state seamlessly.
# 1. Preflight: Verify target OpenCode database writability
npm run watch -- open <claude-session-id> --to opencode --check --json
# 2. Handoff: Transfer session into OpenCode SQLite database
npm run watch -- open <claude-session-id> --to opencode --json
# 3. Reverse handoff: Transfer from OpenCode back to Claude or Codex
npm run watch -- open <opencode-session-id> --to claude --json1. Database isolation & backups: Watch operates on ~/.local/share/opencode/opencode.db by default and respects WATCH_OPENCODE_DB for testing environments. Atomic transactions protect against corrupted partial writes. 2. Tool call representations: Tool records map across schemas; unsupported proprietary parameters degrade into structured text representations. 3. Model continuation: Watch ensures lossless history and workspace database ingestion; response generation quality upon resumption depends on your configured model provider.