Skip to main content
Use this guide if you move Atomic sessions from one store to another, copy them to another machine, or keep them between CI runs. By the end of this page, you can export sessions to portable JSONL files, import them into a supported target store, choose which store each command reads or writes, and redact an export before you share it. To choose a store in the first place, see Storage. atomic storage export <dir> writes sessions to portable JSONL files (one per session), and atomic storage import <dir> loads them into a target store. Both commands take a folder and an optional store selection:
Both commands also accept an optional --sessions compatibility flag, which does nothing, because sessions are all they transfer. Each exported file is a complete, standalone copy of one session—including every branch, tool output, worktree snapshot, and the full inherited history of any shared-history fork. Importing writes standalone sessions, so deleting originals never affects imported copies.

Export folder layout

An export folder holds one file per session:
Session IDs are URL-encoded (encodeURIComponent(id)) in filenames so IDs containing special characters stay portable. Import reads only *.jsonl files in <dir>/sessions and ignores everything else (including temporary files from an interrupted export). If <dir>/sessions does not exist, import adds nothing.

Export sessions

By default, atomic storage export writes every session across all projects, including hidden subagent sessions so subagent history travels with its parent. The following options limit which sessions it writes: Export writes each file to a temporary path and atomically renames it when complete. Unchanged files are skipped, and existing files in <dir> are never deleted—prune old exports yourself.

Import sessions

atomic storage import validates every file before it writes anything. A malformed line, unsupported format version, or conflicting history stops the import with the filename and line number before any data changes. Import matches each file to a session by session ID, then does the following:
  • Sessions absent from the store are added.
  • Sessions present with fewer entries receive the newer entries.
  • Sessions already up to date are skipped.
Importing the same directory twice is safe and idempotent. If a write fails partway through, import exits 1 and lists which sessions succeeded and which did not (StorageImportIncompleteError in the SDK); re-run the same command to finish. Imported sessions work immediately with --session, /resume, and history://sessions.

Choose the store to export from or import into

By default, both commands use the store selected in the current directory. They refuse when that store is a shared database or in-memory store (machines on a shared database already see its sessions). To export from or import into a specific store—including a shared PostgreSQL database—pass --storage <json> or --storage-file <path>:
  • A relative path in --storage / --storage-file resolves against the current directory, not the storage home. Make relative SQLite paths from settings.json absolute first. A relative secrets.file still resolves against the storage home so atomic storage join’s password file works as-is.
  • JSONL { "dir": "..." } and empty {} selections are refused with --storage / --storage-file. (To export from a JSONL directory selected with --session-dir, set ATOMIC_SESSIONS_STORAGE instead; see Move to SQLite or PostgreSQL.)
To copy local SQLite sessions into a new PostgreSQL database:
  1. Export the sessions from the local store:
  2. Save the runtime role’s password to a private file, join the database, and delete the file. atomic storage join keeps its own copy:
  3. Save the new storage setting to a file, and import the sessions into that store:
Confirm that atomic storage status names the PostgreSQL store and that atomic -r lists your project’s sessions.

Export file format and redaction

Export files use session format version 4, the same format as JSONL directories and atomic --import <file>. Line 1 is the session header, and each later line is an entry, in the order it was appended. For example:
Files contain every branch of the session. Tool output and worktree snapshot blobs are embedded once each in base64 and verified by SHA-256 on import. You can redact secrets (for example replacing a token with ***) before sharing an export file, provided every line remains valid JSON in its original order and you keep these fields unchanged:
  • Header: type, version, id, and createdAt (cwd determines the project).
  • Every entry: id, parentId, and type.
  • Every base64 value and blobs object (hash-verified on import).

Keep sessions between CI runs

On a CI runner that caches $STATE_DIR between jobs, import the cached sessions at the start of the job and export them at the end:
Use --since or --limit to bound cache size, and resume an imported session with atomic --session <id>.

What’s next