# Where OpenCode stores your session history

> OpenCode keeps every session in one SQLite database, opencode.db, under ~/.local/share/opencode. How to find it, list, export, share and delete sessions.

Source: https://groundedby.com/agents/opencode (updated 2026-10-29)

OpenCode, the open-source terminal agent now maintained at anomalyco/opencode, stores all sessions in one SQLite database.

## Where the database is

```bash
opencode db path        # prints the active database
```

By default it is `~/.local/share/opencode/opencode.db` on macOS and Linux, and the same path under `%USERPROFILE%` on Windows. `OPENCODE_DB` changes the file name. Before v1.2.0 (February 2026) sessions were JSON files under `storage/`; they are migrated automatically.

## What is inside

| Table | What it holds |
| --- | --- |
| `session` | Title, model, token counts, cost |
| `message` | Messages in each session |
| `part` | Message parts as JSON: text, tool calls, results |

## Resume, export and delete

```bash
opencode --continue              # the latest session
opencode --session <id>          # a specific one
opencode --session <id> --fork
opencode session list
opencode session delete <id>
opencode export <id> --sanitize  # export with sensitive values removed
opencode import <file>
```

## Sharing

`/share` uploads a session to a public link at `opncd.ai/s/<id>`, and `/unshare` removes it. The `share` setting is `manual` by default; `auto` shares every session and `disabled` turns sharing off.

## Not to be confused with

The older Go project named opencode was archived and continues as Charm's Crush.

The groundedby [evaluator](/evaluate) does not read OpenCode's database yet.

## Questions

**Where are OpenCode sessions stored?**

In a single SQLite database, opencode.db, under ~/.local/share/opencode on every system. Run opencode db path to print the exact location; OPENCODE_DB changes it.

**How do I export an OpenCode session?**

opencode export <id> writes it out, and --sanitize removes sensitive values. opencode import brings one back in.

**Are OpenCode sessions uploaded?**

Only if you share them. The share setting is manual by default; a shared session is uploaded to a public link at opncd.ai. Set share to disabled to rule it out.

## Sources

- [OpenCode docs, troubleshooting (storage locations)](https://opencode.ai/docs/troubleshooting/)
- [OpenCode docs, sharing](https://github.com/anomalyco/opencode/blob/v1.19.5/packages/web/src/content/docs/share.mdx)
