Skip to content

Warn or block snapshots when the detected git root is an accidental top-level repo #18857

Closed as not planned

Description

@bradystroud

Problem

If a user accidentally initializes a .git repo in a very high-level directory like $HOME or a broad workspace root, OpenCode's snapshot system can treat that whole tree as one giant repo and snapshot far too much data.

I hit this in practice after accidentally creating a git repo in my home directory. OpenCode then kept snapshotting that repo and the snapshot store ballooned massively.

What happened

On macOS, my machine suddenly dropped from hundreds of GB free to almost no free space.

The culprit ended up being OpenCode snapshot data:

du -sh ~/.local/share/opencode/snapshot/* | sort -hr

Output looked like this:

424G    .../snapshot/global
1.2G    .../snapshot/a36e09...
164M    .../snapshot/17143e...

The global snapshot directory was a bare git repo with roughly 401GB of pack files.

Root cause on my side: I had accidentally created a .git repo in $HOME, so OpenCode was effectively snapshotting everything under it - caches, binaries, node_modules, NuGet packages, and other large directories.

I just reproduced the same class of mistake again in another parent folder (~/Developer/bradystroud) and caught it before it blew up, which suggests this is an easy footgun.

Why this seems worth fixing

This is partly user error, but it feels like a very expensive failure mode for a common mistake:

  • accidentally creating a repo in $HOME
  • accidentally creating a repo in a broad workspace root
  • opening/running OpenCode there and letting snapshots accumulate silently

The storage growth can be extreme before the user realizes what is happening.

Suggested improvements

Any one of these would help a lot:

  • detect and warn when the git root is unusually broad ($HOME, desktop, top-level workspace folder, etc.)
  • refuse or require confirmation before snapshotting repos above a certain size / file count threshold
  • exclude known heavy directories more aggressively (node_modules, package caches, build outputs, SDKs, etc.) when the repo root is suspiciously broad
  • surface snapshot size growth in the UI/CLI so users notice it earlier
  • add a cleanup command or documented recovery flow for oversized snapshot stores

Recovery

What fixed it for me was deleting the oversized snapshot contents and removing the accidental top-level .git repo.

Context

I also wrote up the incident here with the exact numbers and cleanup steps:
https://bradystroud.dev/blogs/opencode-ate-my-storage

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 24, 2026
  2. github-actions commented on Mar 24, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • No issue template was used. This appears to be a bug report — please use the Bug Report template, which requires a structured description and reproduction steps.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  3. github-actions commented on Mar 24, 2026

    @github-actions
    Contributor

    This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

    Feel free to open a new issue that follows our issue templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions