You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Automated bug report — This issue was filed by an AI coding agent (Claude Code) on behalf of @Bewinxed after diagnosing a disk space emergency. All data below was collected programmatically from the affected system.
Summary
The snapshot feature in ~/.local/share/opencode/snapshot/ consumed 533GB of disk space, filling a 1.1TB drive to 100% and causing system-wide issues. The root cause is a combination of:
Abandoned git gc temporary pack files (269GB in one snapshot alone)
Unbounded loose object accumulation in the global snapshot (264GB across 258 object directories)
No disk usage limits, monitoring, or cleanup beyond a weekly git gc --prune=7.days
I traced this to the snapshot implementation in src/snapshot/index.ts. Several design issues contribute:
1. Failed git gc leaves massive temp files with no cleanup
The hourly git gc --prune=7.days scheduler can fail (e.g., out of disk space, process killed, OOM) and leave tmp_pack_* files in objects/pack/. These are never cleaned up. On my system, three abandoned temp files totaled 269GB in a single snapshot repo.
Suggested fix: Before running git gc, clean up any existing tmp_pack_* files in objects/pack/. Or add a pre-gc check like:
2. global snapshot accumulates unbounded loose objects
The global snapshot had 258 object hash directories averaging 1.3GB each (~206GB of loose objects). Since write-tree creates tree objects without commits, and the index references them, git gc --prune=7.days may not actually prune them (they're technically reachable from the index).
Suggested fix: Periodically reset the snapshot index, or use git prune with more aggressive settings. Consider git gc --aggressive or manual git repack -a -d with pack size limits.
3. No disk usage limits or monitoring
There is no cap on snapshot storage. No check like "if snapshot dir exceeds N GB, purge old data." The only cleanup mechanism is the hourly git gc, which as shown above, can itself fail and worsen the problem.
Suggested fix: Add a configurable max size (e.g., snapshot.maxSize in config). Before each Snapshot.track(), check total size and aggressively prune or disable snapshots if the limit is exceeded.
4. No .gitignore-equivalent for the global snapshot
While git add . respects the project's .gitignore, the global snapshot doesn't have clear exclusion rules for large directories like ~/.cache/huggingface (92GB), ~/.cache/uv (31GB), etc. If the global snapshot's worktree covers the home directory, these all get tracked.
Steps to Reproduce
Use opencode on multiple projects for an extended period (days/weeks)
Have projects with large working trees
Let the hourly git gc scheduler run (and occasionally fail, e.g., due to disk pressure)
Check du -sh ~/.local/share/opencode/snapshot/
Workaround
# Nuclear option — delete all snapshots (loses undo history)
rm -rf ~/.local/share/opencode/snapshot/*# Or disable snapshots entirely in .opencode.json# { "snapshot": false }
Suggested Improvements
Clean up tmp_pack_* files before/after git gc runs
Add a total size cap with automatic pruning when exceeded
Add a startup health check that warns if snapshot storage exceeds a threshold
Use git commit-tree instead of orphaned write-tree so gc can properly manage object lifetime via commit reachability
Log snapshot storage size periodically so users can monitor growth
Consider using git gc --auto instead of unconditional git gc to let git decide when gc is needed
Note
Automated bug report — This issue was filed by an AI coding agent (Claude Code) on behalf of @Bewinxed after diagnosing a disk space emergency. All data below was collected programmatically from the affected system.
Summary
The snapshot feature in
~/.local/share/opencode/snapshot/consumed 533GB of disk space, filling a 1.1TB drive to 100% and causing system-wide issues. The root cause is a combination of:git gctemporary pack files (269GB in one snapshot alone)globalsnapshot (264GB across 258 object directories)git gc --prune=7.daysEnvironment
Disk Usage Breakdown (Before Cleanup)
Root Cause Analysis
I traced this to the snapshot implementation in
src/snapshot/index.ts. Several design issues contribute:1. Failed
git gcleaves massive temp files with no cleanupThe hourly
git gc --prune=7.daysscheduler can fail (e.g., out of disk space, process killed, OOM) and leavetmp_pack_*files inobjects/pack/. These are never cleaned up. On my system, three abandoned temp files totaled 269GB in a single snapshot repo.Suggested fix: Before running
git gc, clean up any existingtmp_pack_*files inobjects/pack/. Or add a pre-gc check like:2.
globalsnapshot accumulates unbounded loose objectsThe
globalsnapshot had 258 object hash directories averaging 1.3GB each (~206GB of loose objects). Sincewrite-treecreates tree objects without commits, and the index references them,git gc --prune=7.daysmay not actually prune them (they're technically reachable from the index).Suggested fix: Periodically reset the snapshot index, or use
git prunewith more aggressive settings. Considergit gc --aggressiveor manualgit repack -a -dwith pack size limits.3. No disk usage limits or monitoring
There is no cap on snapshot storage. No check like "if snapshot dir exceeds N GB, purge old data." The only cleanup mechanism is the hourly
git gc, which as shown above, can itself fail and worsen the problem.Suggested fix: Add a configurable max size (e.g.,
snapshot.maxSizein config). Before eachSnapshot.track(), check total size and aggressively prune or disable snapshots if the limit is exceeded.4. No
.gitignore-equivalent for theglobalsnapshotWhile
git add .respects the project's.gitignore, theglobalsnapshot doesn't have clear exclusion rules for large directories like~/.cache/huggingface(92GB),~/.cache/uv(31GB), etc. If the global snapshot's worktree covers the home directory, these all get tracked.Steps to Reproduce
git gcscheduler run (and occasionally fail, e.g., due to disk pressure)du -sh ~/.local/share/opencode/snapshot/Workaround
Suggested Improvements
tmp_pack_*files before/aftergit gcrunsgit commit-treeinstead of orphanedwrite-treeso gc can properly manage object lifetime via commit reachabilitygit gc --autoinstead of unconditionalgit gcto let git decide when gc is needed