VCode home

Where state lives, and how to back it up

Agents: claude, codex, opencode · On: desktop

Everything VCode remembers is plain files under one directory, VCODE_STATE. Copy it to back up; delete it to start clean. There is no database.

Why you would use it

You are moving VCode to another machine, want a backup before an upgrade, or want the disk space back from a year of transcripts.

How to use it

  1. Find the root. Under the unit it is ~/.local/state/v-code/workbench/threads (the workbench/ directory keeps its name from before the rename); for a bare node server.js it is ~/.v-code/threads. The startup line names it: state <path>.
  2. Back up: tar czf v-code-state.tgz -C ~/.local/state/v-code/workbench threads. Stopping the unit first gives a clean snapshot, but the logs are append-only, so a copy taken while it runs loses at most a torn trailing line.
  3. Restore: stop the unit, unpack in place, start it.
  4. Start clean: stop the unit, rm -rf the directory, start it. VCode recreates it empty.
  5. Delete one thread instead: close the tab, then delete it from the UI. That is a recursive remove of the thread's own directory.

What you see

<VCODE_STATE>/
  session-epoch              the logout revocation timestamp
  settings.json              the cog's settings
  tab-order.json             the tab strip's order
  vapid.json                 push keys (0600)
  push-subscriptions.json    subscribed devices (0600)
  <thread-id>/
    events.ndjson            the canonical event log, one JSON object per line
    raw.ndjson               verbatim vendor frames
    raw.1.ndjson             the previous raw file, after a rotation
    attachments/             files uploaded into that thread

The thread directory name is the thread id put through encodeURIComponent.

Options and settings

Option Default What it changes
VCODE_STATE ~/.v-code/threads; $STATE_DIR/workbench/threads in the unit The root of everything above
--state-dir DIR (install.sh) ~/.local/state/v-code The $STATE_DIR the unit's paths are built from
Memory tail 2000 events per thread How many events stay resident; older ones are re-read from the file
Raw rotation 25 MB When raw.ndjson becomes raw.1.ndjson. Two files are kept

Limits and known gaps