Skip to content

Conversation

@ahosker
Copy link
Contributor

@ahosker ahosker commented Jan 7, 2026

Summary

The Snapshot directory can get very large. This is a simple command to delete it.
Its a known issue
Also relevent to #1126 #6845 #5617 #3182 #3176

This adds a new snapshot command to manage project snapshot directories with list and clear subcommands.

Changes

  • New command: opencode snapshot

    • opencode snapshot list - Lists all projects with snapshot sizes, sorted by size
    • opencode snapshot clear [project-id] - Clears specific snapshot
    • opencode snapshot clear - Clears all snapshots
  • Features:

    • Displays project ID, name, size, and last updated date
    • Safety features: --dry-run flag, confirmation prompts by default
    • --force flag to skip confirmation
    • Clear specific project or all projects
    • Error handling for missing projects
    • Success feedback showing space freed

Motivation

Snapshot directories can grow large . Users need a way to:

  • See which projects have snapshots and their sizes
  • Clean up old or unnecessary snapshots to free disk space
  • Manage snapshots per project

I have 8.1 GB across 14 projects.

image

Testing

# List all snapshots
opencode snapshot list

# Preview what would be deleted (dry-run)
opencode snapshot clear --dry-run

# Clear specific project
opencode snapshot clear <project-id>

# Clear all with confirmation
opencode snapshot clear

# Clear all without confirmation
opencode snapshot clear --force

Code Style

  • Follows project style guide (single functions, no destructuring, no else, const only)
  • Minimal changes: 2 lines in index.ts + new command file (260 lines)
  • All typechecks pass

- Add `opencode snapshot list` to list all projects with snapshot sizes
- Add `opencode snapshot clear` to clear snapshots (all or specific project)
- Include safety features: dry-run mode, confirmation prompts, error handling
- Show project details: ID, name, size, last updated date
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant