Repository navigation
Description
Summary
The opencode data directory (~/.local/share/opencode) accumulates two kinds of junk that are never cleaned up: 30,370 orphaned zero-byte temp files named .!<pid>!<name> (leftovers of interrupted temp-then-rename bulk writes), and 874 MB of opencode.db.*backup* copies written directly into the live data directory alongside the active database. Together they took the data directory to 1.7 GB — over 3× the live DB.
Environment
- opencode version: 2.2.4 (desktop app + bundled CLI
cli/2.2.4-arm64/opencode-cli) - OS: Darwin 25.6.0 arm64 (macOS, Apple Silicon)
- Shell:
/bin/zsh - Terminal:
TERM=xterm-256color,TERM_PROGRAMunset,COLORTERMunset - Install/channel: release (desktop app)
- Active plugins: none at time of writing (an
opencode-antigravity-auth@betaplugin had been configured)
Reproduction
Best-effort; the temp files come from an interrupted bulk write, which I could not trigger on demand.
- Have opencode manage a data dir containing a large tool/LSP package tree (e.g.
~/.local/share/opencode/bin/vscode-eslint/, ~18k files). - Interrupt opencode (crash / kill) while it is bulk-writing files (install / update / extract).
- Restart. Observe ~18k — and ~30k in total across
bin/,storage/,snapshot/,shell/,log/,tool-output/— zero-byte.!<pid>!<original-name>files that persist across subsequent starts.
Expected Behavior
- A temp file whose real counterpart already exists should be pruned on startup (or the write should be crash-atomic and clean up after itself).
- Large DB copies produced during recovery/migration should go to a dedicated backups subdirectory — not the live data directory — and be subject to retention/pruning.
Actual Behavior
30,370 zero-byte .!<pid>!<name> files left behind:
| Path | Count | Example |
|---|---|---|
bin/ |
18,273 | bin/vscode-eslint/.!44435!.vscodeignore |
storage/ |
11,933 | storage/.!74700!migration |
snapshot/ |
120 | snapshot/<id>/objects/info/.!44312!packs |
shell/ |
26 | |
log/ |
12 | log/.!74738!opencode.log |
tool-output/ |
5 | |
| data dir root | 1 | .!74749!auth.json |
All are 0 bytes, and every one has its real counterpart intact — none are lost data, purely orphaned litter. Created around 06:28 local and still present hours later; nothing pruned them.
874 MB of DB copies inside the live data directory:
| File | Size |
|---|---|
opencode.db.corrupted-backup-20261031064413 |
528 MB |
opencode.db.pre-v2migration-backup-20261031075456 |
346 MB |
opencode.db (live) |
557 MB |
| data dir total (before cleanup) | 1.7 GB (891 MB after removing the copies + temp files) |
The copies sit next to the live opencode.db, with only a filename suffix distinguishing them, and there is no visible retention or pruning.
Additional Context
- Background: immediately before these copies were created, the server logged 16×
SQLiteError: table session_inbox has no column named type, later cleared bydatabase schema bootstrap started ... migrations=59. - Workaround applied locally: moved both
opencode.db.*backup*files to~/opencode-db-backups/and deleted all 30,370.!temp files (find ~/.local/share/opencode -name '.!*!*' -type f -size 0 -delete). - Possibly related: an older v1 CLI (1.18.31) shared the same data directory as the 2.2.4 desktop app.
Activity
opencodejr commentedon Oct 30, 2026
Thanks for the detailed report!
I looked through the OpenCode v2.2.4 source and couldn't find anything that creates either kind of file:
.!<pid>!<name>temp files: OpenCode's temp-then-rename writes use names like<file>.<pid>.<uuid>.tmpor<file>.<pid>.tmp, never.!<pid>!<name>. Some of the files you list are also never written through a temp file by OpenCode, e.g. git's ownsnapshot/<id>/objects/info/packs,log/opencode.logand the.vscodeignoreinside the extracted eslint package. A pattern like this usually comes from an external tool that copied, synced or backed up the whole directory around 06:28.opencode.db.corrupted-backup-*/opencode.db.pre-v2migration-backup-*: v2 has no code that writes DB copies with these names.To work out where they came from, could you tell us, briefly and in your own words:
~/.local/share/opencodearound 06:28 and 06:44–07:54 that morning? For example a backup or sync tool (Time Machine, iCloud/Dropbox, rsync, Carbon Copy Cloner), a manual copy or restore, or an AI agent or script you asked to repair the database after thesession_inbox has no column named typeerrors.~/.local/share/opencode/log/), please share any lines that mention these backup files or a database recovery or migration.You can reply here, or edit the issue. If you edit it, please also leave a comment saying you've updated it so we know you're done.
Related issues, ordered by how closely they relate (none of them reports this exact problem):
opencode.db/ data-directory growth on v2opencode.dbcarlsuburbmates commentedon Oct 30, 2026
Thanks — you're right, and I verified it rather than assuming.
1. What touched the directory. Those filenames came from an AI agent session I ran on this machine to recover the database after the
session_inbox has no column named typeerrors — not from OpenCode. I checked directly: the only log lines namingopencode.db.corrupted-backup-*/opencode.db.pre-v2migration-backup-*are from my ownducommand. There is no OpenCode log entry about a database recovery, corruption, or backup creation, and no code path that emits.!<pid>!<name>— the temp names I saw don't match<file>.<pid>.<uuid>.tmp.2. v1 CLI. 1.18.31 was on
PATHpointing at the same data dir, but I cannot prove it executed during that window. It's since been quarantined andopencodenow resolves to the bundled 2.2.4 CLI.3. Relevant server log lines.
No recovery/backup lines.
Net: I over-claimed in the original report and I'm narrowing it. Two things I still think are OpenCode-side and worth keeping (happy to split into their own issues if you'd rather):
table session_inbox has no column named typeand only became consistent after a laterdatabase schema bootstrap (migrations=59)— i.e. requests touching new columns can be served before the schema is migrated. You also gate/api/infoon readiness (server/src/process.ts:192), so a hard readiness gate on migration completion looks like the missing piece.GET /api/inforeturns{version,pid,urls,paths}with no API/schema generation, which is the same gap as Expose an API version in /api/info + publish a v1→v2 migration path (routes, prompt payload, events, sessions) #55705.Want me to retitle this to the schema/readiness issue, or close it in favour of #55010 / #55282 / #55705?
[-]data: orphaned temp files and large database backups left inside the live data directory[/-][+]db: server serves before schema migration completes ("table session_inbox has no column named type")[/+]opencodejr commentedon Nov 2, 2026
We're closing this issue as not planned because we haven't heard back.
OpenCode v2.2.4 has no code that creates
.!<pid>!<name>temp files or theopencode.db.corrupted-backup-*/opencode.db.pre-v2migration-backup-*copies. So we need to know which tool, script or process wrote them before we can treat this as an OpenCode bug.If you find out, for example from a backup or sync tool, an agent or script that ran a repair, or log lines in
~/.local/share/opencode/log/that point to OpenCode, please comment with the details and we can reopen this. Thanks for the thorough write-up!